Refactor: Restringimento drag & drop, legenda impostazioni, modalità offline e rimozione sezione liturgia
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
import { Injectable, signal, effect, inject } from '@angular/core';
|
||||
import { Injectable, signal, effect, inject, computed } from '@angular/core';
|
||||
import { CantiService } from './canti.service';
|
||||
import { SettingsService } from './settings.service';
|
||||
import { MediaSessionService } from './media-session.service';
|
||||
import { MyCantiService } from './my-canti.service';
|
||||
import { ConnectivityService } from './connectivity.service';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
@@ -12,6 +13,21 @@ export class YoutubePlayerService {
|
||||
private settingsService = inject(SettingsService);
|
||||
private mediaSessionService = inject(MediaSessionService);
|
||||
private myCantiService = inject(MyCantiService);
|
||||
private connectivityService = inject(ConnectivityService);
|
||||
|
||||
public isPlayerSupported = computed<boolean>(() => {
|
||||
// Check if offline
|
||||
if (!this.connectivityService.isOnline()) {
|
||||
return false;
|
||||
}
|
||||
// Check if iPhone/iPad/iPod
|
||||
const userAgent = window.navigator.userAgent.toLowerCase();
|
||||
const isIOS = /iphone|ipad|ipod/.test(userAgent);
|
||||
if (isIOS) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
|
||||
public currentCantoId = signal<string | null>(null);
|
||||
public isPlaying = signal<boolean>(false);
|
||||
@@ -32,6 +48,14 @@ export class YoutubePlayerService {
|
||||
this.setupMediaSession();
|
||||
this.initSilentAudio();
|
||||
this.setupBackgroundPersistence();
|
||||
|
||||
// Auto-stop player when not supported (e.g. going offline)
|
||||
effect(() => {
|
||||
const supported = this.isPlayerSupported();
|
||||
if (!supported && this.currentCantoId()) {
|
||||
this.stop();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private initSilentAudio() {
|
||||
|
||||
Reference in New Issue
Block a user