mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-20 13:26:08 +00:00
edit actions and video stop
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { NavigationEnd, Router } from '@angular/router';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class StopvideoService {
|
||||
|
||||
video: HTMLVideoElement[] = []
|
||||
|
||||
constructor(
|
||||
private router: Router
|
||||
) {
|
||||
|
||||
this.router.events.forEach((event) => {
|
||||
if (event instanceof NavigationEnd && !event.url.includes('/home/publications')) {
|
||||
this.stopAndRemoveAllVideos();
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
registerVideo(tagVideo: HTMLVideoElement) {
|
||||
this.video.push(tagVideo);
|
||||
}
|
||||
|
||||
stopAndRemoveAllVideos() {
|
||||
for (let i = 0; i < this.video.length; i++) {
|
||||
const video = this.video[i];
|
||||
|
||||
// Pause the video
|
||||
video.pause();
|
||||
|
||||
// Optionally, you can also reset the current time to start from the beginning
|
||||
video.currentTime = 0;
|
||||
|
||||
// Remove the video from the array
|
||||
this.video.splice(i, 1);
|
||||
|
||||
// Decrement the index to properly continue the loop
|
||||
i--;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user