This how-to example entails how to add video in Presentation using Java by exposing the detailed information to configure the environment and using the the example code. You may utilize this application in Java environment configured in operating systems like Linux, Windows or macOS having no dependency any third-party software or Microsoft PowerPoint to embed video in PPTX using Java.
Steps to Insert Video in Presentation using Java
- Configure the application to use Aspose.Slides for Java JAR file from repository manager
- Generate an empty presentation using an instance of the Presentation to insert a video inside the presentation
- Load the first slide inside the presentation slides collection to add a video frame
- Access the video file from the disk and add that inside the presentation slide video frame
- Set the video frame methods for auto play and volume control options
- Save the presentation having a video inside on the disk
By adhering to above steps in Java inserting video in PowerPoint presentation can be easily handled using a very simple API interface. First of all, a default presentation using an instance of the Presentation class will be created, which will then be followed by accessing the first slide inside the presentation. In the subsequent steps, the source video file will be loaded and inserted in a video frame of the selected slide. Finally, the video volume control and play mode properties will be set before saving the presentation having a video inside on the disk.
Code to Insert Video in Presentation using Java
By using the above example in Java saving MP4 video in PPT presentation has been made easily possible using a very simple API interface. We have utilized the IVideoFrame class that also let you set the flags for the features like play mode, rewind mode, play video in a loop and hiding a video to name a few. You can also link a video by providing the absolute path without actually embedding the video inside the presentation as well. Once you will embed the video inside the presentation, you can either save it on the disk or inside a memory stream for web based applications.
This example encompasses, how to insert video in Presentation using Java. If you are interested in learning about hiding a slide inside the presentation, refer to the article on how to hide a slide in presentation using Java.