diff --git a/src/app/pages/video/video.component.html b/src/app/pages/video/video.component.html
index 04fac08..d127ed9 100755
--- a/src/app/pages/video/video.component.html
+++ b/src/app/pages/video/video.component.html
@@ -21,6 +21,7 @@
{{ video.title }}
+
-
+
diff --git a/src/app/pages/video/video.component.ts b/src/app/pages/video/video.component.ts
index 4f2da36..c6bf924 100755
--- a/src/app/pages/video/video.component.ts
+++ b/src/app/pages/video/video.component.ts
@@ -21,6 +21,7 @@ export class VideoComponent implements OnInit {
user: any;
favoriteMessage: string | null = null; // Armazena a mensagem
eduplayVideoUrl = "https://eduplay.rnp.br/portal/video/embed/";
+ isWatchLater = true;
constructor(
private videoService: VideoService,
@@ -115,7 +116,6 @@ export class VideoComponent implements OnInit {
}
}
-
checkFavoriteStatus(): void {
this.videoService.checkFavorite(this.idVideo.toString(), this.userId.toString()).subscribe({
next: (response) => {
@@ -133,10 +133,55 @@ export class VideoComponent implements OnInit {
alert(message); // Exemplo de alert, mas você pode customizar com mensagens na tela
}
+ // Assistir mais tarde
+ toggleWatchLater(video: IVideo): void {
+ const videoId = video.id ?? 0;
+
+ video.isWatchLater = !video.isWatchLater;
+
+ if (video.isWatchLater) {
+ this.videoService.addToWatchLater(videoId.toString(), this.userId.toString()).subscribe({
+ next: () => {
+ this.alertService.showMessage("success", "Sucesso", "Vídeo adicionado à lista de Assistir Mais tarde");
+ },
+ error: (err) => {
+ console.error('Error adding to watch later', err);
+ this.alertService.showMessage('error', 'Erro', 'Erro ao adicionar o vídeo para assistir mais tarde')
+ }
+ });
+ } else {
+ this.videoService.removeFromWatchLater(videoId.toString(), this.userId.toString()).subscribe({
+ next: () => {
+ this.alertService.showMessage("success", "Sucesso", "Vídeo removido da lista de Assistir mais tarde.");
+ },
+ error: (err) => {
+ console.error('Error removing from watch later', err);
+ this.alertService.showMessage('error', 'Erro', 'Erro ao remover o vídeo da lista de assistir mais tarde')
+ }
+ });
+ }
+ }
+
+ checkWatchLaterStatus(): void {
+ this.videoService.checkWatchLater(this.idVideo.toString(), this.userId.toString()).subscribe({
+ next: (response) => {
+ this.isWatchLater = response.status; // Acessa a propriedade status do objeto response
+ },
+ error: (err) => {
+ console.error('Error checking watch later status', err);
+ }
+ });
+ }
+
+ showWatchLaterMessage(isWatchLater: boolean): void {
+ const message = isWatchLater ? 'Vídeo salvo a lista!' : 'Vídeo removido da lista!';
+ this.favoriteMessage = message; // Armazena a mensagem na variável
+ alert(message); // Exemplo de alert, mas você pode customizar com mensagens na tela
+ }
+
returnToCatalog(): void {
this.router.navigate(['/catalog']);
}
-
// Função que retorna a URL do vídeo
getVideoUrl(): string {
return `${this.eduplayVideoUrl}${this.idVideo}`;
diff --git a/src/shared/model/video.model.ts b/src/shared/model/video.model.ts
index 7e87d60..5d59d93 100755
--- a/src/shared/model/video.model.ts
+++ b/src/shared/model/video.model.ts
@@ -17,6 +17,7 @@ export interface IVideo {
channels?: IChannel[];
catalog?: any;
isFavorited?: boolean; // Adiciona a propriedade isFavorited
+ isWatchLater?: boolean;
}
export class Video implements IVideo {
@@ -35,6 +36,7 @@ export class Video implements IVideo {
public embed?: string,
public channels?: IChannel[],
public catalog?: any,
- public isFavorited?: boolean
+ public isFavorited?: boolean,
+ public isWatchLater?: boolean
) {}
}