How to make a video timeline? RRS feed

  • Question

  • Hi.

    How can i make a "timeline" to my video player, so you can se where in  the movie you are?

    Tuesday, December 8, 2009 9:45 AM

All replies

  • If you are using the MediaPlayer component, you can use the Position  property.

    If you are using MediaElement or other StoryBoard oriented approach, you might consider using the Storyboard.CurrentTimeInvalidated
    direct event in combination with a progress bar. Some code-behind will be needed.

            private void storyboard_CurrentTimeInvalidated(object sender, EventArgs e)
                Clock storyboardClock = (Clock)sender;
                if (storyboardClock.CurrentProgress == null)
                    progressBar.Value = 0; //Animation is stopped
                    progressBar.Value = (double)storyboardClock.CurrentProgress;
                    //you can also use storyboardClock.CurrentTime if you need to show a text field with the elapsed time

    Tuesday, December 8, 2009 12:55 PM
  • How could the xaml part look like?
    Wednesday, December 9, 2009 8:39 AM
  • With MediaElement, you can attach a handler to the CurrentTimeInvalidated event of the nested MediaTimeline element. Take a look at this article:
    Thursday, December 10, 2009 10:51 AM
  • Hi,
        I'm trying to do the same thing but in Silverlight, and for the most part failing. First I tried Element Property binding the Position.TotalSeconds to my Slider.Value,
    and NaturalDuration.TimeSpan.TotalSeconds to Slider.Maximum. The Slider.Value binding did nothing, and the Slider.Maximum always came out as 0. In case it was going wrong when there's no Position.TotalSceconds as no video has been loaded. I handled MediaOpened and set the bindings from code: which also failed and produced the same results. MediaTimeline does not exist in Silverlight, and I'm having a hard time figuring out how to implement a "timeline".

    Any Ideas or a solution would be greatly appreciated

    The Admin Jr
    Languages: Visual Basic, C, C++, Python,HTML, XML, C#, JavaScript, XAML
    Wednesday, December 23, 2009 3:56 PM