我们通常在幻灯片中播放插入的视频以使得演示内容更加生动有趣,在幻灯片中有两种播放视频的模式,在单击时播放和自动地播放。本文将介绍如何使用spire.presentation设置视频的播放模式。
c#
//加载ppt文档
presentation presentation = new presentation();
presentation.loadfromfile("演示文稿.pptx");
//遍历所有的幻灯片找到视频
foreach (islide slide in presentation.slides)
{
//遍历幻灯片中的形状
foreach (ishape shape in slide.shapes)
{
//判断形状是否为视频
if (shape is ivideo)
{
//设置视频的播放模式为自动地
(shape as ivideo).playmode = videoplaymode.auto;
//设置视频的播放模式为单击时
//(shape as ivideo).playmode = videoplaymode.onclick;
}
}
}
//保存ppt文档
presentation.savetofile("结果文档.pptx", fileformat.pptx2010);
vb.net
'加载ppt文档
dim presentation as new presentation()
presentation.loadfromfile("演示文稿.pptx")
'遍历所有的幻灯片找到视频
for each slide as islide in presentation.slides
'遍历幻灯片中的形状
for each shape as ishape in slide.shapes
'判断形状是否为视频
if typeof shape is ivideo then
'设置视频的播放模式为自动地
'设置视频的播放模式为单击时
'(shape as ivideo).playmode = videoplaymode.onclick;
trycast(shape, ivideo).playmode = videoplaymode.auto
end if
next
next
'保存ppt文档
presentation.savetofile("结果文档.pptx", fileformat.pptx2010)