Video player
diff --git a/src/app/settings/settings.component.ts b/src/app/settings/settings.component.ts
index 15ecbd018..23e597274 100644
--- a/src/app/settings/settings.component.ts
+++ b/src/app/settings/settings.component.ts
@@ -3,11 +3,13 @@ import { FormGroup, FormBuilder } from '@angular/forms';
import { StorageMap } from '@ngx-pwa/local-storage';
import { Router } from '@angular/router';
import { MatSnackBar } from '@angular/material/snack-bar';
-import { Subscription } from 'rxjs';
+import { Observable, Subscription } from 'rxjs';
import { Settings } from './settings.interface';
import { HttpClient } from '@angular/common/http';
import * as semver from 'semver';
import { ElectronService } from 'app/services/electron.service';
+import { ChannelQuery } from 'app/state';
+import { EPG_FETCH } from 'app/shared/ipc-commands';
@Component({
selector: 'app-settings',
@@ -43,14 +45,23 @@ export class SettingsComponent implements OnInit, OnDestroy {
/** Update message to show */
updateMessage: string;
+ /** EPG availability flag */
+ epgAvailable$: Observable
= this.channelQuery.select(
+ (store) => store.epgAvailable
+ );
+
/**
* Creates an instance of SettingsComponent and injects some dependencies into the component
+ * @param channelQuery
+ * @param electronService
* @param formBuilder
+ * @param http
* @param router
* @param snackBar
* @param storage
*/
constructor(
+ private channelQuery: ChannelQuery,
private electronService: ElectronService,
private formBuilder: FormBuilder,
private http: HttpClient,
@@ -60,6 +71,7 @@ export class SettingsComponent implements OnInit, OnDestroy {
) {
this.settingsForm = this.formBuilder.group({
player: ['html5'], // default value
+ epgUrl: '',
});
this.subscription.add(
@@ -88,7 +100,10 @@ export class SettingsComponent implements OnInit, OnDestroy {
this.subscription.add(
this.storage.get('settings').subscribe((settings: Settings) => {
if (settings) {
- this.settingsForm.setValue(settings);
+ this.settingsForm.setValue({
+ player: settings.player ? settings.player : 'html5',
+ epgUrl: settings.epgUrl ? settings.epgUrl : '',
+ });
}
})
);
@@ -110,6 +125,10 @@ export class SettingsComponent implements OnInit, OnDestroy {
duration: 2000,
}
);
+ // check whether the epg url was changed or not
+ if (this.settingsForm.value.epgUrl) {
+ this.fetchEpg();
+ }
})
);
}
@@ -127,4 +146,17 @@ export class SettingsComponent implements OnInit, OnDestroy {
ngOnDestroy(): void {
this.subscription.unsubscribe();
}
+
+ /**
+ * Fetches and updates EPG from the given URL
+ */
+ fetchEpg(): void {
+ this.electronService.ipcRenderer.send(EPG_FETCH, {
+ url: this.settingsForm.value.epgUrl,
+ });
+ this.snackBar.open('Fetch EPG data...', 'Close', {
+ verticalPosition: 'bottom',
+ horizontalPosition: 'right',
+ });
+ }
}
diff --git a/src/app/settings/settings.interface.ts b/src/app/settings/settings.interface.ts
index 74a94b8c4..b954ce5a9 100644
--- a/src/app/settings/settings.interface.ts
+++ b/src/app/settings/settings.interface.ts
@@ -5,4 +5,5 @@ export type VideoPlayerType = 'html5' | 'videojs';
*/
export interface Settings {
player: VideoPlayerType;
+ epgUrl: string;
}
diff --git a/src/app/state/channel.store.ts b/src/app/state/channel.store.ts
index aff0450e3..4e939ad2c 100644
--- a/src/app/state/channel.store.ts
+++ b/src/app/state/channel.store.ts
@@ -1,12 +1,14 @@
import { Injectable } from '@angular/core';
import { EntityState, EntityStore, StoreConfig } from '@datorama/akita';
+import { EPG_GET_PROGRAM } from '../shared/ipc-commands';
import { ElectronService } from '../services/electron.service';
import { Channel } from './channel.model';
export interface ChannelState extends EntityState {
+ active: Channel;
+ epgAvailable: boolean;
favorites: string[];
playlistId: string;
- active: Channel;
}
@Injectable({ providedIn: 'root' })
@@ -14,13 +16,14 @@ export interface ChannelState extends EntityState {
export class ChannelStore extends EntityStore {
/**
* Creates an instance of ChannelStore
- * @param channelStore channels store
+ * @param electronService electron service
*/
constructor(private electronService: ElectronService) {
super({
+ active: undefined,
+ epgAvailable: false,
favorites: [],
playlistId: '',
- active: undefined,
});
}
@@ -45,4 +48,18 @@ export class ChannelStore extends EntityStore {
return { favorites };
});
}
+
+ /**
+ * Updates selected/active channel in store
+ * @param channel selected channel
+ */
+ setActiveChannel(channel: Channel): void {
+ this.update((store) => ({
+ ...store,
+ active: channel,
+ }));
+ this.electronService.ipcRenderer.send(EPG_GET_PROGRAM, {
+ channelName: channel.name,
+ });
+ }
}