Skip navigation
y_andrei
Currently Being Moderated

Multiple Youtube embedded videos in the same scene

Jul 6, 2012 2:58 PM

Hi guys,

So, I looked for a AS code in order to embed a Youtube video in a scene. Ok. I found it in the Adobe Forum and it's working like a charm (see bellow). However I have to embed 3 more videos in the same scene.

I copied the code and changed the Youtube ID for the other videos. and of course a conflict came up.

So, Im wondering what should I do to get rid of this conflict. I supose that I have to change some parameters or names; I guess. (Im newbie in AS)

Could anyone help me?

Thanks!

 

 

 

Security.allowDomain("www.youtube.com");

Security.allowDomain("youtube.com");

Security.allowDomain("s.ytimg.com");

Security.allowDomain("i.ytimg.com");

Security.loadPolicyFile("http://i.ytimg.com/crossdomain.xml");

Security.loadPolicyFile("http://www.youtube.com/crossdomain.xml");

Security.loadPolicyFile("http://s.ytimg.com/crossdomain.xml")

 

 

var player:Object;

 

var loader:Loader = new Loader();

loader.contentLoaderInfo.addEventListener(Event.INIT, onLoaderInit);

loader.load(new URLRequest("http://www.youtube.com/v/XXXXXXX?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.setSize(365, 265);

    loader.x= 540,95

    loader.y= 264,50

}

 

 

function onPlayerError(event:Event):void {

        trace("player error:", Object(event).data);

}

 

 

function onPlayerStateChange(event:Event):void {

        trace("player state:", Object(event).data);

}

 

 

function onVideoPlaybackQualityChange(event:Event):void {

        trace("video quality:", Object(event).data);

}

 
Replies
  • kglad
    72,212 posts
    Jul 21, 2002
    Currently Being Moderated
    Jul 7, 2012 3:24 PM   in reply to y_andrei

    you're missing code.

     

    you need to use 3 different loaders and 3 different players.

     
    |
    Mark as:
  • kglad
    72,212 posts
    Jul 21, 2002
    Currently Being Moderated
    Jul 10, 2012 4:50 PM   in reply to y_andrei

    you're welcome.

     

    p.s.  please mark helpful/correct responses, if there are any.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points