1

通过 StageWebView Air 组件加载 Youtube 视频时,我需要将视频缩小到视口大小,显示黑条是可以的,但我最终看到的是视频原始大小的裁剪版本。

我没有看到任何可以使用的额外参数,API 似乎非常有限。

任何想法如何播放视频,即使源较大,我也可以将其调整为视口大小?

4

2 回答 2

1

通常我会显示 Youtube,如另一个答案所示(但会加载您可能不想要的 Flash Player 版本)。PS:记住它.com/v/VID_ID用于 Flash Player 或.com/embed/VID_ID用于 HTML5 Player。

任何想法如何播放视频,即使源较大,我也可以将其调整为视口大小?

你说你有与作为答案发布的 Android 示例类似的代码?为什么不尝试打开一个iframe,因为这将允许调整大小选项?

自定义大小的 Youtube iframe 示例...

<iframe width="800" height="600" src="https://www.youtube.com/embed/"+ VID +"?autoplay=1" frameborder="0" allowfullscreen></iframe>

要在 iframe 中打开,您必须通过代码制作动态网页。下面的代码未经测试,但基于Adob​​e 论坛的这个想法。只是一个起点,您可以调整/修复...

var html_Dynamic : String;

html_Dynamic = "<!DOCTYPE HTML>" +
                "<html>" +
                    "<body>" +
                        "<iframe class=\"youtube-player\" style=\"border: 0; width: 100%; height: 100%; padding:0px; margin:0px\" id=\"ytplayer\" type=\"text/html\" src=\"https://www.youtube.com/embed/" +
                            VID + "?fs=0\" frameborder=\"0\">\n" +  "</iframe>\n";
                "</body>" +
                "</html>";
于 2016-04-06T18:31:10.983 回答
0

我将此代码用于 Android 试一试:(它调整页面大小)

import flash.display.MovieClip;
import flash.media.StageWebView;
import flash.geom.Rectangle;
import flash.events.Event;
import flash.utils.Timer;
import flash.events.TimerEvent;
import flash.system.Capabilities;

this.visible = false ;

var webView: StageWebView = new StageWebView();



webView.stage = stage;



function videoing(VID): void {/// VID is the video id
     stage.setAspectRatio(StageAspectRatio.LANDSCAPE);

    var vidLink:String = "https://www.youtube.com/embed/"+ VID +"?autoplay=1" ;
    trace(vidLink);
    webView = new StageWebView();
    webView.stage = this.stage;
    webView.viewPort = new Rectangle(-(stage.stageHeight/2)+100,0, stage.stageHeight*2+40 , stage.stageWidth*2 - 160);
    webView.loadURL(vidLink);
    this.stage.focus = stage;
}


//////////////// dispose the video ///////////////////////

exit_btn.addEventListener(KeyboardEvent.KEY_DOWN, fl_OptionsMenuHandler);

function fl_OptionsMenuHandler(event: KeyboardEvent = null ): void {
    if ((event.keyCode == Keyboard.BACK) && (webView)) {
        event.preventDefault();
        webView.stage = null;
        webView.dispose();
        webView = null ;
        stage.setAspectRatio(StageAspectRatio.PORTRAIT);
    }   
}

在 Android 上它需要添加

 <application android:hardwareAccelerated="true"/> 
于 2016-04-06T12:22:10.207 回答