gpt4 book ai didi

actionscript-3 - 使用ActionScript 3将YouTube嵌入Flash

转载 作者:行者123 更新时间:2023-12-03 06:01:08 25 4
gpt4 key购买 nike

我正在努力将youtube视频嵌入到我的Flash项目中,经过数小时的尝试找到可行的教程并研究Google提供的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();

关于actionscript-3 - 使用ActionScript 3将YouTube嵌入Flash,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17959748/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com