locked
Position after MediaEnded RRS feed

  • Question

  • Hello

    I'm trying to implement a video player based on the sleek video player sample. I'm trying to display the playhead to follow the current MediaElement.Position accurately.

    After receiving the MediaEnded event, the position is not equal to the MediaElement.MediaDuration and as a result, the position of the playhead is not exactly aligned with the right border of the playhead channel.

    You can reproduce it with the Bear.wmv video sample (from Windows Vista) and the SleekVideoPlayer sample.

    It is important for me to keep the last displayed position at the end of the video clip, and it is not a solution to move the playhead back at the beginning of the clip after playback.

    As a workaround, I'm moving the playhead manually (MediaElement.Position = MediaElement.NaturalDuration) after receiving the event but the jump is quite noticeable and look like the player skipped some frames at the end (not good from an user experience point of view, especially if the goal is to help the user analyse the video.)

    Any idea welcome,
    Pascal

    Thursday, March 8, 2007 9:20 PM

Answers

  • Thanks for the quick answer.

    I will do more tests on this particular issue once the updated CTP is available.

    Cheers,
    Pascal

    Friday, March 9, 2007 8:08 PM

All replies

  • I'm trying to understand how you're using the MediaEnded event since the SleekVideoPlayer example doesn't use it.

    Are you just saying that at the end of the video the time / naturalduration does not equal 1 so you're not putting the playhead marker at the end of the channel?

     

    Thursday, March 8, 2007 10:31 PM
  • Yes you are right, after receiving the MediaEnded event, the value time/naturalDuration is '0.985...'.

    As said, I'm experimenting from the SleekVideoPlayer. As you don't known when the last Interval has been handled since the MediaElement ended, it is necessary to update the playhead to the final position. For the record, I'm also using the CurrentStateChanged to start/stop the interval timer.

    For me, it is a bug.

    Thanks,
    Pascal

    Friday, March 9, 2007 5:57 AM
  • This may be a combination of bug and bad behavior by video files.

    Bug: on Feb CTP, there are known issues where the MediaElement will not play some media files until the absolute end.  This has been addressed internally, and will be available on our next release.  The issue is that some files have an audio/video stream that is longer than the other.  The MediaElement did not deal very well with these situations on Feb CTP, so it might prematurely raise MediaEnded.

    Bad Behavior: many media files will lie about their actual duration in the file header metadata.  This value is what MediaElement.naturalDuration returns, so there is always a chance that the Position property will not be exactly equal to NaturalDuration by the time MediaEnded is raised.  If you want your app to be robust to video files that do this, your best best is probably to jump the play head to the end once MediaEnded is raised.

    In summary, the only guarantee that MediaElement.MediaEnded gives is that all audio/video streams in the file have ended (modulo the bug on Feb CTP).  NaturalDuration may actually not be exactly correct, but usually it's good enough.

    Hope this helps.
    Ed Maia
    WPF/E Program Manager

    Friday, March 9, 2007 6:24 PM
  • Thanks for the quick answer.

    I will do more tests on this particular issue once the updated CTP is available.

    Cheers,
    Pascal

    Friday, March 9, 2007 8:08 PM