src/js/init.js
branchpopcorn-port
changeset 453 8568e47379a2
parent 430 c0b529ae20d2
child 456 7fcdb501effd
equal deleted inserted replaced
452:35495f156c41 453:8568e47379a2
     1 /* init.js - initialization and configuration of Popcorn and the widgets
     1 /* init.js - initialization and configuration of Popcorn and the widgets
     2 exemple json configuration:
     2 exemple json configuration:
     3  
     3  
     4  */
     4  */
       
     5 
       
     6 IriSP.setupDataLoader = function() {
       
     7   /* we set it up separately because we need to
       
     8      get data at the very beginning, for instance when
       
     9      setting up the video */
       
    10   IriSP.__dataloader = new IriSP.DataLoader();
       
    11 };
     5 
    12 
     6 IriSP.configurePopcorn = function (layoutManager, options) {
    13 IriSP.configurePopcorn = function (layoutManager, options) {
     7     var pop;
    14     var pop;
     8     var ret = layoutManager.createDiv(); 
    15     var ret = layoutManager.createDiv(); 
     9     var containerDiv = ret[0];
    16     var containerDiv = ret[0];
    27         break;
    34         break;
    28         
    35         
    29       case "jwplayer":
    36       case "jwplayer":
    30           var opts = IriSP.jQuery.extend({}, options);
    37           var opts = IriSP.jQuery.extend({}, options);
    31           delete opts.container;
    38           delete opts.container;
       
    39 
       
    40           /* exit if we can't access the metadata */
       
    41           if (typeof(IriSP.__jsonMetadata) === "undefined") {
       
    42               break;
       
    43           };
       
    44 
       
    45 
       
    46           // the json format is totally illogical
       
    47           opts.streamer = IriSP.__jsonMetadata["medias"][0]["meta"]["item"]["value"];
       
    48           var source = IriSP.__jsonMetadata["medias"][0]["href"];
       
    49 
       
    50           // the source if a full url but jwplayer wants an url relative to the
       
    51           // streamer url, so we've got to remove the common part.
       
    52           opts.file = source.slice(opts.streamer.length);
    32           pop = IriSP.PopcornReplacement.jwplayer("#" + containerDiv, opts);
    53           pop = IriSP.PopcornReplacement.jwplayer("#" + containerDiv, opts);
    33         break;
    54         break;
    34       
    55       
    35       case "youtube":
    56       case "youtube":
    36           var opts = IriSP.jQuery.extend({}, options);
    57           var opts = IriSP.jQuery.extend({}, options);
    51     
    72     
    52     return pop;
    73     return pop;
    53 };
    74 };
    54 
    75 
    55 IriSP.configureWidgets = function (popcornInstance, layoutManager, guiOptions) {
    76 IriSP.configureWidgets = function (popcornInstance, layoutManager, guiOptions) {
    56 
    77  
    57   var dt = new IriSP.DataLoader();
    78   var serialFactory = new IriSP.SerializerFactory(IriSP.__dataloader);
    58   var serialFactory = new IriSP.SerializerFactory(dt);
       
    59   
       
    60   var params = {width: guiOptions.width, height: guiOptions.height};
    79   var params = {width: guiOptions.width, height: guiOptions.height};
    61 
    80 
    62   var ret_widgets = [];
    81   var ret_widgets = [];
    63   var index;
    82   var index;
    64   
    83