Windows Media Player ctlcontrols.play and URL don't work

丶灬走出姿态 提交于 2019-12-12 04:44:28

问题


    private void mediaPlayer_Enter()
    {
        string path = Path.GetFullPath(currentTrack.Text);
        System.Diagnostics.Debug.WriteLine(path);
        mediaPlayer.URL = path;
        mediaPlayer.Ctlcontrols.play();
    }

This is the piece of code which is being called when the state of the media player turns to "media ended". I know that it does execute that line of code but it still doesn't play. It takes the item out of the listbox (which is the playlist) and loads it into the mediaPlayer but does not Automatically play the song. I have to press the button to start playing it - it has do play it stright away by itself. What am I doing wrong?


回答1:


I believe this will autoplay your media: http://msdn.microsoft.com/en-us/library/windows/desktop/dd562405(v=vs.85).aspx

If the AxWindowsMediaPlayer.settings.autoStart property is true, playback begins automatically whenever you set currentMedia.



来源:https://stackoverflow.com/questions/22969315/windows-media-player-ctlcontrols-play-and-url-dont-work

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!