【发布时间】:2019-12-22 19:19:03
【问题描述】:
我想用 范围输入 控制我的视频,问题是当我将 video.currentTime 设置为 2(例如)时,它仍然始终停留在 0 上,并且该值永远不会改变.
这是我的 angular 7 代码:
index.component.html
<video *ngIf="product?.video"
id="myVideo"
width="100%"
height="100%"
#myVideo
(loadedmetadata)="onMetadata($event, myVideo)"
(loadeddata)="pauseVideo(myVideo)"
>
<source [src]="serverUrl+product.video.file" type="video/mp4">
Votre navigateur ne supporte pas le plugin des vidéos.
</video>
...
...
<input class="range-slider__range" #slider type="range" value="0" min="0" step="1" [max]="maxDuration"
(input)="updateVideo(slider.value)"
>
index.component.ts
@ViewChild('myVideo') my3DVideo: ElementRef;
maxDuration = 0;
..
..
pauseVideo(myVideo) {
console.log("data loaded.");
myVideo.currentTime = 3; // i used this line to force juming to second 3 but it still always 0
myVideo.pause();
console.log(myVideo.currentTime);
}
updateVideo(value: any) {
console.log("sliding..");
const video = this.my3DVideo.nativeElement;// as HTMLVideoElement;
video.currentTime = value; // this value is never changes too and it still always 0
}
onMetadata($event, my3DVideo) {
this.maxDuration = my3DVideo.duration;
}
此外,我尝试用可用的远程 mp4 视频替换 url,它可以工作,但在 localmachine 中它不起作用。 另一种尝试,是我在 firefox 上尝试了这段代码,它的工作原理很吸引人,但在 chrome 中却没有。
我搜索了很多关于这个主题但我仍然没有找到任何解决方案,我希望你能帮助我。 提前谢谢你。
【问题讨论】:
标签: html angular angular7 webapi