3 Replies Latest reply: Jul 10, 2012 4:50 PM by kglad RSS

    Multiple Youtube embedded videos in the same scene

    y_andrei

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

      }