angular - 使用 HTMLVideoElement 时如何暂停视频
问题描述
这是我的html代码
<mat-carousel timings="250ms ease-in" [autoplay]="false" interval="5000" color="accent" maxWidth="93%"
proportion="80" slides="3" [loop]="true" [hideArrows]="false" [hideIndicators]="false" [useKeyboard]="true"
[useMouseWheel]="false" orientation="ltr" (change)="currentSlideIndex = $event">
<mat-carousel-slide #matCarouselSlide *ngFor="let slide of video; let i = index"
overlayColor="#00000040" [hideOverlay]="false">
<video controls class="videostyle" #videoPlayer id='myvideoelement'>
<source *ngIf="slide.Video" src="{{slide?.Video}}" type="video/mp4">
Browser not supported
</video>
<button (click)="toggleVideo(videoPlayer)">Play/Pause</button>
</mat-carousel-slide>
<br>
</mat-carousel>
<button (click)="toggleVideo1($event)">bydiv</button>
在 ts 我有这个功能:
toggleVideo(videoplayer) {
console.log(videoplayer)
videoplayer.pause();
}
toggleVideo1(e) {
let video = <HTMLVideoElement>document.getElementById('myvideoelement');
video.pause();
}
从这两个功能我得到相同的控制台,但只toggleVideo(videoplayer)
暂停视频。
请你能与我分享任何想法,谁有问题?如何使它工作 toggleVideo1(e)
解决方案
推荐阅读
- android - 如何按颜色填充网格单元格
- azure-language-understanding - 文字/同义词推荐api
- python - 如何在python中使用openpyxl将if函数中的值插入到数组中?
- php - php把一天分成多少次?
- twitter-bootstrap - 修改列表框的引导多选插件
- sql - 对于部门中超过 5 个 emp 的部门,如何列出部门中的 emp 数量
- c++ - C++ sd-bus 源文件编译问题
- python - 在具有多个值的python中的workfront api中使用'in'修饰符
- npm - NPM 和 YARN 未安装 packgaes
- sql - PostgreSQL 截断现有字段并更改以添加字符限制