Smooth Streaming Element MediaSource in Dispacher.Current... Reply Quote Edit

May 29, 2012 at 11:54 AM

Hi,

I am using SmoothStreaming in windows phone. I am getting streaming URL from asynchronous web service. and in the completed Eventhandler. Setting the response to MediaSource property.
But it is not working.

What is wrong????
 
Here is my code

   IChannel channelLogic = new ChannelLogic();  
           
            channelLogic.SecureUrlEvent += new PlayUrlDelegate((response) =>
            {
                if (response != null)
                {
                    if (response.ErrorCode == "0")
                    {
                        Deployment.Current.Dispatcher.BeginInvoke(delegate
                        {
                            player.SmoothStreamingSource = new Uri("http://***************************.sdp/Manifest", UriKind.Absolute);
                        });
                     
                        //player.Playlist.Add(new PlaylistItem() { MediaSource = new Uri("http://****************.sdp/Manifest", UriKind.Absolute) });
                        //player.Play();
                    }
                    else
                    {
                        prograssBarCanvasLandscape.Visibility = System.Windows.Visibility.Collapsed;
                        txtBlProblem.Visibility = System.Windows.Visibility.Visible;
                    }
                }
            });

            channelLogic.GetPlayUrlAsync(itemID, packCode, streamType);

Coordinator
Jun 1, 2012 at 10:55 PM

The timing is a little tricky to get right in this scenario but the fix is simple: just assign your playlistitem to CurrentPlaylistItem and away you'll go.

For background: when the framework loads, if AutoLoad=true (which is the default), the first playlistitem is automatically assigned to .CurrentPlaylistItem (which starts playback). If you miss the loading boat, you just need to do this same thing manually.