feat(portals): add option to hide external player info dialog

This commit is contained in:
4gray committed 2024-04-05 21:53:35 +02:00
1 parent f4069939df
commit ffdc68688c
4 files changed
+64 -22

No files matched your search

@@ -1,9 +1,11 @@
import { Component } from '@angular/core';
import { Component, inject } from '@angular/core';
import { MatButtonModule } from '@angular/material/button';
import { MatCheckboxModule } from '@angular/material/checkbox';
import { MatDialogModule } from '@angular/material/dialog';
import { MatIconModule } from '@angular/material/icon';
import { RouterLink } from '@angular/router';
import { TranslateModule } from '@ngx-translate/core';
import { PortalStore } from '../../../xtream/portal.store';
@Component({
standalone: true,
@@ -31,7 +33,12 @@ import { TranslateModule } from '@ngx-translate/core';
</div>
</div>
</mat-dialog-content>
<mat-dialog-actions align="end">
<mat-dialog-actions style="justify-content: space-between;">
<div>
<mat-checkbox (change)="setVisibility($event.checked)"
>Don't show anymore</mat-checkbox
>
</div>
<button mat-button mat-dialog-close cdkFocusInitial color="accent">
{{ 'CLOSE' | translate }}
</button>
@@ -54,6 +61,7 @@ import { TranslateModule } from '@ngx-translate/core';
],
imports: [
MatButtonModule,
MatCheckboxModule,
MatDialogModule,
MatIconModule,
RouterLink,
@@ -61,7 +69,12 @@ import { TranslateModule } from '@ngx-translate/core';
],
})
export class ExternalPlayerInfoDialogComponent {
portalStore = inject(PortalStore);
openUrl(url: string) {
window.open(url, '_blank');
}
setVisibility(value: boolean) {
this.portalStore.setHideExternalInfoDialog(value);
}
}
@@ -110,6 +110,8 @@ export class StalkerMainContainerComponent implements OnInit {
}, */
];
hideExternalInfoDialog = this.portalStore.hideExternalInfoDialog;
currentCategoryId;
//pagination
@@ -346,12 +348,11 @@ export class StalkerMainContainerComponent implements OnInit {
this.pageIndex = response.payload.js.cur_page;
} else if (response.action === StalkerPortalActions.CreateLink) {
let url = response.payload.js.cmd as string;
//url = url.replace('extension=ts', 'extension=m3u8');
if (url?.startsWith('ffmpeg')) {
url = url.split(' ')[1];
}
this.openPlayer(url, response.payload.js.name);
this.openPlayer(url);
} else if (response.action === StalkerPortalActions.Handshake) {
const token = response.payload.js.token;
sessionStorage.setItem(this.currentPlaylist()._id, token);
@@ -370,15 +371,17 @@ export class StalkerMainContainerComponent implements OnInit {
this.isLoading = false;
}
openPlayer(streamUrl: string, title: string) {
openPlayer(streamUrl: string) {
const player = this.settings().player;
if (player === VideoPlayer.MPV) {
this.dialog.open(ExternalPlayerInfoDialogComponent);
if (!this.hideExternalInfoDialog())
this.dialog.open(ExternalPlayerInfoDialogComponent);
this.dataService.sendIpcEvent(OPEN_MPV_PLAYER, {
url: streamUrl,
});
} else if (player === VideoPlayer.VLC) {
this.dialog.open(ExternalPlayerInfoDialogComponent);
if (!this.hideExternalInfoDialog())
this.dialog.open(ExternalPlayerInfoDialogComponent);
this.dataService.sendIpcEvent(OPEN_VLC_PLAYER, {
url: streamUrl,
});
@@ -388,10 +391,7 @@ export class StalkerMainContainerComponent implements OnInit {
{
data: {
streamUrl,
title:
title ??
this.itemDetails?.info?.name ??
this.itvTitle,
title: this.itvTitle,
},
width: '80%',
}
@@ -472,6 +472,7 @@ export class StalkerMainContainerComponent implements OnInit {
rating_kinopoisk: selectedContent.rating_kinopoisk,
},
};
this.itvTitle = item.name;
this.breadcrumbs.push({
title: this.itemDetails?.info?.name,
action: StalkerPortalActions.GetOrderedList,
@@ -488,6 +489,7 @@ export class StalkerMainContainerComponent implements OnInit {
name: string;
}) {
if (this.selectedContentType === ContentType.SERIES) {
this.itvTitle = item.name;
this.getSerialDetails(item);
return;
}
+17
View File
@@ -4,6 +4,7 @@ import { ComponentStore } from '@ngrx/component-store';
export interface PortalState {
searchPhrase: string;
content: any[];
hideExternalInfoDialog: boolean;
}
@Injectable({ providedIn: 'root' })
@@ -12,12 +13,18 @@ export class PortalStore extends ComponentStore<PortalState> {
super({
searchPhrase: '',
content: [],
hideExternalInfoDialog:
localStorage.getItem('hideExternalInfoDialog') === 'true',
});
}
// selectors
readonly searchPhrase = this.selectSignal((state) => state.searchPhrase);
readonly hideExternalInfoDialog = this.selectSignal(
(state) => state.hideExternalInfoDialog
);
readonly getContentById = (id: string) =>
this.selectSignal((state) => state.content.find((i) => i.id === id));
@@ -35,4 +42,14 @@ export class PortalStore extends ComponentStore<PortalState> {
content,
})
);
readonly setHideExternalInfoDialog = this.updater(
(state, hideExternalInfoDialog: boolean): PortalState => {
localStorage.setItem(
'hideExternalInfoDialog',
hideExternalInfoDialog.toString()
);
return { ...state, hideExternalInfoDialog };
}
);
}
@@ -142,6 +142,7 @@ export class XtreamMainContainerComponent implements OnInit {
storage = inject(StorageMap);
store = inject(Store);
translate = inject(TranslateService);
currentPlaylist = this.store.selectSignal(selectCurrentPlaylist);
navigationContentTypes: ContentTypeNavigationItem[] = [
{
@@ -178,6 +179,7 @@ export class XtreamMainContainerComponent implements OnInit {
errorViewInfo = { title: '', message: '' };
streamUrl: string;
epgItems = [];
hideExternalInfoDialog = this.portalStore.hideExternalInfoDialog;
commandsList = [
new IpcCommand(XTREAM_RESPONSE, (response: XtreamResponse) =>
@@ -302,9 +304,7 @@ export class XtreamMainContainerComponent implements OnInit {
this.currentLayout = 'category_content';
}
itemClicked(
item: any /* XtreamLiveStream | XtreamVodStream | XtreamSerieItem */
) {
itemClicked(item: any) {
let action;
if (item.stream_type && item.stream_type === 'movie') {
@@ -338,12 +338,14 @@ export class XtreamMainContainerComponent implements OnInit {
openPlayer(streamUrl: string, title: string) {
this.player = this.settings().player ?? VideoPlayer.VideoJs;
if (this.player === VideoPlayer.MPV) {
this.dialog.open(ExternalPlayerInfoDialogComponent);
if (!this.hideExternalInfoDialog())
this.dialog.open(ExternalPlayerInfoDialogComponent);
this.dataService.sendIpcEvent(OPEN_MPV_PLAYER, {
url: streamUrl,
});
} else if (this.player === VideoPlayer.VLC) {
this.dialog.open(ExternalPlayerInfoDialogComponent);
if (!this.hideExternalInfoDialog())
this.dialog.open(ExternalPlayerInfoDialogComponent);
this.dataService.sendIpcEvent(OPEN_VLC_PLAYER, {
url: streamUrl,
});
@@ -484,9 +486,13 @@ export class XtreamMainContainerComponent implements OnInit {
this.playlistService
.addPortalFavorite(this.currentPlaylist()._id, item)
.subscribe(() => {
this.snackBar.open('Added to favorites', null, {
duration: 1000,
});
this.snackBar.open(
this.translate.instant('PORTALS.ADDED_TO_FAVORITES'),
null,
{
duration: 1000,
}
);
});
}
@@ -494,9 +500,13 @@ export class XtreamMainContainerComponent implements OnInit {
this.playlistService
.removeFromPortalFavorites(this.currentPlaylist()._id, favoriteId)
.subscribe(() => {
this.snackBar.open('Removed from favorites', null, {
duration: 1000,
});
this.snackBar.open(
this.translate.instant('PORTALS.REMOVED_FROM_FAVORITES'),
null,
{
duration: 1000,
}
);
});
}