Question

I want to pass a URL to a SMFPlayer at runtime, is there a way to do this in XAML without Binding ? Instead of statically setting the source like I've done below.

So basically the user clicks a button associated with a specific object. A URL field is extracted and passed to the player.

<Core:SMFPlayer x:Name="smf" LogLevel="Error"  LogWriters="ConsoleDebug" RetryInterval="00:00:15" RetryDuration="00:01:00">
    <Core:SMFPlayer.Playlist>
        <Media:PlaylistItem>
            "MediaSource="http://az30243.vo.msecnd.net/ss-video/HawaiiSurfing_H264_EE4_CBR_1080p_Xbox.ism/manifest"
            MediaAssetId="asdf"                 
            DeliveryMethod="AdaptiveStreaming"       
            />
    </Core:SMFPlayer.Playlist>
</Core:SMFPlayer>
Was it helpful?

Solution

I dont think there is a way to do it in XAML at runtime, but you can do it programmatically at runtime. In your code behind you can use the following.

 Microsoft.SilverlightMediaFramework.Core.Media.PlaylistItem mp = new    Microsoft.SilverlightMediaFramework.Core.Media.PlaylistItem();
            mp.MediaSource = strPath;
            smf.CurrentPlaylistItem = mp;
            smf.Play();

This way, you can set your strPath to any Uri. Depending on your UI for example, this button plays this video and etc. Setting each one to a different strPath will let you swap videos in and out.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top