我正在構建一個有兩種可切換大小的播放器,由用戶更改,但我沒有獲得相關結果。如何調整視頻的大小
這是我的setupPlayer功能,工作正常:
function setupPlayer():void
{
layout.width = _playerWidth;
layout.height = _playerHeight;
layout.layoutMode = LayoutMode.HORIZONTAL
layout.horizontalAlign = HorizontalAlign.CENTER;
layout.verticalAlign = VerticalAlign.TOP;
layout.scaleMode = ScaleMode.LETTERBOX;
videoElement.addMetadata(LayoutMetadata.LAYOUT_NAMESPACE, layout);
videoElement.smoothing = true;
mediaPlayer.loop = false;
mediaPlayer.autoPlay = _autoPlay;
mediaContainer.addMediaElement(videoElement);
videoCanvas.addChild(mediaContainer);
.... // more code //
}
然後,我喂的球員,它開始正常播放,這是當我試圖調整其大小。 (我沒地方讀書,我需要改變LayoutMetadata),但沒有任何效果:
public function resize(width:Number, height:Number):void
{
// none of this worked
//mediaContainer.width = 1200;
//mediaContainer.height = 2000;
//mediaContainer.layout(1200, 2000, true);
// neither this
var layout:LayoutMetadata = new LayoutMetadata();
layout.width = 1500;
layout.height = 1500;
layout.layoutMode = LayoutMode.HORIZONTAL
layout.horizontalAlign = HorizontalAlign.CENTER;
layout.verticalAlign = VerticalAlign.TOP;
layout.scaleMode = ScaleMode.STRETCH;
videoElement.removeMetadata(LayoutMetadata.LAYOUT_NAMESPACE)
videoElement.addMetadata(LayoutMetadata.LAYOUT_NAMESPACE, layout);
}
有人能在我的錯誤是什麼?
謝謝!
我想出如何做到這一點,我需要改變mediaContainer **和**設置一個新的layouMetadata。 –