玩两个视频与axWindowsMediaPlayer

编程入门 行业动态 更新时间:2024-10-11 01:15:44
本文介绍了玩两个视频与axWindowsMediaPlayer的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我尝试播放JPG(中环),后点击MP4应结束后进行播放,是JPG应该重新播放。我不知道为什么,但之后我axWindowsMediaPlayer1_PlayStateChange VIDO戏中戏,然后停止。帮助。

使用系统; 使用System.Collections.Generic; 使用System.ComponentModel; 使用System.Data这; 使用System.Drawing中; 使用System.Linq的; 使用System.Text; 使用System.Windows.Forms的; 命名空间视频 {     公共部分类Form1中:形态     {         布尔点击= FALSE;         公共Form1中()         {             的InitializeComponent();             axWindowsMediaPlayer1.URL =wait2.JPG;         }         私人无效axWindowsMediaPlayer1_PlayStateChange(对象发件人,AxWMPLib._WMPOCXEvents_PlayStateChangeEvent E)         {             如果(axWindowsMediaPlayer1.playState == WMPLib.WMPPlayState.wmppsMediaEnded和放大器;点击==真)             {                 点击= FALSE;                 axWindowsMediaPlayer1.settings.setMode(循环,真正的);                 axWindowsMediaPlayer1.URL =wait2.JPG;                 axWindowsMediaPlayer1.Ctlcontrols.play();             }         }         私人无效axWindowsMediaPlayer1_ClickEvent(对象发件人,AxWMPLib._WMPOCXEvents_ClickEvent E)         {             axWindowsMediaPlayer1.settings.setMode(循环,假);             axWindowsMediaPlayer1.URL =video.MP4;             axWindowsMediaPlayer1.Ctlcontrols.play();             点击= TRUE;         }     } }

解决方案

我希望有人回答了这个问题,它被张贴的时间。我花了很多时间来弄清楚为什么我无法通过设置URL属性来启动新的视频。我终于找到了答案,这个问题在这里:

msdn.microsoft/en-us/library/windows/desktop/dd562470%28v=vs.85%29.aspx

现在的问题是从设置axWindowsMediaPlayer1_PlayStateChange()事件处理程序中的URL属性。根据上面的MSDN文档:

别叫从事件处理程序code此方法。从事件处理程序可能会产生意想不到的结果调用的URL。

所以URL属性,必须在即使处理程序之外。我也试过Dispatcher.Invoke(),甚至开始从事件处理程序来设置URL属性中的一个新的线程;但也没有帮助。它真的有来自事件处理程序之外!

I try to play jpg (in loop), after click mp4 should be played after end, that jpg should play again. I dont know why but after I play in axWindowsMediaPlayer1_PlayStateChange vido play and then stop. Help.

using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace Video { public partial class Form1 : Form { bool clicked = false; public Form1() { InitializeComponent(); axWindowsMediaPlayer1.URL = "wait2.JPG"; } private void axWindowsMediaPlayer1_PlayStateChange(object sender, AxWMPLib._WMPOCXEvents_PlayStateChangeEvent e) { if (axWindowsMediaPlayer1.playState == WMPLib.WMPPlayState.wmppsMediaEnded & clicked== true) { clicked = false; axWindowsMediaPlayer1.settings.setMode("Loop", true); axWindowsMediaPlayer1.URL = "wait2.JPG"; axWindowsMediaPlayer1.Ctlcontrols.play(); } } private void axWindowsMediaPlayer1_ClickEvent(object sender, AxWMPLib._WMPOCXEvents_ClickEvent e) { axWindowsMediaPlayer1.settings.setMode("Loop", false); axWindowsMediaPlayer1.URL = "video.MP4"; axWindowsMediaPlayer1.Ctlcontrols.play(); clicked = true; } } }

解决方案

I wish someone had replied to this question the time it was posted. It took me a lot of time to figure out why I was not able to start a new video by setting the URL property. I finally found the answer to this issue here:

msdn.microsoft/en-us/library/windows/desktop/dd562470%28v=vs.85%29.aspx

The problem is with setting the URL property from within the axWindowsMediaPlayer1_PlayStateChange() event handler. According to the above msdn document:

"Do not call this method from event handler code. Calling URL from an event handler may yield unexpected results."

So the URL property has to be set outside of the even handler. I also tried Dispatcher.Invoke() and even starting a new thread from within the event handler to set the URL property; but that too did not help. It really has to come from outside of the event handler!

更多推荐

玩两个视频与axWindowsMediaPlayer

本文发布于:2023-07-14 10:31:49,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1104115.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:两个   视频   axWindowsMediaPlayer

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!