Silverlight C# Sound Loop


/ Published in: C#
Save to your folder(s)

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


Copy this code and paste it in your HTML
  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. }

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

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.