简体   繁体   English

从 Azure 媒体播放器获取视频宽度和高度

[英]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 似乎说我可以得到videoWidthvideoHeight 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 时,我看不到videoWidthvideoHeight作为播放器 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.除非我遗漏了什么,否则我看不到videoWidthvideoHeight值。

在此处输入图像描述

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.

相关问题 获取隐藏视频的高度和宽度 - get height and width of hidden video 当来源是IE / EDGE上的加密令牌视频时,Canvas无法从Azure Media Player中绘制Image - Canvas not drawImage from azure media player when source is encrypted token video on IE/EDGE 如何获取Instagram视频的视频高度和宽度? - How to get video height and width of Instagram video? Azure Media Player在浅灰色弹出窗口上的第二次单击时未播放视频 - Azure Media Player is not playing video on second click on lightgray popup Azure 媒体播放器 drm 保护 iPhone 中的视频问题 - Azure media player drm protected video issue in iPhone CSS | Javascript:像视频播放器一样缩放或信使,具有动态高度和宽度 - CSS | Javascript: Zoom or Messenger like Video Player with dynamic height and width 如何在HTML上的余辉播放器中设置视频高度/宽度 - how to set the video height/width in afterglow player on html 如何在Type Angular 2中获取视频的高度和宽度 - How to get height and width of the video in Angular 2, TypeScript 如何获取不包括背景的视频高度宽度 - How to get a video height width excluding the background 如何在 javascript 中获取 hls 视频宽度/高度? - How to get hls video width/height in javascript?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM