AxWindowsMediaPlayer - black component when starts to play movie

家住魔仙堡 提交于 2019-12-24 07:15:40

问题


I am using AxWindowsMediaPlayer component in my WinForm application. I noticed that when I set URL to file I want to play and call Ctlcontrols.play() command there is an eg. 250ms delay before movie starts to play.

During this delay area of AxWindowsMediaPlayer is black. This behavior can be very easily seen when you are changing from one movie to another, or just when you stop currently playing movie and start it again.

My current solution is based on postponed AxWindowsMediaPlayer visibility set to true when starting to play movie. Player is displayed to user after eg. 500ms when I am sure, movie is actually playing and user will not see black nothing.

I am looking for better way how to avoid black nothing player. Does anyone solved similar issue? Or at least because I am dealing with very empiric values which will be different on different PCs, is there way how create foolproof solution?

Prereq: WinForms, .NET 4.0, WMP 12 for Windows 7


回答1:


private void OnPlayStateChange(object sender, AxWMPLib._WMPOCXEvents_PlayStateChangeEvent e)
{
    switch (e.newState)
    {
        case 3: // Playing started
           // Show your control
           break;
    }
}



回答2:


private void timer1_Tick(object sender, EventArgs e)
{
    if(axWindowsMediaPlayer1.Ctlcontrols.currentPosition > axWindowsMediaPlayer1.Ctlcontrols.currentItem.duration - 0.01)
        {
        axWindowsMediaPlayer1.Ctlcontrols.currentPosition = 0;
        }
}

this code change currentPosition to 0 second when video running 0.01 milliseconds so that transition effect of black screen can be avoided. But for short videos additional codes needed.



来源:https://stackoverflow.com/questions/18641519/axwindowsmediaplayer-black-component-when-starts-to-play-movie

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