[英]Get Video Width and Height from Azure Media Player
I have video's I'm streaming from Azure Media Services and are being rendered in my web page using Azure Media Player API . I have video's I'm streaming from Azure Media Services and are being rendered in my web page using Azure Media Player API .
I don't know ahead of time what the videos dimensions are (and they will vary).我不提前知道视频尺寸是什么(它们会有所不同)。 My issue is that when I play the video there is a black border (either at top/bottom or at left/right) around the video if I don't create the video element with the correct ratio to match the video.我的问题是,当我播放视频时,如果我没有创建具有正确比例的视频元素以匹配视频,则视频周围会出现黑色边框(在顶部/底部或左/右)。 See for example the image below, notice the large black borders on the left and right of the video.例如,请参见下图,注意视频左右两侧的黑色大边框。 I'd like to get the video size so I can correct the dimensions and get rid of the border.我想获得视频大小,以便我可以更正尺寸并摆脱边框。
The Azure Media Player API seems to say I can get the videoWidth and videoHeight . Azure 媒体播放器 API 似乎说我可以得到videoWidth和videoHeight 。 But I'm not sure (in Javascript) what object to get those values from.但我不确定(在 Javascript 中)从哪个 object 获取这些值。
In my script below, when I console.log
the player
object I don't see videoWidth
or videoHeight
as part of the player object.在下面的脚本中,当我console.log
player
object 时,我看不到videoWidth
或videoHeight
作为播放器 object 的一部分。
let myOptions = {
controls: true,
autoplay: true,
logo: { enabled: false }
};
myPlayer = amp(video, myOptions, () => {
console.log(myPlayer);
});
myPlayer.src([{
src: "<manifestURL>",
type: "<type>"
}]);
The following screenshot is what gets logged.以下屏幕截图是记录的内容。 Unless I'm missing something, I don't see the videoWidth
or videoHeight
values.除非我遗漏了什么,否则我看不到videoWidth
或videoHeight
值。
Any assistance is greatly appreciated.非常感谢任何帮助。
Actually videoWidth/videoHeight are functions.实际上 videoWidth/videoHeight 是函数。
Also you should use the this
keyword inside the ready handler.此外,您应该在准备好的处理程序中使用this
关键字。
For example:例如:
amp(video, options, () => console.log(this.videoWidth())
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.