有没有办法在 Windows Media Control 中重播视频?

发布于 2024-10-06 20:03:53 字数 1178 浏览 2 评论 0原文

如何在 Windows Media 控件中重播视频?我尝试用这种方法来做?但它不起作用

    public Form1()
    {
        InitializeComponent();
    }

    private void Form1_Load(object sender, System.EventArgs e)
    {
        //mediaPlayer.currentPlaylist = mediaPlayer.mediaCollection.getByName("Dastan");
        //mediaPlayer.URL = @"C:\Documents and Settings\Администратор\Мои документы\Моя музыка\Мои списки воспроизведения\Dastan.wpl";
        //mediaPlayer.uiMode = "none";
        PlayFile(@"C:\Documents and Settings\Администратор\Мои документы\Моя музыка\Мои списки воспроизведения\Dastan.wpl");
    }

    private void mediaPlayer_PlayStateChange(object sender, AxWMPLib._WMPOCXEvents_PlayStateChangeEvent e)
    {
        if ((WMPLib.WMPPlayState)e.newState == WMPPlayState.wmppsPlaying)
        {
            mediaPlayer.fullScreen = true;
            mediaPlayer.Ctlenabled = false;
        }
        else if ((WMPLib.WMPPlayState)e.newState == WMPPlayState.wmppsMediaEnded)
        {
            Form1_Load(null, null);
        }
    }
    private void PlayFile(String url)
    {
        mediaPlayer.URL = url;
        mediaPlayer.Ctlcontrols.play();
    }

有什么想法吗?

How I can replay a video in Windows Media control? I try to do it by this way? but it doesn't work

    public Form1()
    {
        InitializeComponent();
    }

    private void Form1_Load(object sender, System.EventArgs e)
    {
        //mediaPlayer.currentPlaylist = mediaPlayer.mediaCollection.getByName("Dastan");
        //mediaPlayer.URL = @"C:\Documents and Settings\Администратор\Мои документы\Моя музыка\Мои списки воспроизведения\Dastan.wpl";
        //mediaPlayer.uiMode = "none";
        PlayFile(@"C:\Documents and Settings\Администратор\Мои документы\Моя музыка\Мои списки воспроизведения\Dastan.wpl");
    }

    private void mediaPlayer_PlayStateChange(object sender, AxWMPLib._WMPOCXEvents_PlayStateChangeEvent e)
    {
        if ((WMPLib.WMPPlayState)e.newState == WMPPlayState.wmppsPlaying)
        {
            mediaPlayer.fullScreen = true;
            mediaPlayer.Ctlenabled = false;
        }
        else if ((WMPLib.WMPPlayState)e.newState == WMPPlayState.wmppsMediaEnded)
        {
            Form1_Load(null, null);
        }
    }
    private void PlayFile(String url)
    {
        mediaPlayer.URL = url;
        mediaPlayer.Ctlcontrols.play();
    }

Any ideas?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

波浪屿的海角声 2024-10-13 20:03:53
mediaPlayer.settings.setMode("loop", true); 

此代码片段完成了所有工作。谢谢各位的解答..

mediaPlayer.settings.setMode("loop", true); 

This code snippet does all job. Thanks for answers..

始于初秋 2024-10-13 20:03:53

尝试将 mediaPlayer.Ctlcontrols.currentPosition 设置为 0。

private void mediaPlayer_PlayStateChange(object sender, AxWMPLib._WMPOCXEvents_PlayStateChangeEvent e)
{
    if ((WMPLib.WMPPlayState)e.newState == WMPPlayState.wmppsPlaying)
    {
        mediaPlayer.fullScreen = true;
        mediaPlayer.Ctlenabled = false;
    }
    else if ((WMPLib.WMPPlayState)e.newState == WMPPlayState.wmppsMediaEnded)
    {
        mediaPlayer.Ctlcontrols.currentPosition = 0;
        mediaPlayer.Ctlcontrols.play();
    }
}

Try setting mediaPlayer.Ctlcontrols.currentPosition to 0.

private void mediaPlayer_PlayStateChange(object sender, AxWMPLib._WMPOCXEvents_PlayStateChangeEvent e)
{
    if ((WMPLib.WMPPlayState)e.newState == WMPPlayState.wmppsPlaying)
    {
        mediaPlayer.fullScreen = true;
        mediaPlayer.Ctlenabled = false;
    }
    else if ((WMPLib.WMPPlayState)e.newState == WMPPlayState.wmppsMediaEnded)
    {
        mediaPlayer.Ctlcontrols.currentPosition = 0;
        mediaPlayer.Ctlcontrols.play();
    }
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文