LAZIOMATICA – Guida allo Sviluppo Software

La nuova forma del software su misura…

 

Developing Adobe AIR / Flex – Simple Youtube player with “AirYouTube” library

In previous example I have implemented a simple player with tubeloc library, but when i use it for multiple youtube player application it doesn’t work as aspected! infact this library has problems with multiple istances of the component, so only one istance can be used and the “destroy” method doen’t free the istance…so i try to find something else.
For this purpose i found aroun the web “AirYouTube”, another good component library and i post here another simple application with a main player and a button tha open simultanusly another istance of player in a pop up window.
The library and example can be founded at blog.derhess.de

and this is my basic snippet of code:

main application:

<?xml version=”1.0″ encoding=”utf-8″?>

<mx:WindowedApplication xmlns:mx=”http://www.adobe.com/2006/mxml” layout=”absolute

xmlns:youtube=”de.derhess.video.youtube.*

width=”599” height=”600>

<mx:Script>

<![CDATA[

import mx.managers.PopUpManager;

import de.derhess.video.youtube.AirYouTube;

import de.derhess.video.youtube.YouTubeAS3;

import flash.utils.getDefinitionByName;

import de.derhess.video.youtube.YouTubeError;

import de.derhess.video.youtube.YouTubePlayingState;

import mx.controls.Alert;

import mx.collections.ArrayCollection;

import de.derhess.video.youtube.YouTubeVideoQuality;

import de.derhess.video.youtube.YouTubeEvent;

private function handlePlayerLoaded(event:YouTubeEvent):void

{

youTubePlayer.cueVideoById("paste_here_your_youtube_videoID_here",0,YouTubeVideoQuality.DEFAULT);

}

public function apriPop():void{

var myPop:pop = new pop();

PopUpManager.addPopUp(myPop,this,true);

}

]]>

</mx:Script>

<mx:Button x=”387” y=”393” label=”Carica Video in Popup” click=”apriPop();”/>

<youtube:FlexYouTube id=”youTubePlayer

x=”330” y=”0

width=”320” height=”240

volume=”100

youtubePlayerLoaded=”{handlePlayerLoaded(event);}”

/>

</mx:WindowedApplication>

pop.mxml component:

<?xml version=”1.0″ encoding=”utf-8″?>

<mx:Canvas xmlns:mx=”http://www.adobe.com/2006/mxml” width=”400” height=”300” xmlns:youtube=”de.derhess.video.youtube.*>

<mx:Script>

<![CDATA[

import de.derhess.video.youtube.AirYouTube;

import de.derhess.video.youtube.YouTubeAS3;

import flash.utils.getDefinitionByName;

import de.derhess.video.youtube.YouTubeError;

import de.derhess.video.youtube.YouTubePlayingState;

import mx.controls.Alert;

import mx.collections.ArrayCollection;

import de.derhess.video.youtube.YouTubeVideoQuality;

import de.derhess.video.youtube.YouTubeEvent;

private function handlePlayerLoaded2(event:YouTubeEvent):void

{

youTubePlayer2.cueVideoById("paste_here_your_youtube_videoID_here",0,YouTubeVideoQuality.DEFAULT);

}

]]>

</mx:Script>

<youtube:FlexYouTube id=”youTubePlayer2

x=”59” y=”234

width=”320” height=”240

volume=”100

youtubePlayerLoaded=”{handlePlayerLoaded2(event);}”

/>

</mx:Canvas>


Filed under : Actionscript 3,AIR,Flash CS5,Flex,Flexbuilder,RIA
By admin
On 27 settembre 2010
At 08:27
Comments :Commenti disabilitati
 
 

Adobe Flash e sviluppo per iPhone

Adobe Flash Professional CS5 permetterà di sviluppare software per iPhone!

Articolo originale su macitynet.it

Filed under : Actionscript 3,AIR,Flash CS5,Flex,Flexbuilder,RIA
By admin
On 15 ottobre 2009
At 08:24
Comments : 0