edit actions and video stop

This commit is contained in:
Peter Maquiran
2023-12-13 16:44:29 +01:00
parent 5e8c4187fa
commit d2c1e100cc
13 changed files with 251 additions and 19 deletions
+45
View File
@@ -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--;
}
}
}