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