Created
December 18, 2015 10:17
-
-
Save lovemyliwu/f04b1c4c7183cd094c3d to your computer and use it in GitHub Desktop.
Patch for Youku jsapi
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (!YKP.isSupportFlash) { | |
// patch for direct url | |
var oldSelectDirectUrl = YoukuPlayerSelect.prototype.selectDirectUrl; | |
YoukuPlayerSelect.prototype.selectDirectUrl = function () { | |
var oldStart = BuildVideoInfo.start; | |
BuildVideoInfo.start = function (vid, password, vtype, callback) { | |
var originCallBack = callback, | |
patchCallBack = function (v, videoInfo) { | |
var segsDic = videoInfo._videoSegsDic || {}, | |
lang = segsDic.lang || 'guoyu', | |
streams = segsDic.streams || {}, | |
videos = streams[lang] || {}; | |
for (var videoType in videos) { | |
segsDic[videoType] = videos[videoType]; | |
} | |
console.log(videoInfo); | |
originCallBack.apply(this, [v, videoInfo]); | |
}; | |
oldStart.apply(this, [vid, password, vtype, patchCallBack]); | |
}; | |
oldSelectDirectUrl.apply(this, arguments); | |
}; | |
// patch for h5mp4 | |
YoukuHTML5Player.prototype.isNeedAdRequest = function () { | |
return false; | |
}; | |
} else { | |
// patch for cover flash video | |
var oldSelectFlash = YoukuPlayerSelect.prototype.selectFlash; | |
YoukuPlayerSelect.prototype.selectFlash = function () { | |
oldSelectFlash.apply(this, arguments); | |
var movieSrc = $('.youku-player-wrapper').find('object').find('param[name="movie"]').prop('value'); | |
$('.youku-player-wrapper').find('object') | |
.append('<param name="wmode" value="transparent">'); | |
$('.youku-player-wrapper').find('object') | |
.append('<embed src="' + movieSrc + '" type="application/x-shockwave-flash" ' + | |
'allowscriptaccess="always" allowfullscreen="true" wmode="transparent"></embed'); | |
$('.youku-player').html($('.youku-player').html()); | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment