New "services” package added to the Reyco1 AS3 Tools with an easy to use YouTube api!
Reynaldo February 18th, 2008
Hi all:
There has been a new “services” package added and along with it a very simple to use YouTube api. Simultaneously, the PayPalCart class has been renamed to PayPal and has been moved to this new package as well.
The new YouTube api is very simple to use. All you need is a YouTube developer key which you can get at YouTube and 2 proxy php/aspx files which are provided within the YouTube sample folder. Here’s a small example:
This movie requires Flash Player 9
Here’s the source:
import com.reyco1.services.YouTube;
import com.reyco1.events.YouTubeEvent;
import flash.events.Event;
var objYouTube:YouTube = new YouTube();
var objparameters:Object = new Object();
var flvPlayer:Video = this.player;
var netConnection:NetConnection = new NetConnection();
netConnection.connect(null);
var netStream:NetStream = new NetStream(netConnection);
objparameters.key = "your api key goes here";
objparameters.proxy = "http://www.yourdomain.com/services/YouTube/proxyRequest.php";
objparameters.video_proxy = "http://www.yourdomain.com/services/YouTube/getVideoId.php";
objYouTube.setup(objparameters);
objYouTube.addEventListener(YouTubeEvent.REQUEST_COMPLETE, requestCompleteHandler);
objYouTube.addEventListener(YouTubeEvent.FLV_REQUEST_COMPLETE, flvRequestCompleteHandler);
videoList.addEventListener(Event.CHANGE, onChangeHandler)
searchBtn.addEventListener(MouseEvent.CLICK, searchHandler);
function searchHandler($event:MouseEvent):void
{
objYouTube.getVideos({tag:tagText.text});
}
function requestCompleteHandler($event:YouTubeEvent):void
{
var data:XMLList = $event.params.data;
videoList.labelField = "title";
videoList.removeAll();
for each (var video in data) {
videoList.addItem(video);
}
}
function flvRequestCompleteHandler($event:YouTubeEvent):void
{
netConnection.connect(null);
netStream = new NetStream(netConnection);
netStream.bufferTime = 5;
netStream.client = {onMetaData:onMetaHandler};
flvPlayer.attachNetStream(netStream);
netStream.play($event.params.path);
}
function onMetaHandler(data:Object) {
var duration:Number = Number(data.duration);
}
function onChangeHandler($event:Event):void
{
netStream.close();
var selectedItemData:XML = videoList.selectedItem as XML;
objYouTube.requestFLV(selectedItemData.id);
}
Click on the “Reyco1 AS3 Toolset” tab for instructions on documentation and and sub version.




plz provide the zip file for this with all the files……..
and plz tell us how to display ads on the player…..ads must overlay on the player…………
plz help…………………