angular - 如何从angular2中的函数调用视频暂停事件

标签 angular events video typescript

这是我的player.component.html

<video width="320" height="240" autoplay autobuffer [src]="videoSrc" (ended)="videoEnd()">
Your browser does not support the video tag.
</video>

<button (click)="pauseOrPlay()">pause/play</button>

在我的player.component.ts中,我有以下函数,当视频结束或单击按钮时调用

videoEnd(event) {
   console.log("video ended");
}

pauseOrPlay(event){
    console.log("button clicked");
    //pause or resume video here
}

我现在想要的是,当单击按钮时,暂停或恢复视频。我可以使用 vid.play() 或 vid.pause() 在 javascript 中执行此操作,但我找不到在 angular2 中执行此操作的方法。如有任何建议,我们将不胜感激。

最佳答案

也许您可以在 video 标记内存储一个 localvariable 并将其传递给暂停函数。

<video #video> </video>

<button (click)="pauseOrPlay(video)">pause/play</button>

pauseOrPlay(video){
    video.pause();
}

关于angular - 如何从angular2中的函数调用视频暂停事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41877688/

相关文章:

javascript - Angular 2 typescript 引用路径

javascript - package.json 的开放式对等版本依赖关系?

angular - Angular 7 的简单 ModalService 打不开 : No component factory found for

jquery - 如何在没有JQuery的情况下模仿跨浏览器$(document).ready()行为

c# - 与 Console.ReadLine() 相关的 RabbitMQ BasicConsume 和事件驱动问题

flash - as3 事件 - 类型强制失败?

video - 计算视频视频的比特率

javascript - 使用 MeteorJS Collection 和 Angular 2 显示数据

android - 有没有办法访问视频的像素?

video - 使用 ffmpeg 自动将视频分割成四分之一和堆叠