src/js/widgets/playerWidget.js
author hamidouk
Wed, 19 Oct 2011 15:00:34 +0200
branchpopcorn-port
changeset 98 ed4ac18baf07
child 109 be17a396d68b
permissions -rw-r--r--
broke the widgets.js in multiple files.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
98
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
     1
IriSP.PlayerWidget.prototype = new IriSP.Widget;
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
     2
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
     3
IriSP.PlayerWidget.prototype.draw = function() {
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
     4
  var _this = this;
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
     5
  var width = this._config.gui.width;
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
     6
	var height = this._config.gui.height;
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
     7
	var heightS = this._config.gui.height-20;
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
     8
		
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
     9
	if( this._config.gui.mode=="radio" ){
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
    10
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
    11
		//IriSP.jQuery( "#"+this._config.gui.container ).before(IriSP.search_template);
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
    12
		var radioPlayer = Mustache.to_html(IriSP.radio_template, {"share_template" : IriSP.share_template});    
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
    13
		IriSP.jQuery(radioPlayer).appendTo("#"+this._config.gui.container);
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
    14
    
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
    15
		// special tricks for IE 7
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
    16
		if (IriSP.jQuery.browser.msie==true && IriSP.jQuery.browser.version=="7.0"){
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
    17
			//LdtSearchContainer
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
    18
			//__IriSP.jQuery("#LdtPlayer").attr("margin-top","50px");
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
    19
			IriSP.jQuery("#Ldt-Root").css("padding-top","25px");			
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
    20
		}
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
    21
	} else if(this._config.gui.mode=="video") {
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
    22
	
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
    23
		var videoPlayer = Mustache.to_html(IriSP.video_template, {"share_template" : IriSP.share_template, "heightS" : heightS});
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
    24
		IriSP.jQuery(videoPlayer).appendTo("#"+this._config.gui.container);
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
    25
	}
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
    26
	
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
    27
	IriSP.jQuery("#Ldt-Annotations").width(width-(75*2));
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
    28
	IriSP.jQuery("#Ldt-Show-Arrow-container").width(width-(75*2));
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
    29
	IriSP.jQuery("#Ldt-ShowAnnotation-audio").width(width-10);
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
    30
	IriSP.jQuery("#Ldt-ShowAnnotation-video").width(width-10);
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
    31
	IriSP.jQuery("#Ldt-SaKeyword").width(width-10);
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
    32
	IriSP.jQuery("#Ldt-controler").width(width-10);
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
    33
	IriSP.jQuery("#Ldt-Control").attr("z-index","100");
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
    34
	IriSP.jQuery("#Ldt-controler").hide();
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
    35
	
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
    36
	IriSP.jQuery(IriSP.annotation_loading_template).appendTo("#Ldt-ShowAnnotation-audio");
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
    37
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
    38
	if(this._config.gui.mode=='radio'){
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
    39
		IriSP.jQuery("#Ldt-load-container").attr("width",this._config.gui.width);
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
    40
	}
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
    41
	  		
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
    42
  IriSP.jQuery( "#Ldt-controler" ).show();
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
    43
  //__IriSP.jQuery("#Ldt-Root").css('display','visible');
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
    44
  IriSP.jQuery( "#Ldt-ShowAnnotation").click( function () { 
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
    45
     //__IriSP.jQuery(this).slideUp(); 
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
    46
  } );
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
    47
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
    48
  var LdtpPlayerY = IriSP.jQuery("#Ldt-PlaceHolder").attr("top");
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
    49
  var LdtpPlayerX = IriSP.jQuery("#Ldt-PlaceHolder").attr("left");
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
    50
  
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
    51
  IriSP.jQuery( "#slider-range-min" ).slider( { //range: "min",
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
    52
    value: 0,
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
    53
    min: 1,
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
    54
    max: this._serializer.currentMedia().meta["dc:duration"]/1000,//1:54:52.66 = 3600+3240+
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
    55
    step: 0.1,
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
    56
    slide: function(event, ui) {     
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
    57
      _this._Popcorn.currentTime(ui.value);
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
    58
    },
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
    59
    /* change event is similar to slide, but it happens when the slider position is 
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
    60
       modified programatically. We use it for unit tests */
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
    61
    /*   
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
    62
    change: function(event, ui) {     
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
    63
      _this._Popcorn.currentTime(ui.value);
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
    64
    }
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
    65
    */
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
    66
  } );
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
    67
  
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
    68
  IriSP.jQuery("#amount").val(IriSP.jQuery("#slider-range-min").slider("value")+" s");
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
    69
  IriSP.jQuery(".Ldt-Control1 button:first").button({
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
    70
    icons: {
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
    71
      primary: 'ui-icon-play'
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
    72
    },
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
    73
    text: false
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
    74
  }).click(function() { _this.playHandler.call(_this); })
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
    75
    .next().button({
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
    76
    icons: {
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
    77
      primary: 'ui-icon-seek-next'
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
    78
    },
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
    79
     text: false
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
    80
  });
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
    81
  IriSP.jQuery(".Ldt-Control2 button:first").button({
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
    82
    icons: {
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
    83
      primary: 'ui-icon-search'//,
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
    84
      //secondary: 'ui-icon-volume-off'
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
    85
    },
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
    86
    text: false
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
    87
  }).next().button({
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
    88
    icons: {
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
    89
      primary: 'ui-icon-volume-on'
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
    90
    },
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
    91
     text: false
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
    92
  }).click(function() { _this.muteHandler.call(_this); } );
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
    93
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
    94
  // /!\ PB A MODIFIER 
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
    95
  //__IriSP.MyTags.draw();
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
    96
  IriSP.jQuery( "#ldt-CtrlPlay" ).attr( "style", "background-color:#CD21C24;" );
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
    97
  
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
    98
  IriSP.jQuery( "#Ldt-load-container" ).hide();
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
    99
  
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
   100
  if( this._config.gui.mode=="radio" & IriSP.jQuery.browser.msie != true ) {
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
   101
    IriSP.jQuery( "#Ldtplayer1" ).attr( "height", "0" );
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
   102
  }
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
   103
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
   104
  this._Popcorn.listen("timeupdate", IriSP.wrap(this, this.sliderUpdater));
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
   105
};
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
   106
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
   107
IriSP.PlayerWidget.prototype.playHandler = function() {
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
   108
  var status = this._Popcorn.media.paused;
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
   109
  
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
   110
  if ( status == true ){        
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
   111
    this._Popcorn.play();
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
   112
    IriSP.jQuery( ".ui-icon-play" ).css( "background-position", "-16px -160px" );
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
   113
    IriSP.jQuery( "#ldt-CtrlPlay" ).attr("title", "Play");
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
   114
  } else {
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
   115
    this._Popcorn.pause();
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
   116
    IriSP.jQuery( ".ui-icon-play" ).css( "background-position","0px -160px" );
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
   117
    IriSP.jQuery( "#ldt-CtrlPlay" ).attr("title", "Pause");
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
   118
  }  
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
   119
};
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
   120
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
   121
IriSP.PlayerWidget.prototype.muteHandler = function() {
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
   122
  if (!this._Popcorn.muted()) {    
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
   123
      this._Popcorn.mute(true);
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
   124
      IriSP.jQuery(" .ui-icon-volume-on ").css("background-position", "-130px -160px");    
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
   125
    } else {
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
   126
      this._Popcorn.mute(false);
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
   127
      IriSP.jQuery( ".ui-icon-volume-on" ).css("background-position", "-144px -160px" );
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
   128
    }
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
   129
};
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
   130
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
   131
IriSP.PlayerWidget.prototype.sliderUpdater = function() {  
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
   132
  var currentPosition = this._Popcorn.currentTime();   
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
   133
	IriSP.jQuery( "#slider-range-min" ).slider( "value", currentPosition);		
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
   134
};
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
   135