Saturday, 11 August 2007

Looping a Media Element in Silverlight

I answered this post earlier today, because there is no support for mediatimeline in silverlight, we have to code in looping of media elements.

All you really need to do is call play on the mediaended event (remember to hook in the event in the xaml)

code below:



protected void myMediaElement_MediaEnded(object sender, EventArgs args)
{

// Replay the video

MediaElement video = (MediaElement)sender;video.Position = new TimeSpan(0);
video.Play();

}

No comments: