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();
    }

有任何想法吗?

4

2 回答 2

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

此代码段完成所有工作。谢谢解答。。

于 2010-12-08T06:52:53.003 回答
0

尝试将 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();
    }
}
于 2010-12-08T05:00:58.230 回答