This commit is contained in:
David Frassi
2026-06-18 14:38:04 +02:00
parent 2607c9c1a8
commit 333858bf48
4 changed files with 45 additions and 48 deletions
+10 -7
View File
@@ -396,7 +396,7 @@
</ion-content> </ion-content>
<ion-footer *ngIf="youtubePlayerService.isPlayerSupported() && youtubePlayerService.currentCantoId()" class="ion-no-border"> <ion-footer *ngIf="youtubePlayerService.currentCantoId()" class="ion-no-border">
<ion-toolbar class="global-player-toolbar glass"> <ion-toolbar class="global-player-toolbar glass">
<div class="player-content"> <div class="player-content">
@@ -405,7 +405,8 @@
<ion-icon slot="icon-only" name="chevron-back"></ion-icon> <ion-icon slot="icon-only" name="chevron-back"></ion-icon>
</ion-button> </ion-button>
<ion-button fill="clear" color="secondary" (click)="youtubePlayerService.togglePlayPause()" class="play-btn"> <ng-container *ngIf="youtubePlayerService.isPlayerSupported() && getPlayingCanto()?.link_youtube && getPlayingCanto()?.link_youtube!.length > 5; else noAudioMsg">
<ion-button fill="clear" color="secondary" (click)="togglePlayPause()" class="play-btn">
<ion-icon slot="icon-only" [name]="youtubePlayerService.isPlaying() ? 'pause-sharp' : 'play-sharp'"></ion-icon> <ion-icon slot="icon-only" [name]="youtubePlayerService.isPlaying() ? 'pause-sharp' : 'play-sharp'"></ion-icon>
</ion-button> </ion-button>
@@ -424,14 +425,16 @@
</ion-range> </ion-range>
<span class="player-time-label outfit-font" style="font-size: 0.85rem; color: var(--ion-color-secondary); opacity: 0.8; min-width: 38px; text-align: left; margin-right: 4px;">{{ formatSeconds(youtubePlayerService.videoDuration()) }}</span> <span class="player-time-label outfit-font" style="font-size: 0.85rem; color: var(--ion-color-secondary); opacity: 0.8; min-width: 38px; text-align: left; margin-right: 4px;">{{ formatSeconds(youtubePlayerService.videoDuration()) }}</span>
</ng-container>
<ng-template #noAudioMsg>
<div class="no-audio-msg outfit-font" style="flex: 1; text-align: center; font-size: 0.85rem; opacity: 0.6; color: var(--ion-color-medium);">
Audio non disponibile
</div>
</ng-template>
<ion-button fill="clear" color="secondary" (click)="playNextPreview($event)" class="skip-btn"> <ion-button fill="clear" color="secondary" (click)="playNextPreview($event)" class="skip-btn">
<ion-icon slot="icon-only" name="chevron-forward"></ion-icon> <ion-icon slot="icon-only" name="chevron-forward"></ion-icon>
</ion-button> </ion-button>
<ion-button fill="clear" color="medium" (click)="stopVideo($event)" class="close-btn">
<ion-icon slot="icon-only" name="close-circle-outline"></ion-icon>
</ion-button>
</div> </div>
</div> </div>
</ion-toolbar> </ion-toolbar>
@@ -457,7 +460,7 @@
<ion-button fill="clear" (click)="playPrevPreview($event)" class="car-mode-btn"> <ion-button fill="clear" (click)="playPrevPreview($event)" class="car-mode-btn">
<ion-icon slot="icon-only" name="play-skip-back-sharp"></ion-icon> <ion-icon slot="icon-only" name="play-skip-back-sharp"></ion-icon>
</ion-button> </ion-button>
<ion-button fill="clear" (click)="youtubePlayerService.isPlaying() ? stopVideo($event) : playVideo($event, youtubePlayerService.currentCantoId()!)" class="car-mode-btn"> <ion-button fill="clear" (click)="youtubePlayerService.isPlaying() ? pauseVideo($event) : playVideo($event, youtubePlayerService.currentCantoId()!)" class="car-mode-btn">
<ion-icon slot="icon-only" [name]="youtubePlayerService.isPlaying() ? 'pause-sharp' : 'play-sharp'"></ion-icon> <ion-icon slot="icon-only" [name]="youtubePlayerService.isPlaying() ? 'pause-sharp' : 'play-sharp'"></ion-icon>
</ion-button> </ion-button>
<ion-button fill="clear" (click)="playNextPreview($event)" class="car-mode-btn"> <ion-button fill="clear" (click)="playNextPreview($event)" class="car-mode-btn">
+16 -23
View File
@@ -44,7 +44,7 @@ export class HomePage implements OnDestroy {
this.playNextPreview(); this.playNextPreview();
event.preventDefault(); event.preventDefault();
} else if (event.key === 'MediaPlayPause') { } else if (event.key === 'MediaPlayPause') {
this.youtubePlayerService.togglePlayPause(); this.togglePlayPause();
event.preventDefault(); event.preventDefault();
} }
} }
@@ -517,13 +517,6 @@ export class HomePage implements OnDestroy {
} }
}); });
// Reset black screen dismissed state when play/pause changes
effect(() => {
const isPlaying = this.youtubePlayerService.isPlaying();
if (!isPlaying) {
this.isBlackOverlayDismissed.set(false);
}
}, { allowSignalWrites: true });
let queryParamsSubscribed = false; let queryParamsSubscribed = false;
effect(() => { effect(() => {
@@ -566,9 +559,6 @@ export class HomePage implements OnDestroy {
hasAutoActivatedPlaylist = true; hasAutoActivatedPlaylist = true;
this.selectPlaylist(lastPl); this.selectPlaylist(lastPl);
this.activeFilterType.set('playlist'); this.activeFilterType.set('playlist');
if (lastPl.ids && lastPl.ids.length > 0) {
this.goToCanto(lastPl.ids[0]);
}
} else { } else {
hasAutoActivatedPlaylist = true; hasAutoActivatedPlaylist = true;
} }
@@ -695,14 +685,10 @@ export class HomePage implements OnDestroy {
} }
} }
const openFirst = this.route.snapshot.queryParams['openFirst'] === '1';
if (this.playlistService.processImportJson(json)) { if (this.playlistService.processImportJson(json)) {
this.limit.set(50); // Mostra più canti inizialmente per le playlist speciali this.limit.set(50); // Mostra più canti inizialmente per le playlist speciali
this.activeFilterType.set('playlist'); this.activeFilterType.set('playlist');
await this.router.navigate([], { queryParams: { import: null, openFirst: null }, queryParamsHandling: 'merge', replaceUrl: true }); await this.router.navigate([], { queryParams: { import: null, openFirst: null }, queryParamsHandling: 'merge', replaceUrl: true });
if (openFirst && json.ids && json.ids.length > 0) {
this.goToCanto(json.ids[0]);
}
} }
} catch (e) { } catch (e) {
console.error('Failed to import playlist', e); console.error('Failed to import playlist', e);
@@ -910,11 +896,7 @@ export class HomePage implements OnDestroy {
await toast.present(); await toast.present();
if (selectedPl.ids && selectedPl.ids.length > 0) { if (selectedPl.ids && selectedPl.ids.length > 0) {
hasNavigatedToCanto = true;
await this.router.navigate([], { queryParams: { 'playlist-uid': null, 'playlist-id': null, 'openFirst': null }, queryParamsHandling: 'merge', replaceUrl: true }); await this.router.navigate([], { queryParams: { 'playlist-uid': null, 'playlist-id': null, 'openFirst': null }, queryParamsHandling: 'merge', replaceUrl: true });
if (openFirst) {
this.goToCanto(selectedPl.ids[0]);
}
} }
} else { } else {
throw new Error('Formato dati non valido.'); throw new Error('Formato dati non valido.');
@@ -1406,6 +1388,7 @@ export class HomePage implements OnDestroy {
if (!this.youtubePlayerService.isPlayerSupported()) { if (!this.youtubePlayerService.isPlayerSupported()) {
return; return;
} }
this.isBlackOverlayDismissed.set(false);
this.youtubePlayerService.setMediaSessionCallbacks( this.youtubePlayerService.setMediaSessionCallbacks(
() => this.playNextPreview(), () => this.playNextPreview(),
() => this.playPrevPreview() () => this.playPrevPreview()
@@ -1436,6 +1419,19 @@ export class HomePage implements OnDestroy {
this.playlistService.autoPlayPlaylist.set(false); this.playlistService.autoPlayPlaylist.set(false);
} }
pauseVideo(event: Event) {
if (event) event.stopPropagation();
this.youtubePlayerService.pause();
this.isBlackOverlayDismissed.set(true);
}
togglePlayPause() {
if (!this.youtubePlayerService.isPlaying()) {
this.isBlackOverlayDismissed.set(false);
}
this.youtubePlayerService.togglePlayPause();
}
playNextPreview(event?: Event) { playNextPreview(event?: Event) {
if (event) event.stopPropagation(); if (event) event.stopPropagation();
const currentId = this.youtubePlayerService.currentCantoId(); const currentId = this.youtubePlayerService.currentCantoId();
@@ -1655,11 +1651,8 @@ export class HomePage implements OnDestroy {
// Automatically save to the device! // Automatically save to the device!
this.playlistService.savePlaylist(playlistName, ids); this.playlistService.savePlaylist(playlistName, ids);
// Activate the playlist filter and open the first song! // Activate the playlist filter
this.activeFilterType.set('playlist'); this.activeFilterType.set('playlist');
if (ids.length > 0) {
this.goToCanto(ids[0]);
}
} }
} }
+3 -2
View File
@@ -50,8 +50,9 @@ export class YoutubePlayerService {
// Auto-stop player when not supported (e.g. going offline) // Auto-stop player when not supported (e.g. going offline)
effect(() => { effect(() => {
const supported = this.isPlayerSupported(); const supported = this.isPlayerSupported();
if (!supported && this.currentCantoId()) { if (!supported) {
this.stop(); this.isPlaying.set(false);
this.destroyPlayer();
} }
}); });
} }
+1 -1
View File
@@ -1 +1 @@
export const VERSION = '2026.06.18.1346'; export const VERSION = '2026.06.18.1434';