你考虑监视
onend
事件以跟踪视频结束的时间,但就按钮隐藏部分而言,可以在视频开始时启用标志,在视频结束时启用标志
合一
事件已触发。
HTML格式
<video #videoplayer controls (ended)="videoEnd()" style="width: 1200px;">
<source
src="https://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ForBiggerEscapes.mp4"
type="video/mp4">
Your browser does not support HTML5 video.
</video>
组成部分
import { Component, ViewChild, ElementRef } from '@angular/core';
@Component({
selector: 'my-app',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
@ViewChild('videoplayer') videoplayer;
isEnded: boolean = false;
debugger
pauseVideo(event: any) {
this.videoplayer.nativeElement.pause();
}
playVideo(event: any) {
this.videoplayer.nativeElement.play();
this.isEnded = false
}
videoEnd(event: any) {
this.isEnded = false;
alert('Video Has Ended')
}
}
登记
onended
您可以使用的事件
#templateVariable
结合
ViewChild
或直接登记
合一
关于dom使用
(ended)="videoEnd($event)"
通过视频元素。
Demo Here