Reputation: 25
This is my 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>
and in my player.component.ts i have following functions that are called when video ends, or when button is clicked
videoEnd(event) {
console.log("video ended");
}
pauseOrPlay(event){
console.log("button clicked");
//pause or resume video here
}
What i want now is, when the button is clicked, to pause or resume the video. i can do this in javascript using vid.play() or vid.pause() but i can't find a way to do this in angular2. Any suggestions would be appreciated.
Upvotes: 2
Views: 4152
Reputation: 2989
maybe you can store a localvariable
inside the video
tag and pass that to pause function.
<video #video> </video>
<button (click)="pauseOrPlay(video)">pause/play</button>
pauseOrPlay(video){
video.pause();
}
Upvotes: 6