Wednesday, July 11, 2012

Re: [YouTube-API] Re: Chromeless player error when run on local machine (not web)

Hi Tim,

The issue is running the html from a local disk not as an online URL .
 
Not only do the events not get fired in IE, but even a simple call such as player.getVolume() fails, in IE.
 
I've tried many IE settings to no avail. I think the error lies in the messaging between the player and iframe in the YT code (see the error details mentioned above).
 
Here is the complete HTML page :
 

<html>

<body>

<!-- 1. The <iframe> (and video player) will replace this <div> tag. -->

<div id="player"></div>

<script>

// 2. This code loads the IFrame Player API code asynchronously.

var tag = document.createElement('script');

tag.src = "http://www.youtube.com/player_api";

var firstScriptTag = document.getElementsByTagName('script')[0];

firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);

 

// 3. This function creates an <iframe> (and YouTube player)

// after the API code downloads.

var player;

function onYouTubePlayerAPIReady() {

player = new YT.Player('player', {

height: '480',

width: '853',

videoId: 'u1zgFlCw8Aw',

events: {

'onReady': onPlayerReady,

'onStateChange': onPlayerStateChange

}

});

setTimeout("check()",3000);

}

function check() {

try {

alert(player.getVolume());

}catch(ex){alert("error in check() : "+ex);}

}

// 4. The API will call this function when the video player is ready.

function onPlayerReady(event) {

alert("player ready");

event.target.playVideo();

}

// 5. The API calls this function when the player's state changes.

// The function indicates that when playing a video (state=1),

// the player should play for six seconds and then stop.

var done = false;

function onPlayerStateChange(event) {

if (event.data == YT.PlayerState.PLAYING && !done) {

setTimeout(stopVideo, 6000);

done = true;

}

}

function stopVideo() {

player.stopVideo();

}

</script>

</body>

</html>

 

On Wednesday, July 11, 2012 12:02:20 PM UTC+1, Tim Wintle (Guru) wrote:
Do you have a publicly viewable url where this can be seen?

Tim Wintle

On Wed, 2012-07-11 at 03:53 -0700, kina99 wrote:
> Trying to attach an event listener later also does not work.
>  
> This is a very serious bug. Javascript contolled embed players don't
> work in the most widely used browser unless online.
>
>                  
>
> --
> You received this message because you are subscribed to the Google
> Groups "YouTube APIs Developer Forum" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/youtube-api-gdata/-/jLEwZVgqJssJ.
> To post to this group, send email to
> youtube-api-gdata@googlegroups.com.
> To unsubscribe from this group, send email to youtube-api-gdata
> +unsubscribe@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/youtube-api-gdata?hl=en.


--
You received this message because you are subscribed to the Google Groups "YouTube APIs Developer Forum" group.
To view this discussion on the web visit https://groups.google.com/d/msg/youtube-api-gdata/-/GtzV1ZHpdj8J.
To post to this group, send email to youtube-api-gdata@googlegroups.com.
To unsubscribe from this group, send email to youtube-api-gdata+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/youtube-api-gdata?hl=en.

No comments:

Post a Comment