If you have been trying to play around with sound and video in Silverlight 2.0 you might have run into a problem where the media does not play the first time you call the play function.
The problem is that the media element might not be loaded and ready by the time you call play.
To solve the problem you can use the MediaElement MediaOpened Event that occurs when the media has been loaded and ready to play.
Example:
{
.....
// assume we have a sound/video media element called me
MediaElement me;
.....
// play does not always work since media is not ready
//me.Play();
// add MediaOpened event handler
me.MediaOpened += new RoutedEventHandler(me_MediaOpened);
}
// the event handler can play the sound/video since its ready to play
void me_MediaOpened(object sender, RoutedEventArgs e)
{
((MediaElement)sender).Play();
}