src/js/init.js
author hamidouk
Fri, 21 Oct 2011 17:27:04 +0200
branchpopcorn-port
changeset 123 58bb8ccea9a8
child 127 3ce493c93d6c
permissions -rw-r--r--
added a file for the init routines.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
123
58bb8ccea9a8 added a file for the init routines.
hamidouk
parents:
diff changeset
     1
/* init.js - initialization and configuration of Popcorn and the widgets
58bb8ccea9a8 added a file for the init routines.
hamidouk
parents:
diff changeset
     2
exemple json configuration:
58bb8ccea9a8 added a file for the init routines.
hamidouk
parents:
diff changeset
     3
  
58bb8ccea9a8 added a file for the init routines.
hamidouk
parents:
diff changeset
     4
  var config = {						
58bb8ccea9a8 added a file for the init routines.
hamidouk
parents:
diff changeset
     5
						gui:{
58bb8ccea9a8 added a file for the init routines.
hamidouk
parents:
diff changeset
     6
							width:650,
58bb8ccea9a8 added a file for the init routines.
hamidouk
parents:
diff changeset
     7
							height:480,							
58bb8ccea9a8 added a file for the init routines.
hamidouk
parents:
diff changeset
     8
							container:'LdtPlayer',
58bb8ccea9a8 added a file for the init routines.
hamidouk
parents:
diff changeset
     9
							css:'../../src/css/LdtPlayer.css',
58bb8ccea9a8 added a file for the init routines.
hamidouk
parents:
diff changeset
    10
              widgets: [
58bb8ccea9a8 added a file for the init routines.
hamidouk
parents:
diff changeset
    11
                {type: IriSP.PlayerWidget, // please note that type refers directly to the constructor of the widget.
58bb8ccea9a8 added a file for the init routines.
hamidouk
parents:
diff changeset
    12
                 metadata:{
58bb8ccea9a8 added a file for the init routines.
hamidouk
parents:
diff changeset
    13
                  format:'cinelab',
58bb8ccea9a8 added a file for the init routines.
hamidouk
parents:
diff changeset
    14
                  src:'test.json',
58bb8ccea9a8 added a file for the init routines.
hamidouk
parents:
diff changeset
    15
                  load:'json'}
58bb8ccea9a8 added a file for the init routines.
hamidouk
parents:
diff changeset
    16
                },
58bb8ccea9a8 added a file for the init routines.
hamidouk
parents:
diff changeset
    17
               {type: IriSP.SegmentsWidget, 
58bb8ccea9a8 added a file for the init routines.
hamidouk
parents:
diff changeset
    18
                 metadata:{
58bb8ccea9a8 added a file for the init routines.
hamidouk
parents:
diff changeset
    19
                  format:'cinelab',
58bb8ccea9a8 added a file for the init routines.
hamidouk
parents:
diff changeset
    20
                  src:'test.json',
58bb8ccea9a8 added a file for the init routines.
hamidouk
parents:
diff changeset
    21
                  load:'json'}
58bb8ccea9a8 added a file for the init routines.
hamidouk
parents:
diff changeset
    22
                },
58bb8ccea9a8 added a file for the init routines.
hamidouk
parents:
diff changeset
    23
               {type: IriSP.AnnotationsWidget, 
58bb8ccea9a8 added a file for the init routines.
hamidouk
parents:
diff changeset
    24
                 metadata:{
58bb8ccea9a8 added a file for the init routines.
hamidouk
parents:
diff changeset
    25
                  format:'cinelab',
58bb8ccea9a8 added a file for the init routines.
hamidouk
parents:
diff changeset
    26
                  src:'test.json',
58bb8ccea9a8 added a file for the init routines.
hamidouk
parents:
diff changeset
    27
                  load:'json'}
58bb8ccea9a8 added a file for the init routines.
hamidouk
parents:
diff changeset
    28
                },
58bb8ccea9a8 added a file for the init routines.
hamidouk
parents:
diff changeset
    29
              ]
58bb8ccea9a8 added a file for the init routines.
hamidouk
parents:
diff changeset
    30
						player:{
58bb8ccea9a8 added a file for the init routines.
hamidouk
parents:
diff changeset
    31
							type:'jwplayer', // player type
58bb8ccea9a8 added a file for the init routines.
hamidouk
parents:
diff changeset
    32
              
58bb8ccea9a8 added a file for the init routines.
hamidouk
parents:
diff changeset
    33
              // the rest is player-dependent configuration options.
58bb8ccea9a8 added a file for the init routines.
hamidouk
parents:
diff changeset
    34
              file : "video/franceculture/franceculture_retourdudimanche20100620.flv", 
58bb8ccea9a8 added a file for the init routines.
hamidouk
parents:
diff changeset
    35
              streamer: "rtmp://media.iri.centrepompidou.fr/ddc_player/", 
58bb8ccea9a8 added a file for the init routines.
hamidouk
parents:
diff changeset
    36
              flashplayer : '../libs/player.swf',
58bb8ccea9a8 added a file for the init routines.
hamidouk
parents:
diff changeset
    37
              live: true, 
58bb8ccea9a8 added a file for the init routines.
hamidouk
parents:
diff changeset
    38
              "controlbar.position" : "none", 
58bb8ccea9a8 added a file for the init routines.
hamidouk
parents:
diff changeset
    39
              height: 300, 
58bb8ccea9a8 added a file for the init routines.
hamidouk
parents:
diff changeset
    40
              width: 200, 
58bb8ccea9a8 added a file for the init routines.
hamidouk
parents:
diff changeset
    41
              provider: "rtmp" 
58bb8ccea9a8 added a file for the init routines.
hamidouk
parents:
diff changeset
    42
            }
58bb8ccea9a8 added a file for the init routines.
hamidouk
parents:
diff changeset
    43
	};
58bb8ccea9a8 added a file for the init routines.
hamidouk
parents:
diff changeset
    44
 */
