Control SMFPlayer in Javascript

Jul 13, 2010 at 8:43 AM
Hi, I'm newly trying to control SMFPlayer throw Javascript but I have the following problem with Playlist: (Player is the Javascript reference to the <object />) var playList = Player.CreatePlaylist(); Player.SetPlaylist(playList); doesn't work, throw ArgumentNullException Player.SetPlaylist(Player.CreatePlaylist()); works! It's like Silverlight garbage collect my reference to the playlist in the first csae. How can i do? Thanks. Ghislain
Coordinator
Jul 13, 2010 at 4:42 PM

Ghis, I recommend downloading the source code and running the Samples project.  There is an example demonstrating how to use the JavaScript API.  Here's a snippet for JS from one of those examples:

var slCtl = null;


        function pluginLoaded(sender, args) { 
            slCtl = sender.getHost().Content;
        }  



       function createNewPlaylistItem() {
            var NewPlaylistItem = slCtl.Player.CreatePlaylistItem('http://streams.smooth.vertigo.com/elephantsdream/Elephants_Dream_1024-h264-st-aac.ism/manifest', '', 'Title', 'Description');
            NewPlaylistItem.DeliveryMethod = 'AdaptiveStreaming';
            var NewPlaylist = slCtl.Player.CreatePlaylist();
            NewPlaylist.AddPlaylistItem(NewPlaylistItem);
            slCtl.Player.SetPlaylist(NewPlaylist);
        }

Jul 15, 2010 at 6:47 AM
Edited Jul 15, 2010 at 7:07 AM

Ouups!!! Sorry I could have seen this by myself! The non obvious point is that 'DeliveryMethod' is required.

Is samples there is for me a little mistake in player.html (subfolders JavascriptVCRHtmlResources and JavascriptPlaylistHtmlResources), the Silverlight.js file path is in the same folder, or it requires '../../Silverlight.js' .

 

Other questions:

- how can i extend JavascriptBridge? I need to get the current play time or have a handler called each 10ms value (which may be set)?

- Perhaps this is an improvement, but it would be better to give the onPlayerReady handler rather than fixing it in JavascriptBridge.

 

Thanks.

Ghislain

Coordinator
Jul 15, 2010 at 4:26 PM

Hey Ghis, that reference to Silverlight.js should have been pulled out of the HTML files.  You can safely ignore it or just remove the <script/> tag.

To extend the JavaScript bridge you'll need to modify the source and create your own SMF build, there is no plugin or extensibility point for this component.  Finally, I'm not sure what you mean by your last statement: "Perhaps this is an improvement, but it would be better to give the onPlayerReady handler rather than fixing it in JavascriptBridge."  Can you explain this one?

 

Jul 16, 2010 at 6:29 AM
krohling wrote:

Hey Ghis, that reference to Silverlight.js should have been pulled out of the HTML files.  You can safely ignore it or just remove the <script/> tag.

That was just a remark for the team, not a problem for me. :-)

To extend the JavaScript bridge you'll need to modify the source and create your own SMF build, there is no plugin or extensibility point for this component. 

Ok. I've tryed to extend SMFPlayer ( and rewrite some methods ) and JavaScriptBridge... but my new methods in JavascriptBridge were not visibles in Javascript... and I can't explain why.

Finally, I'm not sure what you mean by your last statement: "Perhaps this is an improvement, but it would be better to give the onPlayerReady handler rather than fixing it in JavascriptBridge."  Can you explain this one?

That was just an idea, adding the possibility to specify name of the Javascript method to call in InitParams in case of multiple SMPlayer instances in the same page.

Coordinator
Jul 21, 2010 at 8:32 PM

Ghis, the next release will have properties on the JavaScriptBridget for getting the current/start/end positions.