Skip to main content
Participant
December 17, 2010
Question

YouTube Chromeless player

  • December 17, 2010
  • 1 reply
  • 403 views

Hi i'm a bit of a newbie to AS 3.0 so can anyone plaese help me. I've used this sample code to play my youtube flv file, and it works like a charm. But i would really like i to go back to timeline frame 1 when the film i fisihed. This is the setup:


Frame 1 shows a stillpic(jpg) I have used this code to make it go to the frame wich loads the flv.

prev.addEventListener(MouseEvent.CLICK, release);
function release(MouseEvent):void {
gotoAndPlay(2);
}


frame 10 contains this (sample)code. I have tried different ways of writing it but the truth is that i'm in the blind here:

stop();
import flash.system.Security;

Security.allowInsecureDomain("*");
Security.allowDomain("*");

var player:Object;

var loader:Loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.INIT, onLoaderInit);
loader.load(new URLRequest("http://www.youtube.com/apiplayer?version=3"));

function onLoaderInit(event:Event):void {
addChild(loader);
loader.content.addEventListener("onReady", onPlayerReady);
loader.content.addEventListener("onError", onPlayerError);
loader.content.addEventListener("onStateChange", onPlayerStateChange);
loader.content.addEventListener("onPlaybackQualityChange", onVideoPlaybackQualityChange);
}

function onPlayerReady(event:Event):void {
   
    trace("player ready:", Object(event).data);
   
    player = loader.content;
    player.loadVideoById("x1y0O-6L0YY")
    player.setSize(400, 225);
    player.x = 10;
    player.y = 10;
}

function onPlayerError(event:Event):void {
    trace("player error:", Object(event).data);
}
function onPlayerStateChange(event:Event):void {
    trace("player state:", Object(event).data);
if(Object(event).data == 0){
    gotoAndPlay(1);
}
}

function onVideoPlaybackQualityChange(event:Event):void {
    trace("video quality:", Object(event).data);
}

This topic has been closed for replies.

1 reply

funkysoul
Inspiring
December 29, 2010

well it seems to me that after the video is finished you jump back to frame1, does that happen? The only thing that I think might be faulty is that you use gotoAndPlay(1) if you don't have a stop action in that frame, flash will just continue playing normally in this case jump automatically to frame 2 where it will play the video again. What's the exact behaviour at the moment?