src/js/init.js
branchpopcorn-port
changeset 127 3ce493c93d6c
parent 123 58bb8ccea9a8
child 129 296d9ddf9cc1
equal deleted inserted replaced
126:e007a7ad66b8 127:3ce493c93d6c
     6 							width:650,
     6 							width:650,
     7 							height:480,							
     7 							height:480,							
     8 							container:'LdtPlayer',
     8 							container:'LdtPlayer',
     9 							css:'../../src/css/LdtPlayer.css',
     9 							css:'../../src/css/LdtPlayer.css',
    10               widgets: [
    10               widgets: [
    11                 {type: IriSP.PlayerWidget, // please note that type refers directly to the constructor of the widget.
    11                 {type: "IriSP.PlayerWidget", // please note that type refers directly to the constructor of the widget.
    12                  metadata:{
    12                  metadata:{
    13                   format:'cinelab',
    13                   format:'cinelab',
    14                   src:'test.json',
    14                   src:'test.json',
    15                   load:'json'}
    15                   load:'json'}
    16                 },
    16                 },
    17                {type: IriSP.SegmentsWidget, 
    17                {type: "IriSP.SegmentsWidget", 
    18                  metadata:{
    18                  metadata:{
    19                   format:'cinelab',
    19                   format:'cinelab',
    20                   src:'test.json',
    20                   src:'test.json',
    21                   load:'json'}
    21                   load:'json'}
    22                 },
    22                 },
    23                {type: IriSP.AnnotationsWidget, 
    23                {type: "IriSP.AnnotationsWidget",                
    24                  metadata:{
    24                  metadata:{
    25                   format:'cinelab',
    25                   format:'cinelab',
    26                   src:'test.json',
    26                   src:'test.json',
    27                   load:'json'}
    27                   load:'json'}
    28                 },
    28                 },
    29               ]
    29               ]
    30 						player:{
    30 						player:{
    31 							type:'jwplayer', // player type
    31 							type:'jwplayer', // player type
    32               
    32               container: '#PopcornContainer'
    33               // the rest is player-dependent configuration options.
    33               // the rest is player-dependent configuration options.
    34               file : "video/franceculture/franceculture_retourdudimanche20100620.flv", 
    34               file : "video/franceculture/franceculture_retourdudimanche20100620.flv", 
    35               streamer: "rtmp://media.iri.centrepompidou.fr/ddc_player/", 
    35               streamer: "rtmp://media.iri.centrepompidou.fr/ddc_player/", 
    36               flashplayer : '../libs/player.swf',
    36               flashplayer : '../libs/player.swf',
    37               live: true, 
    37               live: true, 
    44  */
    44  */
    45 
    45 
    46 IriSP.configurePopcorn = function (options) {
    46 IriSP.configurePopcorn = function (options) {
    47     var pop;
    47     var pop;
    48     
    48     
    49     switch(options.player.type) {
    49     switch(options.type) {
    50       /*
    50       /*
    51         todo : dynamically create the div/video tag which
    51         todo : dynamically create the div/video tag which
    52         will contain the video.
    52         will contain the video.
    53       */
    53       */
    54       case "html5":
    54       case "html5":
    55            //pop = Popcorn(
    55            pop = Popcorn(options.container);
    56         break;
    56         break;
       
    57         
       
    58       case "jwplayer":
       
    59           var opts = IriSP.jQuery.extend({}, options);
       
    60           delete opts.container;
       
    61           pop = Popcorn.jwplayer(options.container, "", opts);
       
    62         break;
       
    63         
       
    64       default:
       
    65         pop = undefined;
    57     };
    66     };
       
    67     
       
    68     return pop;
    58 };
    69 };
    59 
    70 
    60 IriSP.configureWidgets = function (guiOptions) {
    71 IriSP.configureWidgets = function (popcornInstance, guiOptions) {
    61 
    72 
    62   var dt = new IriSP.DataLoader();
    73   var dt = new IriSP.DataLoader();
       
    74   var serialFactory = new IriSP.SerializerFactory(dt);
    63   
    75   
    64   var params = {width: guiOptions.width, height: guiOptions.height, 
    76   var params = {width: guiOptions.width, height: guiOptions.height};
    65   var lay = new LayoutManager(params);
    77   var lay = new IriSP.LayoutManager(params);
    66   
    78   
    67   for (widget in widgets) {
    79   var ret_widgets = [];
       
    80   
       
    81   for (index in guiOptions.widgets) {    
       
    82     var widget = guiOptions.widgets[index];
    68     var container = lay.createDiv();
    83     var container = lay.createDiv();
       
    84         
       
    85     var arr = IriSP.jQuery.extend({}, widget);
       
    86     arr.container = container;
    69     
    87     
       
    88     var serializer = serialFactory.getSerializer(widget.metadata);
       
    89 
       
    90     // instantiate the object passed as a string
       
    91     var widget = new IriSP[widget.type](popcornInstance, widget, serializer);    
       
    92     serializer.sync(function() { widget.draw() });
       
    93     ret_widgets.push(widget);
    70   };
    94   };
       
    95   
       
    96   return ret_widgets;
    71 };
    97 };
    72 
       
    73 IriSP.initInstance = function ( config ) {		
       
    74 		if ( config === null ) {
       
    75 			config = IriSP.configDefault;
       
    76 		
       
    77     } else {			
       
    78 		
       
    79 
       
    80 			if (.config.player.params == null ) {
       
    81 				config.player.params = IriSP.configDefault.player.params;
       
    82 			}
       
    83 			
       
    84 			if ( config.player.flashvars == null ) {
       
    85 				config.player.flashvars = IriSP.configDefault.player.flashvars;
       
    86 			}
       
    87 			
       
    88 			if ( config.player.attributes == null ) {
       
    89 				config.player.attributes = IriSP.configDefault.player.attributes;
       
    90 			}
       
    91 		}
       
    92 		
       
    93 		var metadataSrc 		 = config.metadata.src;
       
    94 		var guiContainer		 = config.gui.container;
       
    95 		var guiMode				 = config.gui.mode;
       
    96 			
       
    97     IriSP.loadLibs(IriSP.lib, IriSP.config.gui.css, function() {
       
    98     	IriSP.createPlayerChrome();			
       
    99       /******* Load Metadata *******/
       
   100       IriSP.getMetadata();	
       
   101     });
       
   102 	
       
   103     
       
   104 };