• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Multiple Youtube embedded videos in the same scene

New Here ,
Jul 06, 2012 Jul 06, 2012

Copy link to clipboard

Copied

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);

}

TOPICS
ActionScript

Views

761

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Jul 07, 2012 Jul 07, 2012

you're missing code.

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

Votes

Translate

Translate
Community Expert ,
Jul 07, 2012 Jul 07, 2012

Copy link to clipboard

Copied

you're missing code.

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 10, 2012 Jul 10, 2012

Copy link to clipboard

Copied

Thanks Kglad,

It's working perfect now!

CHEERS!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 10, 2012 Jul 10, 2012

Copy link to clipboard

Copied

LATEST

you're welcome.

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines