Thank you very much for your swift answer and the sample project, Kiril.
I had discovered the CurrentItem
property but have not quite been able to implement what I want to achieve, as CurrentItem
seems to be ignored by the player when set on load, in the constructor or any other *early* place I could think of, in order for the desired item to start playing right away without additional user interaction. Setting AutoPlay
to true always plays the first item in the playlist, no matter what I set the CurrentItem
Here is what the prototype code looks like at the moment:
|| public Page()
|| mediaPlayer.Loaded += new RoutedEventHandler(mediaPlayer_Loaded);
|| mediaPlayer.AutoPlay = true;
|| void mediaPlayer_Loaded(object sender, RoutedEventArgs e)
|| // Pick a random item for testing
|| RadMediaItem tobeplayed = mediaPlayer.Items as RadMediaItem;
|| mediaPlayer.CurrentItem = tobeplayed;
And this is what I need to do eventually:
- my application has a single page hosting the player with a playlist of several videos.
- other pages link to the page with the player and will have an identifier for the video to be played in the query string
- as soon as as the player loads, it should play the desired item from the playlist.
- once the visitor has watched the video, they should be able to browse the playlist and view any other videos they might be interested in.
I have considered modifying the sequence of the playlist and moving the desired video to the beginning of the list, but since these are training videos that need to be in a precise sequence, this isn't really an option.
I was also able to trap the player's MediaOpened-event and set my desired video there, but this seems more like a hack than a real solution.
So basically my question boils down to this: where/when/how do I have to set CurrentItem so the desired item will be played when the page loads?
Thanks again for your help so far. We're getting there.