feat: simple remote control support on http

This commit is contained in:
Serkan committed 2024-10-09 18:21:53 +03:00
1 parent 5a4cdd848f
commit d6a07cc0cd
14 files changed
+146 -19

No files matched your search

@@ -36,6 +36,7 @@
[player]="player"
[streamUrl]="streamUrl"
[epgItems]="epgItems"
[activeLiveStream]="activeLiveStream"
(itemClicked)="itemClicked($event)"
/>
} @else {
@@ -21,6 +21,7 @@ import { MatSnackBar } from '@angular/material/snack-bar';
import { Store } from '@ngrx/store';
import { IpcCommand } from '../../../shared/ipc-command.class';
import {
REMOTE_CONTROL_CHANGE_CHANNEL,
ERROR,
OPEN_MPV_PLAYER,
OPEN_VLC_PLAYER,
@@ -183,6 +184,7 @@ export class XtreamMainContainerComponent implements OnInit {
streamUrl: string;
epgItems = [];
hideExternalInfoDialog = this.portalStore.hideExternalInfoDialog;
activeLiveStream: XtreamLiveStream;
commandsList = [
new IpcCommand(XTREAM_RESPONSE, (response: XtreamResponse) =>
@@ -191,6 +193,9 @@ export class XtreamMainContainerComponent implements OnInit {
new IpcCommand(ERROR, (response: { message: string; status: number }) =>
this.showErrorAsNotification(response)
),
new IpcCommand(REMOTE_CONTROL_CHANGE_CHANNEL, (response: { type: 'up' | 'down' }) => {
this.remoteControlChangeChannel(response.type);
})
];
constructor() {
@@ -345,6 +350,7 @@ export class XtreamMainContainerComponent implements OnInit {
playLiveStream(item: XtreamLiveStream) {
const { serverUrl, username, password } = this.currentPlaylist();
const streamUrl = `${serverUrl}/${item.stream_type}/${username}/${password}/${item.stream_id}.m3u8`;
this.activeLiveStream = item;
this.openPlayer(streamUrl, item.name);
}
@@ -530,4 +536,22 @@ export class XtreamMainContainerComponent implements OnInit {
this.currentLayout = 'favorites';
this.setInitialBreadcrumb();
}
remoteControlChangeChannel(type: 'up' | 'down') {
if (this.currentLayout === 'category_content' && this.activeLiveStream) {
let nextItem;
const index = this.activeLiveStream.num - 1;
if (type === 'up') {
if (index - 1 >= 0) {
nextItem = this.items[index - 1];
}
} else if (type === 'down') {
const index = this.activeLiveStream.num - 1;
if (index + 1 < this.items.length) {
nextItem = this.items[index + 1];
}
}
this.itemClicked(nextItem);
}
}
}