Skip to content

Commit

Permalink
Release v3.0.3 stable
Browse files Browse the repository at this point in the history
  • Loading branch information
mb.jquery.components committed Jun 8, 2016
1 parent 098e6bf commit 6e69949
Show file tree
Hide file tree
Showing 9 changed files with 161 additions and 101 deletions.
4 changes: 2 additions & 2 deletions bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "jquery.mb.ytplayer",
"version": "3.0.2",
"version": "3.0.3",
"homepage": "http://pupunzi.open-lab.com/mb-jquery-components/jquery-mb-ytplayer",
"authors": [
"pupunzi <[email protected]>"
Expand All @@ -22,5 +22,5 @@
"test",
"tests"
],
"buildnum": "5960"
"buildnum": "5967"
}
2 changes: 1 addition & 1 deletion dist/css/jquery.mb.YTPlayer.min.css

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@
<meta charset="UTF-8">
<title>youtube Chromeless Player - mb.YTPlayer</title>
<link href='http://fonts.googleapis.com/css?family=Lekton|Lobster' rel='stylesheet' type='text/css'>
<link href="css/jquery.mb.YTPlayer.min.css?_bn=5796" media="all" rel="stylesheet" type="text/css">
<link href="css/jquery.mb.YTPlayer.min.css?_bn=5803" media="all" rel="stylesheet" type="text/css">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.js"></script>
<script src="jquery.mb.YTPlayer.min.js?_bn=5796"></script>
<script src="jquery.mb.YTPlayer.min.js?_bn=5803"></script>
<script src="../examples/assets/apikey.js"></script>
<style>
*:focus {
Expand Down
122 changes: 76 additions & 46 deletions dist/jquery.mb.YTPlayer.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions dist/jquery.mb.YTPlayer.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion examples/demo.html
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@

var isIframe=function(){var a=!1;try{self.location.href!=top.location.href&&(a=!0)}catch(b){a=!0}return a};if(!isIframe()){var logo=$("<a href='http://pupunzi.com/#mb.components/components.html' style='position:absolute;top:0;z-index:1000'><img id='logo' border='0' src='http://pupunzi.com/images/logo.png' alt='mb.ideas.repository'></a>");$("#wrapper").prepend(logo),$("#logo").fadeIn()}

myPlayer = jQuery("#bgndVideo").YTPlayer({align:"top,right"});
myPlayer = jQuery("#bgndVideo").YTPlayer({align:"top,center"});

myPlayer.YTPApplyFilters({
grayscale: 50,
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"player",
"custom"
],
"version": "3.0.2",
"version": "3.0.3",
"author": "Pupunzi <[email protected]> (Matteo Bicocchi)",
"maintainers": [
"Pupunzi <[email protected]> (Matteo Bicocchi)"
Expand Down Expand Up @@ -50,5 +50,5 @@
"directories": {
"example": "examples"
},
"buildnum": "5796"
"buildnum": "5803"
}
2 changes: 1 addition & 1 deletion src/dep/jquery.mb.browser.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

116 changes: 73 additions & 43 deletions src/jquery.mb.YTPlayer.src.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ var getYTPVideoID = function( url ) {
realfullscreen: true,
gaTrack: true,
optimizeDisplay: true,
align: "center,center", // top,bottom,left,right
onReady: function( player ) {}
},
/**
Expand Down Expand Up @@ -178,7 +179,8 @@ var getYTPVideoID = function( url ) {
var playlistID = this.opt.videoURL ? getYTPVideoID( this.opt.videoURL ).playlistID : $YTPlayer.attr( "href" ) ? getYTPVideoID( $YTPlayer.attr( "href" ) ).playlistID : false;
YTPlayer.videoID = videoID;
YTPlayer.playlistID = playlistID;
YTPlayer.opt.showAnnotations = ( YTPlayer.opt.showAnnotations ) ? '0' : '3';
YTPlayer.opt.showAnnotations = YTPlayer.opt.showAnnotations ? '0' : '3';

var playerVars = {
'autoplay': 0,
'modestbranding': 1,
Expand All @@ -193,24 +195,23 @@ var getYTPVideoID = function( url ) {
'wmode': 'transparent',
'iv_load_policy': YTPlayer.opt.showAnnotations
};

if( document.createElement( 'video' ).canPlayType ) jQuery.extend( playerVars, {
'html5': 1
} );
if( jQuery.browser.msie && jQuery.browser.version < 9 ) this.opt.opacity = 1;
var playerBox = jQuery( "<div/>" ).attr( "id", playerID ).addClass( "playerBox" );
var overlay = jQuery( "<div/>" ).css( {
position: "absolute",
top: 0,
left: 0,
width: "100%",
height: "100%"
} ).addClass( "YTPOverlay" );

YTPlayer.isSelf = YTPlayer.opt.containment == "self";
YTPlayer.defaultOpt.containment = YTPlayer.opt.containment = YTPlayer.opt.containment == "self" ? jQuery( this ) : jQuery( YTPlayer.opt.containment );
YTPlayer.isBackground = YTPlayer.opt.containment.get( 0 ).tagName.toLowerCase() == "body";
if( YTPlayer.isBackground && ytp.backgroundIsInited ) return;

if( YTPlayer.isBackground && ytp.backgroundIsInited )
return;

var isPlayer = YTPlayer.opt.containment.is( jQuery( this ) );

YTPlayer.canPlayOnMobile = isPlayer && jQuery( this ).children().length === 0;

if( !isPlayer ) {
$YTPlayer.hide();
} else {
Expand All @@ -222,6 +223,14 @@ var getYTPVideoID = function( url ) {
return;
}

var overlay = jQuery( "<div/>" ).css( {
position: "absolute",
top: 0,
left: 0,
width: "100%",
height: "100%"
} ).addClass( "YTPOverlay" );

var wrapper = jQuery( "<div/>" ).addClass( "mbYTP_wrapper" ).attr( "id", "wrapper_" + playerID );
wrapper.css( {
position: "absolute",
Expand All @@ -234,6 +243,7 @@ var getYTPVideoID = function( url ) {
opacity: 0
} );

var playerBox = jQuery( "<div/>" ).attr( "id", playerID ).addClass( "playerBox" );
playerBox.css( {
position: "absolute",
zIndex: 0,
Expand All @@ -243,28 +253,34 @@ var getYTPVideoID = function( url ) {
left: 0,
overflow: "hidden"
} );

wrapper.append( playerBox );

YTPlayer.opt.containment.children().not( "script, style" ).each( function() {
if( jQuery( this ).css( "position" ) == "static" ) jQuery( this ).css( "position", "relative" );
} );
if( YTPlayer.isBackground ) {
jQuery( "body" ).css( {
boxSizing: "border-box"
} );

wrapper.css( {
position: "fixed",
top: 0,
left: 0,
zIndex: 0
} );

$YTPlayer.hide();

} else if( YTPlayer.opt.containment.css( "position" ) == "static" )
YTPlayer.opt.containment.css( {
position: "relative"
} );

YTPlayer.opt.containment.prepend( wrapper );
YTPlayer.wrapper = wrapper;

playerBox.css( {
opacity: 1
} );
Expand All @@ -283,6 +299,7 @@ var getYTPVideoID = function( url ) {
YTPlayer.controlBar.removeClass( "visible" );
} );
}

if( !ytp.YTAPIReady ) {
jQuery( "#YTAPI" ).remove();
var tag = jQuery( "<script></script>" ).attr( {
Expand All @@ -306,7 +323,10 @@ var getYTPVideoID = function( url ) {
YTPlayer.opt.vol = YTPlayer.opt.vol ? YTPlayer.opt.vol : 100;
jQuery.mbYTPlayer.getDataFromAPI( YTPlayer );
jQuery( YTPlayer ).on( "YTPChanged", function() {
if( YTPlayer.isInit ) return;

if( YTPlayer.isInit )
return;

YTPlayer.isInit = true;

//if is mobile && isPlayer fallback to the default YT player
Expand All @@ -316,15 +336,15 @@ var getYTPVideoID = function( url ) {
YTPlayer.opt.containment.css( {
maxWidth: "100%"
} );
var h = YTPlayer.opt.containment.outerWidth() * .6;
var h = YTPlayer.opt.containment.outerWidth() * .563;
YTPlayer.opt.containment.css( {
maxHeight: h
} );
}
new YT.Player( playerID, {
videoId: YTPlayer.videoID.toString(),
height: '100%',
width: '100%',
height: h,
playerVars: playerVars,
events: {
'onReady': function( event ) {
Expand Down Expand Up @@ -439,12 +459,17 @@ var getYTPVideoID = function( url ) {
* @param err
*/
'onError': function( err ) {

if( err.data == 150 ) {
console.log( "Embedding this video is restricted by Youtube." );
if( YTPlayer.isPlayList ) jQuery( YTPlayer ).playNext();
}
if( err.data == 2 && YTPlayer.isPlayList ) jQuery( YTPlayer ).playNext();
if( typeof YTPlayer.opt.onError == "function" ) YTPlayer.opt.onError( $YTPlayer, err );

if( err.data == 2 && YTPlayer.isPlayList )
jQuery( YTPlayer ).playNext();

if( typeof YTPlayer.opt.onError == "function" )
YTPlayer.opt.onError( $YTPlayer, err );
}
}
} );
Expand Down Expand Up @@ -575,7 +600,6 @@ var getYTPVideoID = function( url ) {
* @param callback
* @returns {jQuery.mbYTPlayer}
*/

playlist: function( videos, shuffle, callback ) {
var $YTPlayer = this;
var YTPlayer = $YTPlayer.get( 0 );
Expand Down Expand Up @@ -921,6 +945,21 @@ var getYTPVideoID = function( url ) {
}
return this;
},
/**
*
* @returns {boolean}
*/
toggleVolume: function() {
var YTPlayer = this.get( 0 );
if( !YTPlayer ) return;
if( YTPlayer.player.isMuted() ) {
jQuery( YTPlayer ).YTPUnmute();
return true;
} else {
jQuery( YTPlayer ).YTPMute();
return false;
}
},
/**
*
* @returns {jQuery.mbYTPlayer}
Expand Down Expand Up @@ -966,6 +1005,8 @@ var getYTPVideoID = function( url ) {
return this;
},
/**
* FILTERS
*
*
* @param filter
* @param value
Expand Down Expand Up @@ -1088,12 +1129,17 @@ var getYTPVideoID = function( url ) {
} );

},

/**
*
* @returns {*}
*/
getFilters: function() {
var YTPlayer = this.get( 0 );
return YTPlayer.filters;
},
/**
* MASK
*
*
* @param mask
* @returns {jQuery.mbYTPlayer}
Expand Down Expand Up @@ -1309,8 +1355,8 @@ var getYTPVideoID = function( url ) {
},
/**
*
*
* */
* @param YTPlayer
*/
checkForState: function( YTPlayer ) {
var interval = YTPlayer.opt.showControls ? 100 : 400;
clearInterval( YTPlayer.getState );
Expand Down Expand Up @@ -1436,7 +1482,8 @@ var getYTPVideoID = function( url ) {
},
/**
*
* */
* @param YTPlayer
*/
checkForStart: function( YTPlayer ) {

var $YTPlayer = jQuery( YTPlayer );
Expand Down Expand Up @@ -1538,18 +1585,15 @@ var getYTPVideoID = function( url ) {

/* Fix for Safari freeze */
if( jQuery.browser.safari ) {
var c = 0;
YTPlayer.safariPlay = setInterval( function() {

++c;
console.debug( "YTPlayer.safariPlay_" + c, YTPlayer.state )
YTPlayer.safariPlay = setInterval( function() {

if( YTPlayer.state != 1 )
$YTPlayer.YTPPlay();
else
clearInterval( YTPlayer.safariPlay )

}, 100 )
}, 500 )
}
$YTPlayer.on( "YTPReady", function() {
$YTPlayer.YTPPlay();
Expand Down Expand Up @@ -1590,7 +1634,6 @@ var getYTPVideoID = function( url ) {

}, 1 );


},
/**
*
Expand All @@ -1603,24 +1646,11 @@ var getYTPVideoID = function( url ) {
return( min <= 9 ? "0" + min : min ) + " : " + ( sec <= 9 ? "0" + sec : sec );
}
};

/**
*
* @returns {boolean}
*/
jQuery.fn.toggleVolume = function() {
var YTPlayer = this.get( 0 );
if( !YTPlayer ) return;
if( YTPlayer.player.isMuted() ) {
jQuery( YTPlayer ).YTPUnmute();
return true;
} else {
jQuery( YTPlayer ).YTPMute();
return false;
}
};
/**
*
* @param pos can be center, top, bottom, right, left, undefined (default is center)
* @param align
* can be center, top, bottom, right, left; (default is center,center)
*/
jQuery.fn.optimizeDisplay = function( align ) {
var YTPlayer = this.get( 0 );
Expand Down Expand Up @@ -1684,7 +1714,6 @@ var getYTPVideoID = function( url ) {

}


} else {
vid.width = "100%";
vid.height = "100%";
Expand Down Expand Up @@ -1774,6 +1803,7 @@ var getYTPVideoID = function( url ) {
/**
*
* @deprecated
* todo: Above methods will be removed with version 3.5.0
*
**/
jQuery.fn.mb_YTPlayer = jQuery.mbYTPlayer.buildPlayer;
Expand Down

0 comments on commit 6e69949

Please sign in to comment.