我可以在我的 Flash 网站中嵌入 YouTube 播放器(带控件)吗?

发布于 2024-09-17 10:34:28 字数 221 浏览 4 评论 0原文

我希望将带有 YouTube 控件的 YouTube 视频嵌入到我的 Flash 网站中。这可能吗?

更新了解决方案:

var loader:Loader = new Loader();
loader.load(new URLRequest("http://www.youtube.com/v/zIcx_rxTstc"));
addChild(loader);

I am looking to embed a YouTube video with the YouTube controls into my Flash website. Is this possible?

UPDATED w/ SOLUTION:

var loader:Loader = new Loader();
loader.load(new URLRequest("http://www.youtube.com/v/zIcx_rxTstc"));
addChild(loader);

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

看起来这篇文章将为您提供所需的解决方案:

http://www .actionscript.org/forums/showthread.php3?t=122501

It looks like this post will provide you the solution you need:

http://www.actionscript.org/forums/showthread.php3?t=122501

对岸观火 2024-09-24 10:34:28

这是我为此制作的基本课程。
当然,您必须创建按钮。
并启用/禁用其某些功能。
希望有帮助
沙尼

包{
导入 flash.system.Security;
导入 flash.display.MovieClip;
导入 flash.display.Loader;
导入 flash.events.*;
导入 flash.net.URLRequest;

public class YouTubeAS3 extends MovieClip {
    private var player:Object;
    private var playBtn:PlayBtn;
    private var pauseBtn:PauseBtn;
    private var stopBtn:StopBtn;

    public function YouTubeAS3 (vidId:String) {

        Security.allowDomain("http://www.youtube.com") ;
                    var loader1:Loader = new Loader();
        loader1.contentLoaderInfo.addEventListener (Event.INIT, onLoaderInit);
        loader1.load (new URLRequest("http://www.youtube.com/apiplayer?version=3"));

        function onLoaderInit (event:Event):void {
            addChild (loader1);
            loader1.content.addEventListener ("onReady", onPlayerReady);
            loader1.content.addEventListener ("onError", onPlayerError);
            loader1.content.addEventListener ("onStateChange", onPlayerStateChange);
            loader1.content.addEventListener ("onPlaybackQualityChange", onVideoPlaybackQualityChange);

            playBtn= new PlayBtn();
            pauseBtn= new PauseBtn();
            stopBtn= new StopBtn();


            playBtn.x = pauseBtn.x = stopBtn.x = 430;
            playBtn.y = 20;
            pauseBtn.y = 50;
            stopBtn.y = 80;



            playBtn.addEventListener (MouseEvent.CLICK,playP);
            pauseBtn.addEventListener (MouseEvent.CLICK,pauseP);
            stopBtn.addEventListener (MouseEvent.CLICK,stopP);
            player.addEventListener (MouseEvent.CLICK,setPsize);

            addChild (playBtn);
            addChild (pauseBtn);
            addChild (stopBtn);
        }

        function onPlayerReady (event:Event):void {
            // Event.data contains the event parameter, which is the Player API ID 
            trace ("player ready:", Object(event).data);

            // to load a particular YouTube video.
            player = loader1.content;
            player.loadVideoById (vidId);
            player.setSize (448, 252);


        }



        function onPlayerError (event:Event):void {
            // Event.data contains the event parameter, which is the error code
            trace ("player error:", Object(event).data);
        }

        function onPlayerStateChange (event:Event):void {
            // Event.data contains the event parameter, which is the new player state
            trace ("player state:", Object(event).data);


            if(Object(event).data==1){
                //if(loading!=null){
                //removeChild(loading);
                //loading=null;
                //}
            }

        }

        function onVideoPlaybackQualityChange (event:Event):void {
            // Event.data contains the event parameter, which is the new video quality
            trace ("video quality:", Object(event).data);
        }
    }
    public function setPsize (evt:MouseEvent):void {
        player.setSize (640, 360);
    }

    public function playP (evt:MouseEvent):void {
        if (player) {

            player.playVideo ();
        }
    }
    public function pauseP (evt:MouseEvent):void {
        if (player) {

            player.pauseVideo ();
        }
    }

    public function stopP (evt:MouseEvent):void {
        if (player) {

            player.stopVideo ();
        }
    }

    public function muteP (evt:MouseEvent):void {
        if (player) {

            player.mute ();
        }

    }

    public function unMuteP (evt:MouseEvent):void {
        if (player) {

            player.unMute ();
        }
    }

    //player.isMuted():Boolean

    //player.setVolume(volume:Number):Void

}

}

this is a basic Class i made for that.
off course you will have to create the buttons.
and enable / disable some of its functions.
hope it will help
shani

