From c2459f3dcc6127721a56c4636fbcbb895c7de113 Mon Sep 17 00:00:00 2001 From: 4gray Date: Mon, 27 Jan 2025 08:57:05 +0100 Subject: [PATCH] feat(player): enhance video player IPC events with origin and referrer support --- .../html-video-player.component.ts | 1 + src/app/services/tauri.service.ts | 23 +++++++++------- src/app/state/effects.ts | 27 ++++++++++++------- 3 files changed, 33 insertions(+), 18 deletions(-) diff --git a/src/app/player/components/html-video-player/html-video-player.component.ts b/src/app/player/components/html-video-player/html-video-player.component.ts index d32dda43f..6cd8dbd21 100644 --- a/src/app/player/components/html-video-player/html-video-player.component.ts +++ b/src/app/player/components/html-video-player/html-video-player.component.ts @@ -81,6 +81,7 @@ export class HtmlVideoPlayerComponent implements OnInit, OnChanges, OnDestroy { .sendIpcEvent(CHANNEL_SET_USER_AGENT, { userAgent: channel.http?.['user-agent'] ?? '', referer: channel.http?.referrer ?? '', + origin: channel.http?.origin ?? '', }) .then(() => { if ( diff --git a/src/app/services/tauri.service.ts b/src/app/services/tauri.service.ts index 79bc0bbe2..19fe9368b 100644 --- a/src/app/services/tauri.service.ts +++ b/src/app/services/tauri.service.ts @@ -46,14 +46,15 @@ export class TauriService extends DataService { } ); } else if (type === 'OPEN_MPV_PLAYER') { + const data = payload as any; return invoke('open_in_mpv', { - url: (payload as any).url, - path: (payload as any).mpvPlayerPath || '', - title: (payload as any).title ?? '', - thumbnail: (payload as any).thumbnail ?? '', - userAgent: (payload as any).http?.['user-agent'] ?? '', - referer: (payload as any).http?.referrer ?? '', - origin: (payload as any).http?.origin ?? '', + url: data.url, + path: data.mpvPlayerPath || '', + title: data.title ?? '', + thumbnail: data.thumbnail ?? '', + userAgent: data['user-agent'] ?? undefined, + referer: data.referer ?? undefined, + origin: data.origin ?? undefined, }).catch((error) => { window.postMessage({ type: ERROR, @@ -62,9 +63,13 @@ export class TauriService extends DataService { throw error; }); } else if (type === 'OPEN_VLC_PLAYER') { + const data = payload as any; return invoke('open_in_vlc', { - url: (payload as any).url, - path: (payload as any).vlcPlayerPath || '', + url: data.url, + path: data.vlcPlayerPath || '', + userAgent: data['user-agent'] ?? undefined, + referer: data.referer ?? undefined, + origin: data.origin ?? undefined, }).catch((error) => { window.postMessage({ type: ERROR, diff --git a/src/app/state/effects.ts b/src/app/state/effects.ts index b67422ffa..84ccb6dee 100644 --- a/src/app/state/effects.ts +++ b/src/app/state/effects.ts @@ -32,7 +32,6 @@ import { selectActivePlaylistId, selectChannels, selectFavorites, - selectIsEpgAvailable, } from './selectors'; @Injectable({ providedIn: 'any' }) @@ -47,7 +46,14 @@ export class PlaylistEffects { ), switchMap(([, favorites, playlistId]) => this.playlistsService.updateFavorites(playlistId, favorites) - ) + ), + tap(() => { + this.snackBar.open( + this.translate.instant('CHANNELS.FAVORITES_UPDATED'), + null, + { duration: 2000 } + ); + }) ); }, { dispatch: false } @@ -112,18 +118,16 @@ export class PlaylistEffects { setActiveChannel$ = createEffect(() => { return this.actions$.pipe( ofType(PlaylistActions.setActiveChannel), - combineLatestWith(this.store.select(selectIsEpgAvailable)), - map(([action, isEpgAvailable]) => { + map((action) => { const { channel } = action; - if (isEpgAvailable) { - this.dataService.sendIpcEvent(EPG_GET_PROGRAM, { - channel, - }); - } + this.dataService.sendIpcEvent(EPG_GET_PROGRAM, { + channel, + }); if (channel.http['user-agent']) { this.dataService.sendIpcEvent(CHANNEL_SET_USER_AGENT, { referer: channel.http.referrer, userAgent: channel.http['user-agent'], + origin: channel.http.origin, }); } @@ -137,6 +141,10 @@ export class PlaylistEffects { ) { this.dataService.sendIpcEvent(OPEN_MPV_PLAYER, { url: channel.url, + mpvPlayerPath: settings?.mpvPlayerPath, + referer: channel.http.referrer, + userAgent: channel.http['user-agent'], + origin: channel.http.origin, }); } else if ( settings && @@ -146,6 +154,7 @@ export class PlaylistEffects { ) this.dataService.sendIpcEvent(OPEN_VLC_PLAYER, { url: channel.url, + vlcPlayerPath: settings?.vlcPlayerPath, }); } );