Im trying to get video duration from my videos that i listed in a table. I tried to access it using @ViewChildren and was successful until one part. i get the query list but when i try accessing _results it returns undefined. Later I learned that queryList was private for some reason. Any help will be appreciated
Here is my code:
<video id="video1" #video>
<source src = "{{videos.link}}" type="video/mp4">
</video>
@ViewChildren('video') video;
ngOnInit: {
Observable.timer(1000,1000).subscribe(() => {
if(this.video && !this.isVideoLogged){
console.log(this.video);
this.isVideoLogged = true;
}
}
You can use the loadedmetadata
event:
<video width="480" controls #video (loadedmetadata)="onMetadata($event, video)"
onMetadata(e, video) {
console.log('metadata: ', e);
console.log('duration: ', this.duration = video.duration);
}