vendor/assets/javascripts/webshims/shims/combos/99.js in webshims-rails-1.14.5 vs vendor/assets/javascripts/webshims/shims/combos/99.js in webshims-rails-1.14.6
- old
+ new
@@ -471,11 +471,13 @@
}
return cache[template] || '';
};
})();
- var ios6 = /iP(hone|od|ad)/i.test(navigator.platform) && parseInt(((navigator.appVersion).match(/OS (\d+)_\d+/) || ['','8'])[1], 10) < 7;
+ var ios = /iP(hone|od|ad)/i.test(navigator.platform);
+ var ios6 = ios && parseInt(((navigator.appVersion).match(/OS (\d+)_\d+/) || ['','8'])[1], 10) < 7;
+ var hasYtBug = (!window.Modernizr || !Modernizr.videoautoplay) && (ios || /android/i.test(navigator.userAgent));
var loadLazy = function(){
if(!loadLazy.loaded){
loadLazy.loaded = true;
webshims.loader.loadList(['mediacontrols-lazy', 'range-ui']);
}
@@ -498,11 +500,12 @@
};
return rfn;
};
webshims.loader.addModule('mediacontrols-lazy', {
- src: 'jme/mediacontrols-lazy'
+ src: 'jme/mediacontrols-lazy',
+ d: ['dom-support']
});
var userActivity = {
_create: lazyLoadPlugin()
};
@@ -521,10 +524,15 @@
} else {
if(ios6){
data.media.removeAttr('controls');
data.media.mediaLoad();
}
+
+ if(hasYtBug){
+ data.player.addClass('has-yt-bug');
+ }
+
data.media.prop('controls', false);
structure = getBarHtml();
data._controlbar = $( options.barStructure );
controlBar = data._controlbar.find('div.jme-cb-box').addClass('media-controls');
controls = data._controlbar.filter('.jme-media-overlay');
@@ -567,11 +575,11 @@
}
};
})();
var $poster = $('<div class="ws-poster" />').insertAfter(data.media);
var posterState = (function(){
- var lastPosterState, lastYoutubeState, lastPoster;
+ var lastPosterState, lastYoutubeState, lastPoster, isYt;
var hasFlash = window.swfmini && swfmini.hasFlashPlayerVersion('10.0.3');
var regYt = /youtube\.com\/[watch\?|v\/]+/i;
var isInitial = data.media.prop('paused');
var isEnded = data.media.prop('ended');
@@ -583,12 +591,14 @@
}
if(!('backgroundSize' in $poster[0].style)){
data.player.addClass('no-backgroundsize');
}
data.media.on('play playing waiting seeked seeking', function(e){
-
- if(isInitial){
+ if(!e){
+ e.type = 'playing';
+ }
+ if(isInitial && (!isYt || !hasYtBug || e.type == 'playing' || data.media.prop('readyState') > 1)){
isInitial = false;
data.player.removeClass('initial-state');
}
if(isEnded){
@@ -600,17 +610,21 @@
if(!isEnded && !data.media.prop('loop') && data.media.prop('ended')){
isEnded = true;
data.player.addClass('ended-state');
}
});
+
return function(){
+ var hasYt;
var poster = data.media.attr('poster');
var hasPoster = !!poster;
var currentSrc = data.media.prop('currentSrc') || '';
- var isYt = regYt.test(currentSrc);
- var hasYt = (hasFlash && hasPoster) ? false : isYt;
+ isYt = regYt.test(currentSrc);
+
+ hasYt = (hasFlash && hasPoster) ? false : isYt;
+
if(!hasPoster && isYt){
poster = currentSrc.match(/(?:youtube\.com\/(?:[^\/]+\/.+\/|(?:v|e(?:mbed)?)\/|.*[?&]v=)|youtu\.be\/)([^"&?\/ ]{11})/i) || '';
if(poster){
poster = 'https://img.youtube.com/vi/'+ poster[1] +'/0.jpg';
hasPoster = !!poster;
@@ -634,9 +648,12 @@
if(isEnded){
isEnded = false;
data.player.removeClass('ended-state');
}
+
+ //https://code.google.com/p/gdata-issues/issues/detail?id=5415
+ data.player[isYt ? 'addClass' : 'removeClass']('yt-video');
if(lastYoutubeState !== hasYt){
lastYoutubeState = hasYt;
data.player[hasYt ? 'addClass' : 'removeClass']('has-ytposter');
}