My intention is to provide a brief explanation of the functionality I am looking for. Essentially, when a video is playing, I want it to pause if a user clicks on it, allowing them to do something else. Then, after 30 seconds of idle time, I need the video to automatically resume.
To achieve this, I have utilized basic JavaScript's setTimeout
functionality. You can see the code snippet below:
@HostListener('window:click', ['$event'])
onClick: (event) => {
// stop the video
this.activity = setTimeout(() => { /* resume */ } , 30000)
}
@HostListener('window:mousemove', ['$event'])
onMouseMove: (event) => {
clearTimeout(this.activity)
this.activity = setTimeout(() => { /* resume */ } , 30000)
}
Any suggestions on how this could be accomplished using the RxJs
approach?