locked
telling whether a video has finished playing RRS feed

  • Question

  • Is there any way to determine in code whether a video has completed playing yet?

    I want to make a button that both starts and stops a video. I can do this by just keeping track of two states. If the last click started, then the button will stop. And vice-versa. But if the video has completed playback, i want the button to start playback, even though the last click also started it. So a better method is to ask whether or not the video is currently playing. Is there a way to test for this?

    Sunday, April 20, 2008 6:27 PM

Answers

  • I would have that MediaElement fire a "Completed" event.

    <MediaElement x:Name="BikiniGirls" Width="200" Height="200" MediaEnded="MOV_Done" Source="/media/girls.wmv"></MediaElement>

    And then in the .cs file:

     

    private void MOV_Done(object sender, RoutedEventArgs e)
            {

    // Magical code here

            }

     

    Monday, April 21, 2008 12:45 PM

All replies

  • You can check the CurrentState property of the MediaElement or maybe the CanPause is enough for you ?

    Monday, April 21, 2008 3:52 AM
  • I would have that MediaElement fire a "Completed" event.

    <MediaElement x:Name="BikiniGirls" Width="200" Height="200" MediaEnded="MOV_Done" Source="/media/girls.wmv"></MediaElement>

    And then in the .cs file:

     

    private void MOV_Done(object sender, RoutedEventArgs e)
            {

    // Magical code here

            }

     

    Monday, April 21, 2008 12:45 PM
  • Heap of thanks. That is exactly what I was looking for. Is there a list somewhere of all the built-in event handlers for all xaml elements?

    Monday, April 21, 2008 8:03 PM
  • Have a look in the sdk.

    Tuesday, April 22, 2008 3:29 AM