We expose a Javascript API for our flash Twitch player that gives flexibility and functionality to embedding.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<script src="//ajax.googleapis.com/ajax/libs/swfobject/2.2/swfobject.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script>
$(function () {
window.onPlayerLoad = function () {
var player = $("#twitch_embed_player")[0];
player.playVideo();
player.mute();
};
swfobject.embedSWF("//www-cdn.jtvnw.net/swflibs/TwitchPlayer.swf", "twitch_embed_player", "640", "400", "11", null,
{ "loadCallback":"onPlayerLoad",
"embed":1,
"channel":"chaoxlol",
"auto_play":"true"},
{ "allowScriptAccess":"always",
"allowFullScreen":"true"});
});
</script>
</head>
<body>
<div id="twitch_embed_player">
</div>
</body>
</html>
Name | Description |
---|---|
playVideo |
If stream is online, will play the player. |
pauseVideo |
If stream is online, will pause the player. |
mute |
Mutes the player. |
unmute |
Unmutes the player. |
onlineStatus |
Returns the online status of the loaded stream. Values are online , offline , or unknown . |
loadStream |
Loads a given stream. Parameter is a string. |
loadVideo |
Loads a given video. Parameter is the video id. |