Permalink
Browse files

better video display optimization

  • Loading branch information...
1 parent 8d67eb3 commit d8053f863f20577bc6ca1eebc89863a263b294c8 @pupunzi committed Apr 14, 2012
Showing with 22 additions and 21 deletions.
  1. +1 −1 demo_background.html
  2. +21 −20 inc/jquery.mb.YTPlayer.js
View
@@ -95,7 +95,7 @@
<div class="console">
<button class="command" onclick="$('#bgndVideo').get(0).playVideo()"> play </button>
<button class="command" onclick="$('#bgndVideo').get(0).pauseVideo()"> pause </button>
- <button class="command" onclick="$('#bgndVideo').changeVolume(100)"> switch volume </button>
+ <button class="command" onclick="$('#bgndVideo').setYTPVolume(100)"> switch volume </button>
<button class="command" onclick="alert($('#bgndVideo').get(0).getPlayerState())"> get State </button>
<br>
<br>
View
@@ -43,7 +43,6 @@
var dataObj=$("<span/>");
dataObj.attr("id",ID+"_data").hide();
-// var data= dataObj.get(0);
var data= dataObj.data();
data.opacity=1;
@@ -186,6 +185,7 @@
player.addEventListener("onStateChange", '(function(state) { return playerState(state, "' + player.id + '"); })');
},
+
changeMovie:function(url, opt){
var player = $(this).get(0);
@@ -204,45 +204,58 @@
$(player).optimizeDisplay();
},
+
getPlayer:function(){
return this.get(0);
},
+
playYTP: function(){
var player= $(this).get(0);
var playBtn=$(player).parent().find(".mb_YTVPPlaypause");
playBtn.html($.mbYTPlayer.controls.pause);
player.playVideo();
},
+
stopYTP:function(){
var player= $(this).get(0);
var playBtn=$(player).parent().find(".mb_YTVPPlaypause");
playBtn.html($.mbYTPlayer.controls.play);
player.pauseVideo();
},
+
pauseYTP:function(){
var player= $(this).get(0);
var playBtn=$(player).parent().find(".mb_YTVPPlaypause");
playBtn.html($.mbYTPlayer.controls.play);
player.pauseVideo();
},
- // todo
+
setYTPVolume:function(val){
- var player= $(this).get(0);
- var VolumeBtn=$(player).parent().find(".mb_YTVPVolume");
- player.setVolume(val);
+ var player = $(this).get(0);
+ var data = $("#"+player.id+"_data").data();
+ if(!val && !data.vol && player.getVolume()==0)
+ data.vol=100;
+ else if((!val && player.getVolume()>0) || (val && player.getVolume()==val))
+ data.vol=0;
+ else
+ data.vol=val;
+ player.setVolume(data.vol);
},
+
muteYTPVolume:function(){
var player= $(this).get(0);
var muteBtn=$(player).parent().find(".mb_YTVPMuteUnmute");
muteBtn.html($.mbYTPlayer.controls.unmute);
player.mute();
},
+
unmuteYTPVolume:function(){
var player= $(this).get(0);
var muteBtn=$(player).parent().find(".mb_YTVPMuteUnmute");
muteBtn.html($.mbYTPlayer.controls.mute);
player.unMute();
},
+
manageYTPProgress:function(){
var player= $(this).get(0);
var YTPlayer= $(player).parent();
@@ -268,6 +281,7 @@
timeBar.css({left:0,width:timeW});
return {totalTime:totalTime,currentTime: currentTime};
},
+
buildYTPControls:function(){
var player= $(this).get(0);
var data = $("#"+player.id+"_data").data();
@@ -304,7 +318,6 @@
var loadedBar = $("<div/>").addClass("mb_YTVPLoaded").css("position","absolute");
var timeBar = $("<div/>").addClass("mb_YTVTime").css("position","absolute");
-
progressBar.append(loadedBar).append(timeBar);
buttonBar.append(playpause).append(MuteUnmute).append(idx);
controlBar.append(buttonBar).append(progressBar);
@@ -335,6 +348,7 @@
},500);
}
},
+
formatTime: function(s){
var min= Math.floor(s/60);
var sec= Math.floor(s-(60*min));
@@ -353,21 +367,9 @@
$.fn.pauseYTP = $.mbYTPlayer.pauseYTP;
$.fn.muteYTPVolume = $.mbYTPlayer.muteYTPVolume;
$.fn.unmuteYTPVolume = $.mbYTPlayer.unmuteYTPVolume;
+ $.fn.setYTPVolume = $.mbYTPlayer.setYTPVolume;
$.fn.manageYTPProgress = $.mbYTPlayer.manageYTPProgress;
-
- $.fn.changeVolume=function(val){
- var player = $(this).get(0);
- var data = $("#"+player.id+"_data").data();
- if(!val && !data.vol && player.getVolume()==0)
- data.vol=100;
- else if((!val && player.getVolume()>0) || (val && player.getVolume()==val))
- data.vol=0;
- else
- data.vol=val;
- player.setVolume(data.vol);
- };
-
})(jQuery);
function onYouTubePlayerReady(playerId) {
@@ -447,7 +449,6 @@ $.fn.optimizeDisplay=function(){
var marginTop= -((vid.height-win.height)/2);
var marginLeft= 0 ;
-
if(vid.height<win.height){
vid.width= data.ratio=="16/9" ? Math.ceil((16*win.height)/9): Math.ceil((4*win.height)/3);
vid.height = win.height;

0 comments on commit d8053f8

Please sign in to comment.