mat-video
mat-video copied to clipboard
Time event not working
PLEASE FILL THIS OUT IF YOU WANT HELP WITH AN ISSUE!
Bug, feature request, or proposal:
<mat-video #video [src]="src" title="My Tutorial Title" [(time)]="ctime" [autoplay]="true" [preload]="true" [download]="false" color="accent" spinner="spin">
TS:- ctime = 30;
What is the current behavior?
never stop on time given
What is the expected behavior?
Video need to be paused on selected time
What are the steps to reproduce?
Providing a StackBlitz reproduction is the best way to share your issue.
StackBlitz starter: https://goo.gl/wwnhMV
What is the use-case or motivation for changing an existing behavior?
Which versions of Angular, Material, OS, TypeScript, browsers are affected?
Is there anything else I should know?
For me, the time setting as an output does not work (ok for input). It also doesn't work in the demo.
But I found this great solution :
ngAfterViewInit(): void {
fromEvent(this.matVideo.getVideoTag(), 'timeupdate')
.pipe(
throttleTime(1000),
map(() => Math.round(this.matVideo.getVideoTag().currentTime)),
mergeMap(time => this.store.dispatch(new UpdateVideoViewTime(this.lesson._id, this.video._id, time))),
takeUntil(this.destroy$)
)
.subscribe();
}