diff -r 1f90756342e2 -r becd5f52fa24 src/js/init.js --- a/src/js/init.js Tue Oct 25 14:32:23 2011 +0200 +++ b/src/js/init.js Tue Oct 25 14:33:18 2011 +0200 @@ -1,46 +1,6 @@ /* init.js - initialization and configuration of Popcorn and the widgets exemple json configuration: - - var config = { - gui:{ - width:650, - height:480, - container:'LdtPlayer', - css:'../../src/css/LdtPlayer.css', - widgets: [ - {type: "IriSP.PlayerWidget", // please note that type refers directly to the constructor of the widget. - metadata:{ - format:'cinelab', - src:'test.json', - load:'json'} - }, - {type: "IriSP.SegmentsWidget", - metadata:{ - format:'cinelab', - src:'test.json', - load:'json'} - }, - {type: "IriSP.AnnotationsWidget", - metadata:{ - format:'cinelab', - src:'test.json', - load:'json'} - }, - ] - player:{ - type:'jwplayer', // player type - container: '#PopcornContainer' - // the rest is player-dependent configuration options. - file : "video/franceculture/franceculture_retourdudimanche20100620.flv", - streamer: "rtmp://media.iri.centrepompidou.fr/ddc_player/", - flashplayer : '../libs/player.swf', - live: true, - "controlbar.position" : "none", - height: 300, - width: 200, - provider: "rtmp" - } - }; + */ IriSP.configurePopcorn = function (options) { @@ -52,13 +12,13 @@ will contain the video. */ case "html5": - pop = Popcorn(options.container); + pop = Popcorn("#" + options.container); break; case "jwplayer": var opts = IriSP.jQuery.extend({}, options); delete opts.container; - pop = Popcorn.jwplayer(options.container, "", opts); + pop = Popcorn.jwplayer("#" + options.container, "", opts); break; default: @@ -78,21 +38,24 @@ lay.setPopcornInstance(popcornInstance); var ret_widgets = []; + var index; - for (index in guiOptions.widgets) { + for (index = 0; index < guiOptions.widgets.length; index++) { var widget = guiOptions.widgets[index]; var container = lay.createDiv(); var arr = IriSP.jQuery.extend({}, widget); arr.container = container; - + var serializer = serialFactory.getSerializer(widget.metadata); - + // instantiate the object passed as a string - var widget = new IriSP[widget.type](popcornInstance, arr, serializer); - serializer.sync(function() { widget.draw() }); + var widget = new IriSP[widget.type](popcornInstance, arr, serializer); + + serializer.sync(IriSP.wrap(widget, function() { this.draw(); })); ret_widgets.push(widget); + }; - + return ret_widgets; }; \ No newline at end of file