如何在PPT中自动同时播放两个视频

  1. 嵌入视频

  2. 视频工具中选择自动播放
    在这里插入图片描述

  3. 动画中第二个视频选择和上一动画同时
    在这里插入图片描述

您可以使用Microsoft.Office.Interop.PowerPoint命名空间中的类来实现在WPF窗口中播放PPT。具体步骤如下: 1. 添加对Microsoft.Office.Interop.PowerPoint的引用。 2. 在WPF窗口中添加一个WindowsFormsHost控件。 3. 在WindowsFormsHost控件中添加一个AxHost控件,并将其类型设置为Microsoft.Office.Interop.PowerPoint.Presentation。 4. 在窗口加载事件中,使用Microsoft.Office.Interop.PowerPoint.Application类加载PPT文件。 5. 在AxHost控件的CreateControl方法中,使用Microsoft.Office.Interop.PowerPoint.SlideShowSettings类设置PPT播放方式。 下面是示例代码: ```C# using System.Windows.Forms.Integration; using Microsoft.Office.Interop.PowerPoint; //添加引用:Microsoft.Office.Core、Microsoft.Office.Interop.PowerPoint //在WPF窗口中添加一个WindowsFormsHost控件 WindowsFormsHost host = new WindowsFormsHost(); this.grid.Children.Add(host); //在WindowsFormsHost控件中添加一个AxHost控件,并将其类型设置为Microsoft.Office.Interop.PowerPoint.Presentation AxHost axHost = new AxHost(); axHost.Dock = DockStyle.Fill; axHost.CreateControl(); axHost.GetType().InvokeMember("Enable", BindingFlags.InvokeMethod, null, axHost, new object[] { true }); axHost.GetType().InvokeMember("DisplayAlerts", BindingFlags.SetProperty, null, axHost, new object[] { PpAlertLevel.ppAlertsNone }); host.Child = axHost; //在窗口加载事件中,使用Microsoft.Office.Interop.PowerPoint.Application类加载PPT文件 private void Window_Loaded(object sender, RoutedEventArgs e) { Application pptApp = new Application(); Presentation pptPresentation = pptApp.Presentations.Open(@"D:\test.pptx", MsoTriState.msoTrue, MsoTriState.msoFalse, MsoTriState.msoFalse); axHost.GetType().InvokeMember("Ocx", BindingFlags.SetProperty, null, axHost, new object[] { pptPresentation }); } //在AxHost控件的CreateControl方法中,使用Microsoft.Office.Interop.PowerPoint.SlideShowSettings类设置PPT播放方式 protected override void CreateControl() { base.CreateControl(); if (this.ActiveXInstance != null) { SlideShowSettings slideShowSettings = ((Presentation)this.ActiveXInstance).SlideShowSettings; slideShowSettings.ShowType = PpSlideShowType.ppShowTypeSpeaker; slideShowSettings.Run(); } } ``` 注意:在使用AxHost控件播放PPT时,需要在CreateControl方法中设置PPT播放方式。此外,由于AxHost控件是Windows Forms控件,因此需要使用WindowsFormsHost控件将其嵌入到WPF窗口中。
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值