Microsoft PowerPoint provides you the ability to add video frames to your PowerPoint presentations. Videos can be used to enhance the quality of the presentations and help better communicate the message to the audience. There might be situations where you want to add videos to PowerPoint presentations programmatically. To that end, this article will teach you how to embed video in PowerPoint presentations using C++.
- C++ API for Embedding Video in PowerPoint Presentations
- Embed Video in PowerPoint Presentations using C++
- Embedding Video from a Web Source in PowerPoint Presentations
- Extract Video from PowerPoint Presentations using C++
TIP: You may want to check out Aspose FREE PowerPoint to Video converter because it allows you to transform your presentations to stunning videos with transition effects.
C++ API for Embedding Video in PowerPoint Presentations
We will use the Aspose.Slides for C++ API to embed videos in PowerPoint presentations. It is a powerful and feature-rich API that supports creating, reading, and modifying PowerPoint files without needing Mircosoft PowerPoint to be installed. You can either install the API through NuGet or download it directly from the Downloads section.
PM> Install-Package Aspose.Slides.Cpp
Embed Video in PowerPoint Presentations using C++
The following are the steps to embed a video in a PowerPoint presentation.
- Firstly, create an instance of the Presentation class to represent a new PowerPoint file.
- Retrieve the slide where you want to embed the video.
- Add the video to the presentation using the Presentation->get_Videos()->AddVideo (System::SharedPtr<System::IO::Stream> stream) method.
- Add the video frame using the ISlide->get_Shapes()->AddVideoFrame(float x, float y, float width, float height, System::SharedPtr< IVideo > video) method.
- Embed the video inside the video frame using the IVideoFrame->set_EmbeddedVideo(System::SharedPtr<IVideo> value) method.
- Set the play mode and volume of the video.
- Lastly, save the presentation using the Presentation->Save(System::String fname, Export::SaveFormat format) method.
The following sample code shows how to embed a video in a PowerPoint presentation using C++.
Embedding Video from a Web Source in PowerPoint Presentations
The following are the steps to embed a video from a web source in a PowerPoint presentation.
- Firstly, create an instance of the Presentation class to represent a new PowerPoint file.
- Retrieve the slide where you want to embed the video.
- Add a video frame using the ISlide->get_Shapes()->AddVideoFrame(float x, float y, float width, float height, System::String fname) method.
- Set the play mode of the video.
- Finally, save the presentation using the Presentation->Save(System::String fname, Export::SaveFormat format) method.
The following sample code shows how to embed a video from a web source in a PowerPoint presentation using C++.
Extract Video from PowerPoint Presentations using C++
The following are the steps to extract a video from a PowerPoint presentation using C++.
- Firstly, load the PowerPoint file using the Presentation class.
- Loop through the slides of the presentation.
- Loop through the shapes in each slide.
- For each shape, check if the shape is a VideoFrame. In case it is a video frame, extract the embedded video and save it.
The following sample code shows how to extract a video from a PowerPoint presentation using C++.
Get a Free License
In order to try the API without evaluation limitations, you can request a free temporary license.
Conclusion
In this article, you have learned how to embed videos in PowerPoint presentations using C++. Moreover, you have seen how to extract embedded videos from PowerPoint presentations using Aspose.Slides for C++ API. It is a robust API that provides many additional features for working with PowerPoint files. You can explore the API in detail by visiting the official documentation. In case of any questions, please feel free to reach us at our free support forum.