RewindAndPlay
When a silverlight MediaElement finishes playing, it does not rewind automatically. This extension method sets the MediaElement position at Zero and starts playing.
Source
public static class MediaExtensions
{
public static void Rewind(this MediaElement mediaElement) {
if (mediaElement.CurrentState != MediaElementState.Stopped)
mediaElement.Stop();
mediaElement.Position = TimeSpan.Zero;
}
public static void RewindAndPlay(this MediaElement mediaElement)
{
mediaElement.Rewind();
mediaElement.Play();
}
}
Example
MediaElementSlideIn.RewindAndPlay();
Author: Loek van den Ouweland
Submitted on: 7 sep. 2009
Language: C#
Type: System.Windows.Controls.MediaElement
Views: 5503