Using the Silverlight 1.0 MediaElement for live streaming
If you want to create a Live TV player with Silverlight, perhaps are you going to face with some troubles if you want to switch from a live stream to another. The problem comes if you try to use Stop and Play methods. Instead, you have to use the AutoPlay property
Here is a sample :
...
media = rootElement.findName("mediaElement");
media.addEventListener("MediaOpened", Silverlight.createDelegate(this, this.handleMediaOpened));
...
setMediaElementSource : function(sender, url) {
this.startWaiting(sender); // start an animation
media.AutoPlay="False"
media.Source = url ;
media.AutoPlay="True"
},
handleMediaOpened: function(sender, eventArgs)
{
this.stopWaiting(sender); // stop the animation
},
startWaiting : function(sender)
{
sender.findName("StoryboardWaiting").begin();
},
stopWaiting : function(sender)
{
sender.findName("StoryboardWaiting").stop();
}