nkoehler / mat-video

:tv: mat-video is an Angular 8/9+ video player using Material!
https://nkoehler.github.io/mat-video/
MIT License
91 stars 47 forks source link

Expose Video duration #40

Open Nemolo opened 4 years ago

Nemolo commented 4 years ago

Feature request:

Expose video duration if relevant (not on streamed video)

What is the current behavior?

it is only possible to seek to a certain time, but not to know the video length.

What is the expected behavior?

To have some access to know the video duration.

What are the steps to reproduce?

N/A

What is the use-case or motivation for changing an existing behavior?

In case of a playlist i want to switch to the next video as soon as the current one finishes.

Which versions of Angular, Material, OS, TypeScript, browsers are affected?

Angular 8.2 Material 8.2 Windows 10 Typescript 3.5.3

Is there anything else I should know?

...

nkoehler commented 4 years ago

Would something like this work in the meantime? Change the video when the ended event has triggered.

export class SampleComponent implements OnInit {
  @ViewChild('video') matVideo: MatVideoComponent;
  video: HTMLVideoElement;

  constructor(private renderer: Renderer2) { }

  ngOnInit(): void {
    this.video = this.matVideo.getVideoTag();

    // Use Angular renderer or addEventListener to listen for standard HTML5 video events

    this.renderer.listen(this.video, 'ended', () => console.log('video ended'));
    this.video.addEventListener('ended', () => console.log('video ended'));
  }
}
Nemolo commented 4 years ago

yes this could do, however i still think that exposing the full length of the video could be useful. Thanks!