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

Actionscript 3 & Youtube API: Thumbnails

New Here ,
Sep 23, 2013 Sep 23, 2013

Hello. I've currently got a nice little file setup that pulls in a youtube video. I'd like to setup additional images that pull in thumbnails in a different area of the stage, that will act as buttons and load and play the fullsized video. I'm used the version of the youtube player that has the defaul buttons.  Here is the code I have so far:

import flash.display.Loader;

import flash.net.URLRequest;

import flash.events.Event;

import flash.system.Security;

import flash.display.DisplayObject;

import flash.display.Sprite;

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

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

Security.allowDomain("http://s.ytimg.com");

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

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

var vid_player:Object;

var thumb1:Object;

var my_loader:Loader = new Loader();

my_loader.load(new URLRequest("http://www.youtube.com/v/GctR_uzuNvw?version=3"));

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

function onLoaderInit(e:Event):void{

          addChild(my_loader);

          vid_player = my_loader.content;

          vid_player.addEventListener("onReady", onPlayerReady);

          my_loader.content.addEventListener("onReady", onPlayerReady);

    my_loader.content.addEventListener("onError", onPlayerError);

    my_loader.content.addEventListener("onStateChange", onPlayerStateChange);

    my_loader.content.addEventListener("onPlaybackQualityChange",

    onVideoPlaybackQualityChange)

}

function onPlayerReady(e:Event):void{

          vid_player.setSize(415,234);

          //vid_player.cueVideoById("npvJ9FTgZbM",3);

          //vid_player.pauseVideo();

          vid_player.x = 262;

          vid_player.y = 7;

          vid_player = my_loader.content;

 

}

function createFeaturedButtons(thumb1:Object, featuredVideos:Array) {

  var results:Array = [];

  for each (var id:String in featuredVideos) {

    results.push(thumb1.getClickToPlayButton("bHQqvYy5KYo"));

            }

  return results;

  trace(featuredVideos);

}

function onPlayerError(event:Event):void {

    // Event.data contains the event parameter, which is the error code

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

}

function onPlayerStateChange(event:Event):void {

    // Event.data contains the event parameter, which is the new player state

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

}

function onVideoPlaybackQualityChange(event:Event):void {

    // Event.data contains the event parameter, which is the new video quality

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

}

I'm pretty sure the problem is with this code:

function createFeaturedButtons(thumb1:Object, featuredVideos:Array) {

  var results:Array = [];

  for each (var id:String in featuredVideos) {

    results.push(thumb1.getClickToPlayButton("bHQqvYy5KYo"));

   }

  return results;

  trace(featuredVideos);

}

I don't seem to have that quite setup right. Please any help would be greatly appreciated.

TOPICS
ActionScript
450
Translate
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
no replies

Have something to add?

Join the conversation