Reputation: 2424
Here is my code:
var player;
function onYouTubeIframeAPIReady() {
player = new YT.Player('myytflashplayer', {
loadPlaylist:{
},
events: {
'onReady': onPlayerReady,
'onPlayerStateChange': onPlayerStateChange
}
});
}
function onPlayerReady(event) {
event.target.mute();
event.target.playVideo(10);
event.target.seekTo(10);
event.target.playVideoAt(5);
}
var done = false;
function onPlayerStateChange() {
if (event.data == YT.Player.PLAYING && !done) {
event.setTimeout(stopVideo,6000);
done=true;
}
}
function seekTo() {
player.seekTo();
}
public
function playVideo() {
player.playVideo()
}
public
function pauseVideo() {
player.pauseVideo()
}
public
function stopVideo() {
player.stopVideo()
}
public
function muteVideo() {
player.mute()
}
public
function unmuteVideo() {
player.unMute()
}
// var params = { allowScriptAccess: "always" };
// var atts = { id: "myytplayer" };
// swfobject.embedSWF("http://www.youtube.com/v/Kunq0JnYCKE?version=3&origin=https://developers.google.com&enablejsapi=1&loop=1&autoplay=1&start=10&rel=0","ytapiplayer", "800", "500", "8", null, null, params, atts);
// });
</script>
<object width="640" height="390" >
<param name="movie" value="https://www.youtube.com/v/videoseries?version=3&listType=playlist&list=PLqRSwyqnU1WEECXxN3uN08G24h34EQOko&autoplay=1"></param>
<param name="allowScriptAccess" value="always"></param>
<embed src="https://www.youtube.com/v/videoseries?version=3&listType=playlist&list=PLqRSwyqnU1WEECXxN3uN08G24h34EQOko&origin=https://developers.google.com&enablejsapi=1&playerapiid=myytflashplayer&autoplay=1" type="application/x-shockwave-flash"
allowscriptaccess="always" width="640" height="390"></embed>
</object>
here is my event to do in my flash action script 3.0 youtube player api
autoplay a random video in the playlist
the video will start at 10 seconds in
the video will start muted
when someone clicks to unmute the audio, restart the video from the beginning and unmute the audio.
any first interaction with the video should unmute it. For example, if they pause the video for the first time, unmute the audio and pause it.
when the video finishes, it can pick another Random video from the playlist or go to the next video in the order of the playlist. Whichever is easier.
the playlist should loop if they've seen all the videos.
the video can't auto-play for some users (mobile). When it doesn't autoplay, it should show the thumbnail from the video. When the person manually presses play, the video should start with normal sound.
Upvotes: 0
Views: 166
Reputation: 2433
I think you are a bit confused with which API you are using. The YT.Player api uses the HTML5 iframe player API, but you are inserting a flash object at the bottom - which is a different API.
Documentation for the iframe player is here: https://developers.google.com/youtube/iframe_api_reference
And Documentation for the Javascript interface to the Flash players is available here: https://developers.google.com/youtube/js_api_reference
Upvotes: 0