Skip to content

Commit

Permalink
YTAPIReady is triggered also on mobile
Browse files Browse the repository at this point in the history
  • Loading branch information
mb.jquery.components committed Jun 17, 2016
1 parent f10a7d0 commit 944032f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
11 changes: 6 additions & 5 deletions dist/jquery.mb.YTPlayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -219,11 +219,6 @@ var getYTPVideoID = function( url ) {
YTPlayer.isPlayer = true;
}

if( jQuery.browser.mobile && !YTPlayer.canPlayOnMobile ) {
$YTPlayer.remove();
return;
}

var overlay = jQuery( "<div/>" ).css( {
position: "absolute",
top: 0,
Expand Down Expand Up @@ -320,6 +315,11 @@ var getYTPVideoID = function( url ) {
}, 100 )
}

if( jQuery.browser.mobile && !YTPlayer.canPlayOnMobile ) {
$YTPlayer.remove();
return;
}

jQuery( document ).on( "YTAPIReady", function() {
if( ( YTPlayer.isBackground && ytp.backgroundIsInited ) || YTPlayer.isInit ) return;
if( YTPlayer.isBackground ) {
Expand All @@ -336,6 +336,7 @@ var getYTPVideoID = function( url ) {

YTPlayer.isInit = true;


//if is mobile && isPlayer fallback to the default YT player
if( jQuery.browser.mobile && YTPlayer.canPlayOnMobile ) {
// Try to adjust the player dimention
Expand Down
10 changes: 5 additions & 5 deletions src/jquery.mb.YTPlayer.src.js
Original file line number Diff line number Diff line change
Expand Up @@ -219,11 +219,6 @@ var getYTPVideoID = function( url ) {
YTPlayer.isPlayer = true;
}

if( jQuery.browser.mobile && !YTPlayer.canPlayOnMobile ) {
$YTPlayer.remove();
return;
}

var overlay = jQuery( "<div/>" ).css( {
position: "absolute",
top: 0,
Expand Down Expand Up @@ -320,6 +315,11 @@ var getYTPVideoID = function( url ) {
}, 100 )
}

if( jQuery.browser.mobile && !YTPlayer.canPlayOnMobile ) {
$YTPlayer.remove();
return;
}

jQuery( document ).on( "YTAPIReady", function() {
if( ( YTPlayer.isBackground && ytp.backgroundIsInited ) || YTPlayer.isInit ) return;
if( YTPlayer.isBackground ) {
Expand Down

0 comments on commit 944032f

Please sign in to comment.