我正在努力将 youtube 视频嵌入到我的 flash 项目中,经过数小时的努力寻找工作教程和研究谷歌提供的 api,我无法得到任何工作。我想要一个可以从 youtube 播放列表播放的播放器,因为目标是展示乐队的现场表演,但我不知道如何让它脱离地面!
如果有人可以提供帮助,将不胜感激。
谢谢!:)
我正在努力将 youtube 视频嵌入到我的 flash 项目中,经过数小时的努力寻找工作教程和研究谷歌提供的 api,我无法得到任何工作。我想要一个可以从 youtube 播放列表播放的播放器,因为目标是展示乐队的现场表演,但我不知道如何让它脱离地面!
如果有人可以提供帮助,将不胜感激。
谢谢!:)
import flash.system.Security;
Security.allowDomain( '*' );
Security.allowInsecureDomain( '*' );
var vPlayer:Object;
var playerLoader:Loader;
function loadVideo():void
{
playerLoader = new Loader();
// next line loads a youtube player with no UI
playerLoader.load( new URLRequest( 'http://www.youtube.com/apiplayer?version=3' ) );
// wait for it to load
playerLoader.contentLoaderInfo.addEventListener( Event.INIT, onLoaderInit );
}
function onLoaderInit( evt:Event ):void
{
// 'vPlayer_container' is a movieclip on stage that you need to create to hold the youtube player.
// add your youtube Loader, ( which is actually the player ), to vPlayer_container's display list.
vPlayer_container.addChild(playerLoader);
// set the vPlayer variable to be the loaded youtube player
vPlayer = playerLoader.content;
// wait for it to be ready
vPlayer.addEventListener( 'onReady', onPlayerReady );
}
function onPlayerReady( evt:Event ):void
{
vPlayer.removeEventListener( 'onReady', onPlayerReady );
// set listener for onComplete and play/pause events
vPlayer.addEventListener( 'onStateChange', onPlayerStateChange );
// mute it on start if you want
vPlayer.mute();
// set size of video screen
vPlayer.setSize( 392,220 );
// now load your youtube video in your new youtube player
// get this video number off the url to your youtube video
vPlayer.loadVideoById( 'GEghz32qhiA', 0 );
}
function onPlayerStateChange( evt:Event ):void
{
// if video is over
if( Object(evt).data == 0 )
{
//do something when video is over
}
}
// other player commands available - you need to make your own buttons for these
// vPlayer.mute();
// vPlayer.unMute();
// vPlayer.pauseVideo();
// vPlayer.playVideo();
// to start the whole process, call loadVideo();