04 February, 2011

WP7: How to receive streaming video in your application

I yesterday set out to produce a streaming video client as a POC. Basically, I wanted the ability to show live video feeds on the phone and that without having to download the video onto the device first.

Therefore, the solution should be to receive a video in a streaming manner from a resource (server) on the internet.

image

How to do?

It turns out it is pretty easy to create. MS has creating a streaming video client control (Microsoft.Web.Media.SmoothStreaming, Link) that should be able to do the job, but it is not all that easy to use. On CodePlex, some guys have made a control that in contrast makes it very easy to set up. This framework is called SMF (Silverlight Media Framework) and includes a SMFPlayer control (http://smf.codeplex.com/)

References:
The references you need to have in your project are shown below.

image

You need to add these to ref. in your page XAML:

    xmlns:Core="clr-namespace:Microsoft.SilverlightMediaFramework.Core;assembly=Microsoft.SilverlightMediaFramework.Core.Phone" 
xmlns:Media
="clr-namespace:Microsoft.SilverlightMediaFramework.Core.Media;assembly=Microsoft.SilverlightMediaFramework.Core.Phone"


and finally the player is embedded like this:


<Core:SMFPlayer>
<
Core:SMFPlayer.Playlist>
<
Media:PlaylistItem
DeliveryMethod="AdaptiveStreaming"
MediaSource="http://ecn.channel9.msdn.com/o9/content/smf/smoothcontent/bbbwp7/big buck bunny.ism/manifest"/>
</
Core:SMFPlayer.Playlist>
</
Core:SMFPlayer>

That is basically all there is to it. Of-course a lot of properties/settings can me tweaked to make the player look/behave as you prefer – but a basic setup is the above. Note the mediaSource here is the bugsbunny sample stream; in this case hosted on a channel9-server.


Not sure as to why SMF suggests that you should reference the Microsoft.Web.SmoothStreaming assembly, as the project runs fine without it. But that’s what they state?


Happy coding!



Technorati Tags: ,

No comments:

iPhone/XCode - not all cases are equal!

This bit me! Having made some changes to an iPhone application (Obj-C); everything worked fine in the simulator. But, when deploying the s...