In this short blog, I will talk about how to assign media url in code behind for SSME: SmoothStreamingMediaElement. For this code sample, I am not using Microsoft Media Platform: Player Framework v2.6. I am building the application from scratch using Silverlight Smooth Streaming Client v1.5. I hope this short blog will help you while debugging.
1. You will need to add the player in .xaml file. I didn't set the streaming source in SmoothStreamingMediaElement in .xaml file.
<SSME:SmoothStreamingMediaElement AutoPlay="false" x:Name="SmoothPlayer" Grid.Row="0" />
2. And go to the code behind, and insert the following code
SmoothPlayer.SmoothStreamingSource = new Uri("http://devplatem.vo.msecnd.net/Sintel/Sintel_VC1.ism/manifest");
SmoothPlayer.MediaOpened += (o, e) =>
You will see from the code above, the first step is straight-forward, that we assign the media source URI to SmoothStreamingSource. However, if now, you immediately call SmoothPlayer.Play(), you will get an error. That's because when media source gets set up, Smooth Streaming player will do a bunch of things, such as downloading manifest and downloading some amount of data chunks. Thus, initially I called SmoothPlayer.Play() after ManifestReady() event, that's also wrong. Because Smooth Streaming player still needs to validate the media stream and read the file reader. However, MediaOpened event guaranteed all these. For details, you could read on MediaOpened() MSDN documentations here.
In addition, if you want to read more about how we design different state of the media elements, you could read MSDN documents Media Element State Transitions.