Skip to content

Instantly share code, notes, and snippets.

@miketaylr
Created February 20, 2014 17:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save miketaylr/9119551 to your computer and use it in GitHub Desktop.
Save miketaylr/9119551 to your computer and use it in GitHub Desktop.
// the Youku object
var Youku = (Youku || {});
// configurable variables
Youku._IsHtml5 = (Youku._IsHtml5 || false);
Youku._Player = "http://static.youku.com/v/swf/player.swf";
Youku._LivePlayer = "http://static.youku.com/v/swf/livePlayer.swf";
Youku._ApiPlayer = "http://player.youku.com/player.php";
Youku._ExpressInstall = "http://events.youku.com/global/flashes/expressInstall.swf";
Youku._VideoThumb = "http://events.youku.com/global/api/video-thumb.php";
// load the Youku Player
Youku.loadLivePlayer = function(channel, divName, playerWidth, playerHeight) {
channel = (channel || "101");
divName = (divName || "live_player");
playerWidth = (playerWidth || 600);
playerHeight = (playerHeight || 450);
var flashPlayerDiv = "flash_live_player_" + String(Math.random()).substr(2, 5);
var hId = document.getElementById(divName);
//alert(hId.innerHTML);
hId.innerHTML=('<div id="' + flashPlayerDiv + '"></div>');
var flashParams = {"quality": "high", "allowScriptAccess": "always", "allowFullScreen": "true", "bgcolor": "#000000"};
var flashVars = {"reconnects": 3, "channel": channel, "autoplay": 1, "showfrontad": 0, "dragback": 0};
swfobject.embedSWF(Youku._LivePlayer, flashPlayerDiv, playerWidth, playerHeight, "9.0.0", Youku._ExpressInstall, flashVars, flashParams);
};
Youku.loadPlayer = function(videoId, divName, playerWidth, playerHeight, autoPlay, imgLogo, fullToolbar) {
videoId = (videoId || "");
divName = (divName || "youku_player");
playerWidth = (playerWidth || 400);
playerHeight = (playerHeight || 315);
autoPlay = (autoPlay ? "true" : "false");
imgLogo = (imgLogo || "");
fullToolbar = (fullToolbar ? true : true);
var flashPlayerDiv = "flash_youku_player_" + String(Math.random()).substr(2, 5);
var hId = document.getElementById(divName);
hId.innerHTML=('<div id="' + flashPlayerDiv + '"></div>');
var flashParams = {"quality": "high", "allowScriptAccess": "always", "allowFullScreen": "true", "bgcolor": "#FFFFFF", "wmode": "transparent"};
var flashVars = {"winType": "index", "isShowRelatedVideo": "false", "isAutoPlay": autoPlay, "isLoop": "false", "UserID": "0", "VideoIDS": videoId};
if (imgLogo != "") { flashVars.imglogo = imgLogo; }
if (fullToolbar) { flashVars.winType = "interior"; }
swfobject.embedSWF(Youku._Player, flashPlayerDiv, playerWidth, playerHeight, "9.0.0", Youku._ExpressInstall, flashVars, flashParams);
};
Youku.loadFullPlayer = function(videoId, divName, playerWidth, playerHeight, autoPlay, imgLogo) {
playerWidth = (playerWidth || 400);
playerHeight = (playerHeight || 340);
Youku.loadPlayer(videoId, divName, playerWidth, playerHeight, autoPlay, imgLogo, true);
};
if((/(iPhone|iPad|iPod)/i.test(navigator.userAgent))){
//var a = '<a href="http://v.youku.com/v_show/id_XNDY5NDQ4NTA4.html" target="_blank"><img src="http://res.mfs.ykimg.com/051000004F4C3A969792734DCD0CF694.jpg" /></a>';
var a = '<a href="http://v.youku.com/v_show/id_XNDY5NDQ4NTA4.html" target="_blank"><img src="http://res.mfs.ykimg.com/051000004F4C3A969792734DCD0CF694.jpg" /></a>';
var player = document.getElementById("player");
player.innerHTML=a;
}else{
Youku.loadPlayer ("XNDY5NDQ4NTA4", "player", 575, 460, true);
}
@firecentaur
Copy link

Hi, I am wondering what this code is for... have you done much with the Youku api? I am particularly interested in how to display youku either as an html 5 player, or use a webplayer to play youku vids...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment