views:

1617

answers:

1

Situation: here, where I pressed some video.

Problem: I try to stop the video by Javascript in the console of Firebug:

player.stopVideo(playerid):Void   [1] [2]

Question: Why does not the command above work?

[1] Source for the part "player.stopVideo():Void"

[2] I looked playerid with Firebug from the source.

+2  A: 

Your video is requesting w/ the JSAPI enabled, so you are very close! All you need is a valid reference to the embedded player. Inspecting your page revealed that you are using the HTML DOM element id of "playerid" to identify your player.

Example:

<embed id="playerid" width="100%" height="100%" allowfullscreen="true" allowscriptaccess="always" quality="high" bgcolor="#000000" name="playerid" style="" src="http://www.youtube.com/apiplayerbeta?enablejsapi=1&amp;playerapiid=normalplayer" type="application/x-shockwave-flash">

To obtain a reference to the player and then stop the video use the following code:

var myPlayer = document.getElementById('playerid');
myPlayer.stopVideo();
Raegx
Very cool! Great thanks!
Masi
Sentence: "Your video is requesting w/ the JSAPI enabled, so you are very close!" So it does not work without the API enabled?
Masi
So I am only able to control things like on the site, if the developer has designed an API on it? I feel it weird because JS is run on the client. Why would it not be possible to control JS on any arbitrary site without JS API enabled?
Masi
Raegx