58bb8ccea9a8 added a file for the init routines.
hamidouk
parents:
diff changeset
    45
58bb8ccea9a8 added a file for the init routines.
hamidouk
parents:
diff changeset
    46
IriSP.configurePopcorn = function (options) {
58bb8ccea9a8 added a file for the init routines.
hamidouk
parents:
diff changeset
    47
    var pop;
58bb8ccea9a8 added a file for the init routines.
hamidouk
parents:
diff changeset
    48
    
58bb8ccea9a8 added a file for the init routines.
hamidouk
parents:
diff changeset
    49
    switch(options.player.type) {
58bb8ccea9a8 added a file for the init routines.
hamidouk
parents:
diff changeset
    50
      /*
58bb8ccea9a8 added a file for the init routines.
hamidouk
parents:
diff changeset
    51
        todo : dynamically create the div/video tag which
58bb8ccea9a8 added a file for the init routines.
hamidouk
parents:
diff changeset
    52
        will contain the video.
58bb8ccea9a8 added a file for the init routines.
hamidouk
parents:
diff changeset
    53
      */
58bb8ccea9a8 added a file for the init routines.
hamidouk
parents:
diff changeset
    54
      case "html5":
58bb8ccea9a8 added a file for the init routines.
hamidouk
parents:
diff changeset
    55
           //pop = Popcorn(
58bb8ccea9a8 added a file for the init routines.
hamidouk
parents:
diff changeset
    56
        break;
58bb8ccea9a8 added a file for the init routines.
hamidouk
parents:
diff changeset
    57
    };
58bb8ccea9a8 added a file for the init routines.
hamidouk
parents:
diff changeset
    58
};
58bb8ccea9a8 added a file for the init routines.
hamidouk
parents:
diff changeset
    59
58bb8ccea9a8 added a file for the init routines.
hamidouk
parents:
diff changeset
    60
