由网友(別鬧啊)分享简介:我挣扎嵌入YouTube视频到我的闪存项目,我只是不能得到任何小时,试图找到一个工作教程和研究API谷歌提供小时的工作。我想有一个球员,可能会从YouTube的播放列表中播放为目标,是向人们展示一个乐队的现场表演,但我没有线索如何得到它掉在地上的!如果有人可以帮助,那将是极大的AP preciated。感谢您! :)...
我挣扎嵌入YouTube视频到我的闪存项目,我只是不能得到任何小时,试图找到一个工作教程和研究API谷歌提供小时的工作。 我想有一个球员,可能会从YouTube的播放列表中播放为目标,是向人们展示一个乐队的现场表演,但我没有线索如何得到它掉在地上的!
如果有人可以帮助,那将是极大的AP preciated。
感谢您! :)
解决方案 进口类flash.system.Security;
的Security.allowDomain('*');
了Security.allowInsecureDomain('*');
VAR VPLAYER:对象;
VAR playerLoader:装载机;
功能loadVideo():无效
{
playerLoader =新的Loader();
//下一行加载YouTube播放器,没有用户界面
playerLoader.load(新的URLRequest('http://www.youtube.com/apiplayer?version=3'));
//等待它加载
playerLoader.contentLoaderInfo.addEventListener(Event.INIT,onLoaderInit);
}
功能onLoaderInit(EVT:事件):无效
{
//'vPlayer_container是,你需要创建持有YouTube播放器的阶段,一个影片剪辑。
//添加您的YouTube加载程序,(这实际上是玩家),到vPlayer_container的显示列表。
vPlayer_container.addChild(playerLoader);
//设置VPLAYER变量是加载YouTube播放器
VPLAYER = playerLoader.content;
//等待它做好准备
vPlayer.addEventListener('onReady',onPlayerReady);
}
功能onPlayerReady(EVT:事件):无效
{
vPlayer.removeEventListener('onReady',onPlayerReady);
为的onComplete和播放/暂停事件//设置监听器
vPlayer.addEventListener('onStateChange',onPlayerStateChange);
//如果你想在启动静音
vPlayer.mute();
//设置视频画面大小
vPlayer.setSize(392220);
//现在加载您的YouTube视频在你的新的YouTube播放器
//得到这个视频数量过的URL到您的YouTube视频
vPlayer.loadVideoById('GEghz32qhiA',0);
}
功能onPlayerStateChange(EVT:事件):无效
{
//如果视频已经结束
如果(对象(EVT)的.data == 0)
{
//做一些事情时,视频结束
}
}
//其他玩家可用的命令 - 你需要使自己的按钮,这些
// vPlayer.mute();
// vPlayer.unMute();
// vPlayer.pauseVideo();
// vPlayer.playVideo();
//开始的全过程,调用loadVideo();
I'm struggling to embed a youtube video into my flash project, I just can't get anything to work after hours and hours of trying to find a working tutorial and studying the api google have provided. I want to have a player that could possibly play from a youtube playlist as the goal is to showcase live performances of a band, but I don't have a clue how to get it off of the ground!
If anyone can help, it would be greatly appreciated.
Thank you! :)
解决方案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();
相关推荐
最新文章