玩两个视频与axWindowsMediaPlayer [英] Playing two video with axWindowsMediaPlayer

查看:143
本文介绍了玩两个视频与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属性来启动新的视频。我终于找到了答案,这个问题在这里:

<一个href="http://msdn.microsoft.com/en-us/library/windows/desktop/dd562470%28v=vs.85%29.aspx">http://msdn.microsoft.com/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:

http://msdn.microsoft.com/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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