I am using the Apache POI library to create powerpoint slides with Java.
Our client is interested in embedded text, images and videos. No fancy
stuff like charts etc. is needed for now. I understand that XSLF is still
under development and not yet a mature product.
I have achieved my target using Apache POI HSLF model but the only thing it is missing is that videos which are embedded doesn't show up any playback controls. After little researching I found that it is the pptx and ppt file standards which are making the things different. So now to solve this issue I am migrating from HSLF to XSLF. But unfortunately XSLF library doesn't have any method to add video file (unlike HSLF addmovie method).
What method you guys recomend ? Is there any other way to show the playback controls on ppt files(and not pptx)?I mean by additional activex control/mediaplayer. If yes how should it be done using Java ?
Beginning from Powerpoint 2010 it's possible to embed videos in PPTX-files (... instead of linking them or using some kind of ActiveX/youtube combo). If you embed MP4-videos you need to have the Quicktime plugin installed.
Regarding the playback controls, my PP 2010 viewer displays them when you move the mouse over the video shape. Sometimes they never show up again, when you click straight into the image instead of waiting for the popup.
The following code ...
- fetches a MPEG (could be also a local file)
- creates a snapshot of the frame on the 5th second, which is used as the preview image. I've used the Xuggle libs here, but of course any other libs are ok too (... plain JMF (without extension pack) couldn't handle (this) MPEGs)
- embeds image and video
- and adds some arbitrary ;) stuff, which PP needs to actually play the video
Here is the code:
https://svn.apache.org/viewvc/poi/trunk/src/examples/src/org/apache/poi/xslf/usermodel/AddVideoToPptx.java.txt
(Update 2016-02-06: moved the code to POI examples, so there's only one place to be modifed in case of new features. Furthermore there was a regression in POI 3.13 making it impossible to add pictures after adding movies to the media directory - this is fixed in the upcoming POI 3.14)