To determine whether the video is portrait or landscape, I am attempting to retrieve the height and width of the video using the following method:
import { Component, OnInit, AfterViewInit } from '@angular/core';
@Component({
selector: 'app-videoplayer',
template: `<video id="singleVideo">
<source src="/assets/videoname.mp4" type="video/mp4">
</video>`
})
export class VideoplayerComponent implements OnInit, AfterViewInit {
constructor() {}
ngOnInit() {
}
ngAfterViewInit() {
const videoElem: HTMLVideoElement = <HTMLVideoElement>document.getElementById('singleVideo');
const vidH = videoElem.videoHeight;
const vidW = videoElem.videoWidth;
console.log(vidH, vidW); // this returns: 0, 0
}
}
Despite my efforts in trying to obtain the video's height and width within the constructor, ngOnInit, and ngAfterViewInit functions, I consistently receive 0 values for both dimensions.