Passing in playlist in InitParams

Sep 16, 2010 at 7:02 PM

Is there any support for passing in a playlist from initparams similar to the expression players?  I want to be able to set a playlist for the player without javascript.  For example:

<object data="data:application/x-silverlight-2," type="application/x-silverlight-2" ...>

    <param name="initparams" value='playerSettings =
                <Playlist>
                    <AutoLoad>true</AutoLoad>
                    <AutoPlay>false</AutoPlay>
                    <DisplayTimeCode>false</DisplayTimeCode>
                    <EnableOffline>true</EnableOffline>
                    <EnablePopOut>true</EnablePopOut>
                    <EnableCaptions>true</EnableCaptions>
                    <EnableCachedComposition>true</EnableCachedComposition>
                    <StretchNonSquarePixels>NoStretch</StretchNonSquarePixels>
                    <StartMuted>false</StartMuted>
                    <StartWithPlaylistShowing>false</StartWithPlaylistShowing>
                    <Items>
                        <PlaylistItem>
                            <MediaSource>http://wss.mp.advection.net/mp/deveducate/UnderstandingEF4Preview.wmv</MediaSource>
                            <ThumbSource>http://www.deveducate.com/content/images/trainingthumbs/OverviewOfUnderstandingEF4_Thumb.jpg</ThumbSource>       
                            <Title>Understanding Entity Framework 4</Title>
                                   
                            <AudioCodec>WmaProfessional</AudioCodec>
                            <DRM>false</DRM>
                            <VideoCodec>VC1</VideoCodec>
                            <IsAdaptiveStreaming>false</IsAdaptiveStreaming>
                            <Width>900</Width>
                            <Height>675</Height>
                            <AspectRatioWidth>4</AspectRatioWidth>
                            <AspectRatioHeight>3</AspectRatioHeight>
                        </PlaylistItem>...

Sep 18, 2010 at 8:10 PM

Rob,

this is a very interesting proposition. Have you made any headway in figuring this out? If you have, would you mind posting here please.

Thanks

 

Sep 18, 2010 at 9:57 PM

I made some headway implementing it myself.  However, I am running into the same issue noted here:  http://smf.codeplex.com/Thread/View.aspx?ThreadId=225581.  The workaround noted in that thread kind of works, but is not optimal.  I'll make a post when I have a better solution.

Sep 18, 2010 at 10:32 PM

Rob,

not sure if you are using this playList to create a YouTube like player, thats really what im trying to do. Do you know if the video files can sit on the local server, and if so can you set the playListItems with something like this ("~/Myserver/somefile.wmv") to the location of the file instead of a URL (http://www.someserver.com/somefile.wmv)? 

I posted the question here, but Im not getting a definitive answer. http://smf.codeplex.com/Thread/View.aspx?ThreadId=78850

Thanks

Sep 22, 2010 at 6:05 PM

There is actually a method SMFPlayer.LoadInitParams(IDictionary<string, string> initParams) that does exactly what you need.  The key of your playlist must be "Playlist".

Oct 1, 2010 at 8:01 AM
Edited Oct 1, 2010 at 9:13 AM

cchao, how exactly do you use the LoadInitParams? I want to send the playlist from my server side to the smf player.

To clarify, I have groups of videos that i want to play, so each group...lets say item, as they are clicked, i want to pass that set of playlists to the smf player. that is what i am trying to achieve. can you give some pointers on how to achieve this please.

thanks

 

Oct 1, 2010 at 12:45 PM

Hi;

Not sure if this may help or not but you can pass your initparms as normal and add them as a resource in named pairs...  Here is code from my app.xaml.cs file so it loads them into resources...  thaks to someone else for posting on another site....

 

 if (e.InitParams != null)
            {
                foreach (var item in e.InitParams)
                {
                    this.Resources.Add(item.Key, item.Value);
                }
            }

 

then I call a function to get them back after the load...

private void ParseInitParams()
    {
    //Get xxx from the InitParams resources.... 
        if (!ReferenceEquals(App.Current.Resources["PARMNAME"], null))
        {

// load it into whatever... this case simulated global variables class....
            GlobalVariables.G_VideoSource = App.Current.Resources["VideoType"].ToString();
}

else
            {

//show custom dialog child window...
                Dialog ad1 = new Dialog("Initialization Error", "Critical Error: The xxx was not passed via INITPARAMS", 1);
                ad1.Show();
                SISPlayer.Stop();
                SISPlayer.IsEnabled = false;
                ad1 = null;
            }

}

Not sure if this is of any use to anyone but here it is anyhow...  Good Luck...  Of course you could pass all the elements of the playlist as a delimited string and parse it after if named pairs are not applicable...  Hope this helps...

Cheers;

Brendon   

Oct 7, 2010 at 5:39 AM

Thanks cchao,

It works flawlessly.  Here is some code to illustrate:

        public virtual void OnStartup(object sender, StartupEventArgs e)
        {
            if (Application.Current.InstallState == InstallState.NotInstalled)
            {
                ParseInitParams(e);
            }
        }

        private void ParseInitParams(StartupEventArgs e)
        {
            string strInitValue;
            if (e.InitParams.TryGetValue("playerSettings", out strInitValue))
            {
                Dictionary<string, string> parms = new Dictionary<string,string>();
                parms.Add("PlayList", strInitValue);
                mediaPlayer.LoadInitParams(parms);
            }
        }

(Don't forget to wire up OnStartup)

Oct 7, 2010 at 7:00 AM

Rob

Whats the purpose of the OnStartup?

Also, can you show me a sample of what your initParams looks like please. maybe thats where im making the mistake, cause i couldnt get my version to work.

thanks

 

Oct 7, 2010 at 7:58 AM

spinz2112,

OnStartup is just a method I call from Application_Startup:

private void Application_Startup(object sender, StartupEventArgs e)
        {
            MainPage pg = new MainPage();
            this.RootVisual = pg;
            pg.OnStartup(sender, e);
        }

Here is a sample of initparams:

 

<param name="initparams" value='playerSettings =
          <Playlist>
                    <AutoLoad>true</AutoLoad>
                    <AutoPlay>true</AutoPlay>
                    <DisplayTimeCode>false</DisplayTimeCode>
                    <EnableOffline>true</EnableOffline>
                    <EnablePopOut>true</EnablePopOut>
                    <EnableCaptions>true</EnableCaptions>
                    <EnableCachedComposition>true</EnableCachedComposition>
                    <StretchNonSquarePixels>NoStretch</StretchNonSquarePixels>
                    <StartMuted>false</StartMuted>
                    <StartWithPlaylistShowing>false</StartWithPlaylistShowing>
                    <Items>
                        <PlaylistItem>
                            <MediaSource>http://www.someurl.com/somevideo.wmv</MediaSource>
                            <ThumbSource>http://www.someurl.com/SomeThumb.jpg</ThumbSource>       
                            <Title>Some Title</Title>
                            <AudioCodec>WmaProfessional</AudioCodec>
                            <DRM>false</DRM>
                            <VideoCodec>VC1</VideoCodec>
                            <IsAdaptiveStreaming>false</IsAdaptiveStreaming>
                            <Width>900</Width>
                            <Height>675</Height>
                            <AspectRatioWidth>4</AspectRatioWidth>
                            <AspectRatioHeight>3</AspectRatioHeight>
                        </PlaylistItem>
                        <PlaylistItem>
                            <MediaSource>http://www.someurl.com/someothervideo.wmv</MediaSource>
                            <ThumbSource>http://www.someurl.com/SomeOtherThumb.jpg</ThumbSource>       
                            <Title>Some Other Title</Title>
                            <AudioCodec>WmaProfessional</AudioCodec>
                            <DRM>false</DRM>
                            <VideoCodec>VC1</VideoCodec>
                            <IsAdaptiveStreaming>false</IsAdaptiveStreaming>
                            <Width>900</Width>
                            <Height>675</Height>
                            <AspectRatioWidth>4</AspectRatioWidth>
                            <AspectRatioHeight>3</AspectRatioHeight>
                        </PlaylistItem>
                       
                    </Items>
                </Playlist>'/>

 

Hope it helps...

Oct 8, 2010 at 5:01 PM
Edited Oct 8, 2010 at 5:02 PM

App class method (add): 
private string GetParam(string p)    {      

if (App.Current.Resources[p] != null)        
return App.Current.Resources[p].ToString();      
else        
return string.Empty;    
}

inside Application_Startup:
if (e.InitParams != null)      {        
foreach (var item in e.InitParams)        {          
this.Resources.Add(item.Key, item.Value);        
}      
}

later on when processing initParams in Application_Startup:
... 

string rawPlaylist = GetParam("Playlist"); 
if (!rawPlaylist.IsNullOrWhiteSpace())        {          
if (rawPlaylist.Contains(';'))          {            
string[] items = rawPlaylist.Split(';');            
for (int i = 0; i < items.Length; i++)            {              
Core.Media.PlaylistItem item = new Core.Media.PlaylistItem();              
item.DeliveryMethod = DeliveryMethods.AdaptiveStreaming;              
item.Description = "[description]";              
item.MediaSource = new Uri(items[i]);              
player.Playlist.Add(item);            
}          
}          else          {            
Core.Media.PlaylistItem item = new Core.Media.PlaylistItem();            
item.DeliveryMethod = DeliveryMethods.AdaptiveStreaming;            
item.Description = "[description]";            
item.MediaSource = new Uri(rawPlaylist);            
player.Playlist.Add(item);          
}        
}

Format expected:
<param name="InitParams" value="selectedcaptionstream=textstream_eng,mediaurl=http://ecn.channel9.msdn.com/o9/content/smf/smoothcontent/elephantsdream/Elephants_Dream_1024-h264-st-aac.ism/manifest,Playlist=http://vids.server.com/ny/vts_01_1.ism/Manifest;http://vids.server.com/ny/vts_02_1.ism/Manifest">

Notes:
Although the new parameter is not consistently one-to-one with the same information for the first video (the first video also has that captionstream parameter), this is all i need for now. I if needed lots more information for each video I would consider object data binding in the silverlight app from a service data.  

Hope this helps! 

G-

Apr 6, 2011 at 7:30 PM

Is there a complete code example for this?  I have tried piecing code together but it just doesn't work.  What is the code that is used in the xaml file for example?

Thanks

Seth

Jun 29, 2013 at 2:33 PM
is there any documentation on those InitParams? e.g. what does EnablePopout do?