IriSP.configureWidgets = function (guiOptions) {
58bb8ccea9a8 added a file for the init routines.
hamidouk
parents:
diff changeset
    61
58bb8ccea9a8 added a file for the init routines.
hamidouk
parents:
diff changeset
    62
  var dt = new IriSP.DataLoader();
58bb8ccea9a8 added a file for the init routines.
hamidouk
parents:
diff changeset
    63
  
58bb8ccea9a8 added a file for the init routines.
hamidouk
parents:
diff changeset
    64
  var params = {width: guiOptions.width, height: guiOptions.height, 
58bb8ccea9a8 added a file for the init routines.
hamidouk
parents:
diff changeset
    65
  var lay = new LayoutManager(params);
58bb8ccea9a8 added a file for the init routines.
hamidouk
parents:
diff changeset
    66
  
58bb8ccea9a8 added a file for the init routines.
hamidouk
parents:
diff changeset
    67
  for (widget in widgets) {
58bb8ccea9a8 added a file for the init routines.
hamidouk
parents:
diff changeset
    68
    var container = lay.createDiv();
58bb8ccea9a8 added a file for the init routines.
hamidouk
parents:
diff changeset
    69
    
58bb8ccea9a8 added a file for the init routines.
hamidouk
parents:
diff changeset
    70
  };
58bb8ccea9a8 added a file for the init routines.
hamidouk
parents:
diff changeset
    71
};
58bb8ccea9a8 added a file for the init routines.
hamidouk
parents:
diff changeset
    72
58bb8ccea9a8 added a file for the init routines.
hamidouk
parents:
diff changeset
    73
IriSP.initInstance = function ( config ) {		
58bb8ccea9a8 added a file for the init routines.
hamidouk
parents:
diff changeset
    74
		if ( config === null ) {
58bb8ccea9a8 added a file for the init routines.
hamidouk
parents:
diff changeset
    75
			config = IriSP.configDefault;
58bb8ccea9a8 added a file for the init routines.
hamidouk
parents:
diff changeset
    76
		
58bb8ccea9a8 added a file for the init routines.
hamidouk
parents:
diff changeset
    77
    } else {			
58bb8ccea9a8 added a file for the init routines.
hamidouk
parents:
diff changeset
    78
		
58bb8ccea9a8 added a file for the init routines.
hamidouk
parents:
diff changeset
    79
58bb8ccea9a8 added a file for the init routines.
hamidouk
parents:
diff changeset
    80
			if (.config.player.params == null ) {
58bb8ccea9a8 added a file for the init routines.
hamidouk
parents:
diff changeset
    81
				config.player.params = IriSP.configDefault.player.params;
58bb8ccea9a8 added a file for the init routines.
hamidouk
parents:
diff changeset
    82
			}
58bb8ccea9a8 added a file for the init routines.
hamidouk
parents:
diff changeset
    83
			
58bb8ccea9a8 added a file for the init routines.
hamidouk
parents:
diff changeset
    84
			if ( config.player.flashvars == null ) {
58bb8ccea9a8 added a file for the init routines.
hamidouk
parents:
diff changeset
    85
				config.player.flashvars = IriSP.configDefault.player.flashvars;
58bb8ccea9a8 added a file for the init routines.
hamidouk
parents:
diff changeset
    86
			}
58bb8ccea9a8 added a file for the init routines.
hamidouk
parents:
diff changeset
    87
			
58bb8ccea9a8 added a file for the init routines.
hamidouk
parents:
diff changeset
    88
			if ( config.player.attributes == null ) {
58bb8ccea9a8 added a file for the init routines.
hamidouk
parents:
diff changeset
    89
				config.player.attributes = IriSP.configDefault.player.attributes;
58bb8ccea9a8 added a file for the init routines.
hamidouk
parents:
diff changeset
    90
			}
58bb8ccea9a8 added a file for the init routines.
hamidouk
parents:
diff changeset
    91
		}
58bb8ccea9a8 added a file for the init routines.
hamidouk
parents:
diff changeset
    92
		
58bb8ccea9a8 added a file for the init routines.
hamidouk
parents:
diff changeset
    93
		var metadataSrc 		 = config.metadata.src;
58bb8ccea9a8 added a file for the init routines.
hamidouk
parents:
diff changeset
    94
		var guiContainer		 = config.gui.container;
58bb8ccea9a8 added a file for the init routines.
hamidouk
parents:
diff changeset
    95
		var guiMode				 = config.gui.mode;
58bb8ccea9a8 added a file for the init routines.
hamidouk
parents:
diff changeset
    96
			
58bb8ccea9a8 added a file for the init routines.
hamidouk
parents:
diff changeset
    97
    IriSP.loadLibs(IriSP.lib, IriSP.config.gui.css, function() {
58bb8ccea9a8 added a file for the init routines.
hamidouk
parents:
diff changeset
    98
    	IriSP.createPlayerChrome();			
58bb8ccea9a8 added a file for the init routines.
hamidouk
parents:
diff changeset
    99
      /******* Load Metadata *******/
58bb8ccea9a8 added a file for the init routines.
hamidouk
parents:
diff changeset
   100
      IriSP.getMetadata();	
58bb8ccea9a8 added a file for the init routines.
hamidouk
parents:
diff changeset
   101
    });
58bb8ccea9a8 added a file for the init routines.
hamidouk
parents:
diff changeset
   102
	
58bb8ccea9a8 added a file for the init routines.
hamidouk
parents:
diff changeset
   103
    
58bb8ccea9a8 added a file for the init routines.
hamidouk
parents:
diff changeset
   104
};