我正在构建一个具有两种可切换尺寸的播放器,由用户更改,但我没有结果。
那是我的 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);
}
有人可以指出我的错误在哪里?
谢谢!