Posted By

johnlync on 12/04/09


Tagged

video loop sound Silverlight mediaelement


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

danfinrud55


Silverlight C# Sound Loop


 / Published in: C#
 

URL: http://www.john-lynch.org/

There's no built-in "loop" property on the Silverlight mediaElement control. Add a listener to any mediaElement and this function will loop it.

  1. //to add Event Handler where "ambient1" and "ambient2" are different media elements...
  2.  
  3. ambient1.MediaEnded += new RoutedEventHandler(media_MediaEnded);
  4. ambient2.MediaEnded += new RoutedEventHandler(media_MediaEnded);
  5.  
  6. //Event Handler
  7.  
  8. void media_MediaEnded(object sender, RoutedEventArgs e)
  9. {
  10. MediaElement ctrl = (MediaElement)sender;
  11. ctrl.Stop();
  12. ctrl.Play();
  13. }

Report this snippet  

You need to login to post a comment.