为了使PPT演示文件更加丰富动人,开发人员可以在PPT文件中嵌入各种播放视频,
Aspose.Slides for .NET可以利用简单的代码轻松帮助开发人员实现该功能,这篇文章主要就是介绍如何使用
Aspose.Slides提供的API实现这个功能,具体可以参考下面的代码:
//Instantiate Presentation class that represents the PPTX
using (Presentation pres = new Presentation())
{
//Get the first slide
ISlide sld = pres.Slides[0];
//Embedd vide inside presentation
IVideo vid = pres.Videos.AddVideo(new FileStream("Wildlife.wmv", FileMode.Open));
//Add Video Frame
IVideoFrame vf = sld.Shapes.AddVideoFrame(50, 150, 300, 350, vid);
//Set video to Video Frame
vf.EmbeddedVideo = vid;
//Set Play Mode and Volume of the Video
vf.PlayMode = VideoPlayModePreset.Auto;
vf.Volume = AudioVolumeMode.Loud;
//Write the PPTX file to disk
pres.Save("VideoFrame.pptx", SaveFormat.Pptx);
}