0

I have a windows form with a aXWindowsMediaPlayer which should play a random video/picture every 5 seconds using the method aXWindowsMediaPlayer.Url = <video/image file location>. This works fine for pictures, but when a video is longer it'll only play the 5 seconds and not the full length, same for a shorter video, it'll play the full video and leaving the other seconds with a black screen.

Is there a way to configure the mediaPlayer to only go to the next picture/video when it has played the videos full length?

EDIT1:

Something like:

    Timer_TickEvent()//Every 5 seconds it chooses a random given URL
    {
       axWindowsMediaPlayer1.URL = <Random URL>;
       if(<Random URL> == 'A video?')
       {
             timer.Enabled = false;
             PlayVideoLength();
       }
    }
    Private void PlayVideoLength()
    {
     if('<Random URL.Length> ?' == 'the length of the played video in axWindowsMediaPlayer1 ?')
     {
          Timer.enabled = true;
     }
    }

This code obviously wont work. It's an idea of what I want it to do.

Nick Peelman
  • 585
  • 1
  • 10
  • 28

1 Answers1

0

You can find if your URL is a video/audio/picture media with a IWMPMedia::getItemInfo, or getType.

instead of set Url in your axWindowsMediaPlayer component :

 MyMediaComponent.Url = <MyMediaUrl>;

You can create a new with this URL:

WMPLib.IWMPMedia MyNewMedia = MyMediaComponent.newMedia(<MyMediaUrl>);

And I think you can get the type of your Media with :

MyNewMedia.getType();

You can Find the msdn documentation here.

When you find the type of your media, you can just test the type of your media before set your URL!

/* It is just a suggestion, this code don't work! */
if ( MyNewMedia.getType() == <A photo MEDIA code>)
{
    // Set the URL for show the picture
    MyMediaComponent.Url = <MyMediaUrl>;
    return;
}

//else

// This media is not a picture!

Hope my idea help you.

Doc Roms
  • 3,288
  • 1
  • 20
  • 37