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

gue*_*est 2 video events typescript angular

这是我的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>
Run Code Online (Sandbox Code Playgroud)

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

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

pauseOrPlay(event){
    console.log("button clicked");
    //pause or resume video here
}
Run Code Online (Sandbox Code Playgroud)

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

Pri*_*mal 5

localvariable也许您可以在标签内存储 avideo并将其传递给暂停函数。

<video #video> </video>

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

pauseOrPlay(video){
    video.pause();
}
Run Code Online (Sandbox Code Playgroud)