【问题标题】:AS2 full screen only the video window on the stageAS2全屏只有舞台上的视频窗口
【发布时间】:2014-12-29 04:02:38
【问题描述】:

我已经从高处和低处搜索了这个问题的答案。我使用 AS2 而不是 AS3,并且我知道全屏视频/音频/文本聊天 SWF 的几种方法,但是有没有办法在 Flash 文件中创建一个按钮,该按钮只能全屏显示视频窗口 mc?如果我正常全屏显示文本和所有内容,单击全屏时我想要显示的只是视频窗口。我不知道该怎么做。任何帮助都会很棒。如果答案在这个网站或网络上,我不知道我是怎么错过的,因为我一直在寻找大约 3 周但没有运气。如果是,请接受我的道歉。在此先感谢所有火箭科学家:)

【问题讨论】:

    标签: flash resize actionscript-2 stage mc


    【解决方案1】:

    要做你想做的事,你可以做正常的全屏并将你的视频尺寸设置为Stage.widthStage.height,当然不要忘记设置深度。

    以这个例子为例,你可以在here线上看到:

    // don't forget to set the Stage.scaleMode and Stage.align
    Stage.scaleMode = 'showAll'; // noBorder, exactFit, noScale
    Stage.align = 'T'; // top center
    
    // boolean to indicate if we do the fullscreen of the video element
    var video_is_fullscreen:Boolean = false;
    var server:String = null;
    var stream = 'http://stream.flowplayer.org/flowplayer-700.mp4';
    
    var nc:NetConnection = new NetConnection();
        nc.connect(server); 
    var ns:NetStream = new NetStream(nc);
        ns.play(stream);
    
        // we use a Video element inside a MovieClip to set the object depth later
        video_player.video.attachVideo(ns);
        video_player.video.smoothing = true;
    
        // just to disable sound
        video_player.attachAudio(ns);
        var audio:Sound = new Sound(video_player);
            audio.setVolume(0); 
    
    // toggle play / pause video
    video_player.onPress = function(){
        ns.pause();
    }
    
    // set stage fullscreen mode
    btn_fullscreen.onPress = function(){
        full_screen();
    }
    
    // set video element fullscreen mode
    btn_fullscreen_video.onPress = function(){
        video_is_fullscreen = true;
        full_screen();
    }
    function full_screen(){
        Stage.displayState = Stage.displayState == 'normal' ? 'fullScreen' : 'normal';  
    }
    
    // add stage fullscreen event listener
    var event_listener:Object = new Object();
    Stage.addListener(event_listener);
    event_listener.onFullScreen = function(fullscreen_active:Boolean){
        if(video_is_fullscreen){    
            if(fullscreen_active){
                // set our video element fullscreen mode
                video_player._x = video_player._y = 0;
                video_player._width = Stage.width;
                video_player._height = Stage.height;
            } else {
                // set our video element to it's normal mode
                video_player._x = 10;
                video_player._y = 30;
                video_player._width = 160;
                video_player._height = 120;
                video_is_fullscreen = false;
            }       
        } else {
            video_is_fullscreen = false;
        }
    }
    
    // set depths of all stage elements
    function set_depths():Void {
        image.swapDepths(2);
        txt.swapDepths(4);
        video_player.swapDepths(8); 
        btn_fullscreen.swapDepths(6);
        btn_fullscreen_video.swapDepths(10);
    }
    
    set_depths();
    

    当然,这只是向您展示制作全屏视频的方式的示例,您必须对其进行改进并使其适应您的需求。

    希望对你有帮助。

    【讨论】:

    • 谢谢,我会尝试一下,我看到代码中的平滑。我运行实时视频流并且过去遇到过问题并尝试使用平滑功能但从未注意到任何差异,这是否仅适用于全屏等放大模式?
    • @dellee 是的,就是这样。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-12-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-02-21
    • 1970-01-01
    相关资源
    最近更新 更多