src/js/init.js
branchpopcorn-port
changeset 531 e7f27746668e
parent 500 a784e70993b3
child 539 3ba5b82aebb6
equal deleted inserted replaced
530:3cc4a789dae7 531:e7f27746668e
     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 
     5 
       
     6 /**
       
     7     set up the IriSP.__dataloader instance - 
       
     8     we need it because we have to get the metadata
       
     9     about the video before that the widget have even
       
    10     loaded.
       
    11 */
     6 IriSP.setupDataLoader = function() {
    12 IriSP.setupDataLoader = function() {
     7   /* we set it up separately because we need to
    13   /* we set it up separately because we need to
     8      get data at the very beginning, for instance when
    14      get data at the very beginning, for instance when
     9      setting up the video */
    15      setting up the video */
    10   IriSP.__dataloader = new IriSP.DataLoader();
    16   IriSP.__dataloader = new IriSP.DataLoader();
    11 };
    17 };
    12 
    18 
       
    19 /** do some magic to configure popcorn according to the options object passed.
       
    20     Works for html5, jwplayer and youtube videos 
       
    21 */
    13 IriSP.configurePopcorn = function (layoutManager, options) {
    22 IriSP.configurePopcorn = function (layoutManager, options) {
    14     var pop;
    23     var pop;
    15     var ret = layoutManager.createDiv(); 
    24     var ret = layoutManager.createDiv(); 
    16     var containerDiv = ret[0];
    25     var containerDiv = ret[0];
    17     
    26     
    77     };
    86     };
    78     
    87     
    79     return pop;
    88     return pop;
    80 };
    89 };
    81 
    90 
       
    91 /** Configure the gui and instantiate the widgets passed as parameters
       
    92     @param guiOptions the gui object as seen in the examples.
       
    93  */
    82 IriSP.configureWidgets = function (popcornInstance, layoutManager, guiOptions) {
    94 IriSP.configureWidgets = function (popcornInstance, layoutManager, guiOptions) {
    83  
    95  
    84   var serialFactory = new IriSP.SerializerFactory(IriSP.__dataloader);
    96   var serialFactory = new IriSP.SerializerFactory(IriSP.__dataloader);
    85   var params = {width: guiOptions.width, height: guiOptions.height};
    97   var params = {width: guiOptions.width, height: guiOptions.height};
    86 
    98 
    95   };
   107   };
    96 
   108 
    97   return ret_widgets;
   109   return ret_widgets;
    98 };
   110 };
    99 
   111 
       
   112 /** configure modules. @see configureWidgets */
   100 IriSP.configureModules = function (popcornInstance, modulesList) {
   113 IriSP.configureModules = function (popcornInstance, modulesList) {
   101  
   114  
   102   var serialFactory = new IriSP.SerializerFactory(IriSP.__dataloader);
   115   var serialFactory = new IriSP.SerializerFactory(IriSP.__dataloader);
   103   var ret_modules = [];
   116   var ret_modules = [];
   104   var index;
   117   var index;
   112   };
   125   };
   113 
   126 
   114   return ret_modules;
   127   return ret_modules;
   115 };
   128 };
   116 
   129 
       
   130 /** instantiate a widget - only called by configureWidgets, never by the user. Handles widget 
       
   131     dependencies.
       
   132     @param popcornInstance popcorn instance the widget will user
       
   133     @param serialFactory serializer factory to instantiate the widget with
       
   134     @param layoutManager layout manager
       
   135     @param widgetConfig configuration options for the widget
       
   136  */
   117 IriSP.instantiateWidget = function(popcornInstance, serialFactory, layoutManager, widgetConfig) {
   137 IriSP.instantiateWidget = function(popcornInstance, serialFactory, layoutManager, widgetConfig) {
   118     /* create div returns us a container for the widget and a spacer */
   138     /* create div returns us a container for the widget and a spacer */
   119     var ret = layoutManager.createDiv(widgetConfig.type);        
   139     var ret = layoutManager.createDiv(widgetConfig.type);        
   120     var container = ret[0];
   140     var container = ret[0];
   121     var spacer = ret[1];
   141     var spacer = ret[1];