package {
import flash.system.Security;
import flash.display.MovieClip;
import flash.display.Loader;
import flash.events.*;
import flash.net.URLRequest;

public class YouTubeAS3 extends MovieClip {
    private var player:Object;
    private var playBtn:PlayBtn;
    private var pauseBtn:PauseBtn;
    private var stopBtn:StopBtn;

    public function YouTubeAS3 (vidId:String) {

        Security.allowDomain("http://www.youtube.com") ;
                    var loader1:Loader = new Loader();
        loader1.contentLoaderInfo.addEventListener (Event.INIT, onLoaderInit);
        loader1.load (new URLRequest("http://www.youtube.com/apiplayer?version=3"));

        function onLoaderInit (event:Event):void {
            addChild (loader1);
            loader1.content.addEventListener ("onReady", onPlayerReady);
            loader1.content.addEventListener ("onError", onPlayerError);
            loader1.content.addEventListener ("onStateChange", onPlayerStateChange);
            loader1.content.addEventListener ("onPlaybackQualityChange", onVideoPlaybackQualityChange);

            playBtn= new PlayBtn();
            pauseBtn= new PauseBtn();
            stopBtn= new StopBtn();


            playBtn.x = pauseBtn.x = stopBtn.x = 430;
            playBtn.y = 20;
            pauseBtn.y = 50;
            stopBtn.y = 80;



            playBtn.addEventListener (MouseEvent.CLICK,playP);
            pauseBtn.addEventListener (MouseEvent.CLICK,pauseP);
            stopBtn.addEventListener (MouseEvent.CLICK,stopP);
            player.addEventListener (MouseEvent.CLICK,setPsize);

            addChild (playBtn);
            addChild (pauseBtn);
            addChild (stopBtn);
        }

        function onPlayerReady (event:Event):void {
            // Event.data contains the event parameter, which is the Player API ID 
            trace ("player ready:", Object(event).data);

            // to load a particular YouTube video.
            player = loader1.content;
            player.loadVideoById (vidId);
            player.setSize (448, 252);


        }



        function onPlayerError (event:Event):void {
            // Event.data contains the event parameter, which is the error code
            trace ("player error:", Object(event).data);
        }

        function onPlayerStateChange (event:Event):void {
            // Event.data contains the event parameter, which is the new player state
            trace ("player state:", Object(event).data);


            if(Object(event).data==1){
                //if(loading!=null){
                //removeChild(loading);
                //loading=null;
                //}
            }

        }

        function onVideoPlaybackQualityChange (event:Event):void {
            // Event.data contains the event parameter, which is the new video quality
            trace ("video quality:", Object(event).data);
        }
    }
    public function setPsize (evt:MouseEvent):void {
        player.setSize (640, 360);
    }

    public function playP (evt:MouseEvent):void {
        if (player) {

            player.playVideo ();
        }
    }
    public function pauseP (evt:MouseEvent):void {
        if (player) {

            player.pauseVideo ();
        }
    }

    public function stopP (evt:MouseEvent):void {
        if (player) {

            player.stopVideo ();
        }
    }

    public function muteP (evt:MouseEvent):void {
        if (player) {

            player.mute ();
        }

    }

    public function unMuteP (evt:MouseEvent):void {
        if (player) {

            player.unMute ();
        }
    }

    //player.isMuted():Boolean

    //player.setVolume(volume:Number):Void

}

}

趁年轻赶紧闹 2024-09-24 10:34:28

我的简化工作解决方案(复制和粘贴宝贝!):

package  {
    import flash.display.MovieClip;
    import flash.system.Security
    import flash.events.*;

    import flash.display.Loader;
    import flash.net.URLRequest;

    public class youtubeSandbox extends MovieClip {
        // remember, this is just an example - remove the following line for production!
        Security.allowInsecureDomain("*");

        var my_player:Object;
        var my_loader:Loader = new Loader();

        public function youtubeSandbox () {
            my_loader.load(new URLRequest("http://www.youtube.com/v/5P6UU6m3cqk?version=3"));
            // use either /v or /apiplayer
            //my_loader.load(new URLRequest("http://www.youtube.com/apiplayer?version=3"));

            my_loader.contentLoaderInfo.addEventListener(Event.INIT, onLoaderInit);
        }
        function onLoaderInit(e:Event):void{
            addChild(my_loader);
            my_player = my_loader.content;
            my_player.addEventListener("onReady", onPlayerReady); 
        } 
        function onPlayerReady(e:Event):void{
            my_player.setSize(640,480);
        }
    }
}

参考资料:

My simplified working solution (copy & paste baby!):

package  {
    import flash.display.MovieClip;
    import flash.system.Security
    import flash.events.*;

    import flash.display.Loader;
    import flash.net.URLRequest;

    public class youtubeSandbox extends MovieClip {
        // remember, this is just an example - remove the following line for production!
        Security.allowInsecureDomain("*");

        var my_player:Object;
        var my_loader:Loader = new Loader();

        public function youtubeSandbox () {
            my_loader.load(new URLRequest("http://www.youtube.com/v/5P6UU6m3cqk?version=3"));
            // use either /v or /apiplayer
            //my_loader.load(new URLRequest("http://www.youtube.com/apiplayer?version=3"));

            my_loader.contentLoaderInfo.addEventListener(Event.INIT, onLoaderInit);
        }
        function onLoaderInit(e:Event):void{
            addChild(my_loader);
            my_player = my_loader.content;
            my_player.addEventListener("onReady", onPlayerReady); 
        } 
        function onPlayerReady(e:Event):void{
            my_player.setSize(640,480);
        }
    }
}

References:

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文