AxWindowsMediaPlayer - black component when starts to play movie

934 views Asked by At

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

2

There are 2 answers

0
qweeerty78 On
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.

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