Merge pull request 'push-tlnqyqsrywyr' (#53) from push-tlnqyqsrywyr into main
Some checks failed
Build and Push Docker Image / build (push) Failing after 4m55s
Some checks failed
Build and Push Docker Image / build (push) Failing after 4m55s
Reviewed-on: #53
This commit was merged in pull request #53.
This commit is contained in:
@@ -3,8 +3,7 @@ name: Build and Push Docker Image
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main # Changez cela si votre branche principale a un autre nom
|
||||
|
||||
- main # Changez cela si votre branche principale a un autre nom
|
||||
|
||||
jobs:
|
||||
build:
|
||||
@@ -15,7 +14,13 @@ jobs:
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: ~/.npm
|
||||
key: dont-cache-${{ github.run_id }}
|
||||
key: dont-cache-${{ github.run_id }}
|
||||
|
||||
- name: Extract version from Cargo.toml
|
||||
run: |
|
||||
grep '^version = ' PMOMusic/Cargo.toml | head -n 1 | sed 's/version = "\(.*\)"/\1/' > version.txt
|
||||
echo "Version extracted: $(cat version.txt)"
|
||||
|
||||
- name: Build and push image
|
||||
uses: https://gargoton.petite-maison-orange.fr/pmo-actions/build-push-image@main
|
||||
with:
|
||||
@@ -24,6 +29,3 @@ jobs:
|
||||
no_cache: true
|
||||
version_file: version.txt
|
||||
check_uuid: 82a30d23-b3bd-4199-9237-776965831d20
|
||||
|
||||
|
||||
|
||||
2
Cargo.lock
generated
2
Cargo.lock
generated
@@ -4,7 +4,7 @@ version = 4
|
||||
|
||||
[[package]]
|
||||
name = "PMOMusic"
|
||||
version = "0.1.0"
|
||||
version = "0.3.1"
|
||||
dependencies = [
|
||||
"axum 0.8.7",
|
||||
"console-subscriber",
|
||||
|
||||
37
Makefile
37
Makefile
@@ -13,6 +13,7 @@ BINARY_NAME = PMOMusic
|
||||
# Couleurs pour l'affichage
|
||||
GREEN = \033[0;32m
|
||||
YELLOW = \033[1;33m
|
||||
BLUE = \033[1;34m
|
||||
RED = \033[0;31m
|
||||
NC = \033[0m # No Color
|
||||
|
||||
@@ -193,6 +194,21 @@ update:
|
||||
cd $(WEBAPP_DIR) && $(NPM) update
|
||||
@echo "$(GREEN)✓ Dépendances mises à jour$(NC)"
|
||||
|
||||
## bump-version: Incrémente le numéro de version patch (x.y.z -> x.y.z+1)
|
||||
bump-version:
|
||||
@echo "$(YELLOW)→ Incrémentation de la version...$(NC)"
|
||||
@current=$$(grep '^version = ' PMOMusic/Cargo.toml | head -n 1 | sed 's/version = "\(.*\)"/\1/'); \
|
||||
echo " Version actuelle: $$current"; \
|
||||
major=$$(echo $$current | cut -d. -f1); \
|
||||
minor=$$(echo $$current | cut -d. -f2); \
|
||||
patch=$$(echo $$current | cut -d. -f3); \
|
||||
new_patch=$$((patch + 1)); \
|
||||
new_version="$$major.$$minor.$$new_patch"; \
|
||||
echo " Nouvelle version: $$new_version"; \
|
||||
sed -i.bak "s/^version = \"$$current\"/version = \"$$new_version\"/" PMOMusic/Cargo.toml && \
|
||||
rm PMOMusic/Cargo.toml.bak
|
||||
@echo "$(GREEN)✓ Version mise à jour dans PMOMusic/Cargo.toml$(NC)"
|
||||
|
||||
## bench: Exécute les benchmarks
|
||||
bench:
|
||||
@echo "$(YELLOW)→ Exécution des benchmarks...$(NC)"
|
||||
@@ -203,4 +219,23 @@ coverage:
|
||||
@echo "$(YELLOW)→ Génération du rapport de couverture...$(NC)"
|
||||
$(CARGO) tarpaulin --out Html --output-dir target/coverage
|
||||
@echo "$(GREEN)✓ Rapport disponible dans target/coverage/index.html$(NC)"
|
||||
|
||||
|
||||
jjnew:
|
||||
@echo "$(YELLOW)→ Création d'un nouveau commit...$(NC)"
|
||||
@echo "$(BLUE)→ Documentation du commit courrant...$(NC)"
|
||||
@jj auto-describe
|
||||
@echo "$(BLUE)→ C'est fait.$(NC)"
|
||||
@jj new
|
||||
@echo "$(GREEN)✓ nouveau commit créé$(NC)"
|
||||
|
||||
jjpush: bump-version
|
||||
@echo "$(YELLOW)→ Push du commit sur le dépôt...$(NC)"
|
||||
@jj auto-describe
|
||||
@jj git push --change @
|
||||
@echo "$(GREEN)✓ Commit pushé sur le dépôt$(NC)"
|
||||
|
||||
jjfetch:
|
||||
@echo "$(YELLOW)→ Pull des derniers commits...$(NC)"
|
||||
@jj git fetch
|
||||
@jj new main@origin
|
||||
@echo "$(GREEN)✓ Derniers commits pullés$(NC)"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "PMOMusic"
|
||||
version = "0.1.0"
|
||||
version = "0.3.1"
|
||||
edition = "2024"
|
||||
|
||||
[dependencies]
|
||||
|
||||
@@ -1,62 +1,58 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, ref, watch } from 'vue'
|
||||
import { useMediaServers } from '@/composables/useMediaServers'
|
||||
import { useRenderers } from '@/composables/useRenderers'
|
||||
import { useUIStore } from '@/stores/ui'
|
||||
import Breadcrumb from './Breadcrumb.vue'
|
||||
import ContainerItem from './ContainerItem.vue'
|
||||
import MediaItem from './MediaItem.vue'
|
||||
import { Loader2 } from 'lucide-vue-next'
|
||||
import { computed, ref, watch } from "vue";
|
||||
import { useMediaServers } from "@/composables/useMediaServers";
|
||||
import { useRenderers } from "@/composables/useRenderers";
|
||||
import { useUIStore } from "@/stores/ui";
|
||||
import Breadcrumb from "./Breadcrumb.vue";
|
||||
import ContainerItem from "./ContainerItem.vue";
|
||||
import MediaItem from "./MediaItem.vue";
|
||||
import { Loader2 } from "lucide-vue-next";
|
||||
|
||||
const props = defineProps<{
|
||||
serverId: string
|
||||
containerId: string
|
||||
}>()
|
||||
serverId: string;
|
||||
containerId: string;
|
||||
}>();
|
||||
|
||||
const {
|
||||
getBrowseCached,
|
||||
browseContainer,
|
||||
currentPath: breadcrumbPath,
|
||||
loading,
|
||||
error
|
||||
} = useMediaServers()
|
||||
getBrowseCached,
|
||||
browseContainer,
|
||||
currentPath: breadcrumbPath,
|
||||
loading,
|
||||
error,
|
||||
} = useMediaServers();
|
||||
|
||||
const {
|
||||
playContent,
|
||||
addToQueue,
|
||||
attachAndPlayPlaylist,
|
||||
attachPlaylist,
|
||||
} = useRenderers()
|
||||
const uiStore = useUIStore()
|
||||
const { playContent, addToQueue, attachAndPlayPlaylist, attachPlaylist } =
|
||||
useRenderers();
|
||||
const uiStore = useUIStore();
|
||||
|
||||
// Flags pour gérer le rechargement automatique avec debounce et cooldown
|
||||
const isRefreshing = ref(false)
|
||||
const refreshTimeoutId = ref<number | null>(null)
|
||||
const lastRefreshTime = ref<number>(0)
|
||||
const REFRESH_COOLDOWN_MS = 5000 // Ne pas recharger plus d'une fois toutes les 5 secondes
|
||||
const isRefreshing = ref(false);
|
||||
const refreshTimeoutId = ref<number | null>(null);
|
||||
const lastRefreshTime = ref<number>(0);
|
||||
const REFRESH_COOLDOWN_MS = 2000; // Ne pas recharger plus d'une fois toutes les 2 secondes
|
||||
|
||||
const browseData = computed(() =>
|
||||
getBrowseCached(props.serverId, props.containerId)
|
||||
)
|
||||
getBrowseCached(props.serverId, props.containerId),
|
||||
);
|
||||
|
||||
const containers = computed(() =>
|
||||
browseData.value?.entries.filter((e) => e.is_container) || []
|
||||
)
|
||||
const containers = computed(
|
||||
() => browseData.value?.entries.filter((e) => e.is_container) || [],
|
||||
);
|
||||
|
||||
const items = computed(() =>
|
||||
browseData.value?.entries.filter((e) => !e.is_container) || []
|
||||
)
|
||||
const items = computed(
|
||||
() => browseData.value?.entries.filter((e) => !e.is_container) || [],
|
||||
);
|
||||
|
||||
// Charger le container au montage et quand containerId change
|
||||
watch(
|
||||
() => props.containerId,
|
||||
async (newContainerId) => {
|
||||
if (newContainerId) {
|
||||
await browseContainer(props.serverId, newContainerId)
|
||||
}
|
||||
},
|
||||
{ immediate: true }
|
||||
)
|
||||
() => props.containerId,
|
||||
async (newContainerId) => {
|
||||
if (newContainerId) {
|
||||
await browseContainer(props.serverId, newContainerId);
|
||||
}
|
||||
},
|
||||
{ immediate: true },
|
||||
);
|
||||
|
||||
// Recharger automatiquement si le cache est invalidé (ex: après un ContainersUpdated SSE)
|
||||
// Cela se produit notamment quand on clique sur "Lire maintenant" sur une playlist,
|
||||
@@ -64,268 +60,282 @@ watch(
|
||||
// Utilise un debounce de 3 secondes pour regrouper les multiples invalidations
|
||||
// et un cooldown de 5 secondes pour éviter les rechargements successifs
|
||||
watch(
|
||||
() => browseData.value,
|
||||
(data) => {
|
||||
// Si browseData devient undefined alors que containerId est présent,
|
||||
// et qu'on n'est pas déjà en train de charger, planifier un rechargement
|
||||
if (!data && props.containerId && !loading.value) {
|
||||
// Vérifier le cooldown: ignorer si on a rechargé il y a moins de 5 secondes
|
||||
const timeSinceLastRefresh = Date.now() - lastRefreshTime.value
|
||||
if (timeSinceLastRefresh < REFRESH_COOLDOWN_MS) {
|
||||
console.log(
|
||||
`[MediaBrowser] Cache invalidé mais cooldown actif (${Math.round((REFRESH_COOLDOWN_MS - timeSinceLastRefresh) / 1000)}s restantes), rechargement ignoré`
|
||||
)
|
||||
return
|
||||
}
|
||||
() => browseData.value,
|
||||
(data) => {
|
||||
// Si browseData devient undefined alors que containerId est présent,
|
||||
// et qu'on n'est pas déjà en train de charger, planifier un rechargement
|
||||
if (!data && props.containerId && !loading.value) {
|
||||
// Vérifier le cooldown: ignorer si on a rechargé il y a moins de 5 secondes
|
||||
const timeSinceLastRefresh = Date.now() - lastRefreshTime.value;
|
||||
if (timeSinceLastRefresh < REFRESH_COOLDOWN_MS) {
|
||||
console.log(
|
||||
`[MediaBrowser] Cache invalidé mais cooldown actif (${Math.round((REFRESH_COOLDOWN_MS - timeSinceLastRefresh) / 1000)}s restantes), rechargement ignoré`,
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
// Annuler tout timeout en cours
|
||||
if (refreshTimeoutId.value !== null) {
|
||||
clearTimeout(refreshTimeoutId.value)
|
||||
}
|
||||
// Annuler tout timeout en cours
|
||||
if (refreshTimeoutId.value !== null) {
|
||||
clearTimeout(refreshTimeoutId.value);
|
||||
}
|
||||
|
||||
// Planifier le rechargement après 3 secondes
|
||||
// Cela permet de regrouper plusieurs événements SSE successifs
|
||||
refreshTimeoutId.value = window.setTimeout(async () => {
|
||||
if (!isRefreshing.value) {
|
||||
console.log(
|
||||
`[MediaBrowser] Cache invalidé pour ${props.serverId}/${props.containerId}, rechargement après debounce...`
|
||||
)
|
||||
isRefreshing.value = true
|
||||
await browseContainer(props.serverId, props.containerId, false)
|
||||
lastRefreshTime.value = Date.now() // Enregistrer le moment du rechargement
|
||||
isRefreshing.value = false
|
||||
refreshTimeoutId.value = null
|
||||
// Planifier le rechargement après 200ms
|
||||
// Cela permet de dédupliquer les événements SSE dans le même batch (polling 500ms)
|
||||
refreshTimeoutId.value = window.setTimeout(async () => {
|
||||
if (!isRefreshing.value) {
|
||||
console.log(
|
||||
`[MediaBrowser] Cache invalidé pour ${props.serverId}/${props.containerId}, rechargement après debounce...`,
|
||||
);
|
||||
isRefreshing.value = true;
|
||||
await browseContainer(
|
||||
props.serverId,
|
||||
props.containerId,
|
||||
false,
|
||||
);
|
||||
lastRefreshTime.value = Date.now(); // Enregistrer le moment du rechargement
|
||||
isRefreshing.value = false;
|
||||
refreshTimeoutId.value = null;
|
||||
}
|
||||
}, 200);
|
||||
}
|
||||
}, 3000)
|
||||
}
|
||||
}
|
||||
)
|
||||
},
|
||||
);
|
||||
|
||||
const emit = defineEmits<{
|
||||
navigate: [containerId: string]
|
||||
}>()
|
||||
navigate: [containerId: string];
|
||||
}>();
|
||||
|
||||
function handleNavigate(containerId: string) {
|
||||
emit('navigate', containerId)
|
||||
emit("navigate", containerId);
|
||||
}
|
||||
|
||||
function handleBrowseContainer(containerId: string) {
|
||||
emit('navigate', containerId)
|
||||
emit("navigate", containerId);
|
||||
}
|
||||
|
||||
// Actions handlers pour les containers (playlists/albums)
|
||||
async function handlePlayContainer(containerId: string, rendererId: string) {
|
||||
try {
|
||||
await attachAndPlayPlaylist(rendererId, props.serverId, containerId)
|
||||
uiStore.notifySuccess('Lecture de la playlist démarrée !')
|
||||
} catch (err) {
|
||||
const message = err instanceof Error ? err.message : 'Erreur inconnue'
|
||||
uiStore.notifyError(`Erreur lors de la lecture de la playlist: ${message}`)
|
||||
}
|
||||
try {
|
||||
await attachAndPlayPlaylist(rendererId, props.serverId, containerId);
|
||||
uiStore.notifySuccess("Lecture de la playlist démarrée !");
|
||||
} catch (err) {
|
||||
const message = err instanceof Error ? err.message : "Erreur inconnue";
|
||||
uiStore.notifyError(
|
||||
`Erreur lors de la lecture de la playlist: ${message}`,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
async function handleQueueContainer(containerId: string, rendererId: string) {
|
||||
try {
|
||||
await attachPlaylist(rendererId, props.serverId, containerId)
|
||||
uiStore.notifySuccess('Playlist attachée à la queue !')
|
||||
} catch (err) {
|
||||
const message = err instanceof Error ? err.message : 'Erreur inconnue'
|
||||
uiStore.notifyError(`Erreur lors de l'ajout de la playlist: ${message}`)
|
||||
}
|
||||
try {
|
||||
await attachPlaylist(rendererId, props.serverId, containerId);
|
||||
uiStore.notifySuccess("Playlist attachée à la queue !");
|
||||
} catch (err) {
|
||||
const message = err instanceof Error ? err.message : "Erreur inconnue";
|
||||
uiStore.notifyError(
|
||||
`Erreur lors de l'ajout de la playlist: ${message}`,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Actions handlers pour les items (tracks)
|
||||
async function handlePlayItem(itemId: string, rendererId: string) {
|
||||
try {
|
||||
await playContent(rendererId, props.serverId, itemId)
|
||||
uiStore.notifySuccess('Lecture démarrée !')
|
||||
} catch (err) {
|
||||
const message = err instanceof Error ? err.message : 'Erreur inconnue'
|
||||
uiStore.notifyError(`Erreur lors de la lecture: ${message}`)
|
||||
}
|
||||
try {
|
||||
await playContent(rendererId, props.serverId, itemId);
|
||||
uiStore.notifySuccess("Lecture démarrée !");
|
||||
} catch (err) {
|
||||
const message = err instanceof Error ? err.message : "Erreur inconnue";
|
||||
uiStore.notifyError(`Erreur lors de la lecture: ${message}`);
|
||||
}
|
||||
}
|
||||
|
||||
async function handleQueueItem(itemId: string, rendererId: string) {
|
||||
try {
|
||||
await addToQueue(rendererId, props.serverId, itemId)
|
||||
uiStore.notifySuccess('Ajouté à la queue !')
|
||||
} catch (err) {
|
||||
const message = err instanceof Error ? err.message : 'Erreur inconnue'
|
||||
uiStore.notifyError(`Erreur lors de l'ajout à la queue: ${message}`)
|
||||
}
|
||||
try {
|
||||
await addToQueue(rendererId, props.serverId, itemId);
|
||||
uiStore.notifySuccess("Ajouté à la queue !");
|
||||
} catch (err) {
|
||||
const message = err instanceof Error ? err.message : "Erreur inconnue";
|
||||
uiStore.notifyError(`Erreur lors de l'ajout à la queue: ${message}`);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="media-browser">
|
||||
<!-- Breadcrumb -->
|
||||
<Breadcrumb
|
||||
:items="breadcrumbPath"
|
||||
:serverId="serverId"
|
||||
@navigate="handleNavigate"
|
||||
/>
|
||||
<div class="media-browser">
|
||||
<!-- Breadcrumb -->
|
||||
<Breadcrumb
|
||||
:items="breadcrumbPath"
|
||||
:serverId="serverId"
|
||||
@navigate="handleNavigate"
|
||||
/>
|
||||
|
||||
<!-- Loading state -->
|
||||
<div v-if="loading" class="browser-loading">
|
||||
<Loader2 :size="32" class="spinner" />
|
||||
<p>Chargement...</p>
|
||||
</div>
|
||||
|
||||
<!-- Error state -->
|
||||
<div v-else-if="error" class="browser-error">
|
||||
<p class="error-message">{{ error }}</p>
|
||||
<button class="btn btn-secondary" @click="browseContainer(serverId, containerId, false)">
|
||||
Réessayer
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<!-- Content -->
|
||||
<div v-else class="browser-content">
|
||||
<!-- Containers section -->
|
||||
<div v-if="containers.length" class="browser-section">
|
||||
<h3 class="section-title">Dossiers et playlists</h3>
|
||||
<div class="entries-list">
|
||||
<ContainerItem
|
||||
v-for="container in containers"
|
||||
:key="container.id"
|
||||
:entry="container"
|
||||
:server-id="serverId"
|
||||
@browse="handleBrowseContainer"
|
||||
@play-now="handlePlayContainer"
|
||||
@add-to-queue="handleQueueContainer"
|
||||
/>
|
||||
<!-- Loading state -->
|
||||
<div v-if="loading" class="browser-loading">
|
||||
<Loader2 :size="32" class="spinner" />
|
||||
<p>Chargement...</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Items section -->
|
||||
<div v-if="items.length" class="browser-section">
|
||||
<h3 class="section-title">Pistes</h3>
|
||||
<div class="entries-list">
|
||||
<MediaItem
|
||||
v-for="item in items"
|
||||
:key="item.id"
|
||||
:entry="item"
|
||||
:server-id="serverId"
|
||||
@play-now="handlePlayItem"
|
||||
@add-to-queue="handleQueueItem"
|
||||
/>
|
||||
<!-- Error state -->
|
||||
<div v-else-if="error" class="browser-error">
|
||||
<p class="error-message">{{ error }}</p>
|
||||
<button
|
||||
class="btn btn-secondary"
|
||||
@click="browseContainer(serverId, containerId, false)"
|
||||
>
|
||||
Réessayer
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Empty state -->
|
||||
<div v-if="!containers.length && !items.length" class="browser-empty">
|
||||
<p>Ce dossier est vide</p>
|
||||
</div>
|
||||
<!-- Content -->
|
||||
<div v-else class="browser-content">
|
||||
<!-- Containers section -->
|
||||
<div v-if="containers.length" class="browser-section">
|
||||
<h3 class="section-title">Dossiers et playlists</h3>
|
||||
<div class="entries-list">
|
||||
<ContainerItem
|
||||
v-for="container in containers"
|
||||
:key="container.id"
|
||||
:entry="container"
|
||||
:server-id="serverId"
|
||||
@browse="handleBrowseContainer"
|
||||
@play-now="handlePlayContainer"
|
||||
@add-to-queue="handleQueueContainer"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Items section -->
|
||||
<div v-if="items.length" class="browser-section">
|
||||
<h3 class="section-title">Pistes</h3>
|
||||
<div class="entries-list">
|
||||
<MediaItem
|
||||
v-for="item in items"
|
||||
:key="item.id"
|
||||
:entry="item"
|
||||
:server-id="serverId"
|
||||
@play-now="handlePlayItem"
|
||||
@add-to-queue="handleQueueItem"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Empty state -->
|
||||
<div
|
||||
v-if="!containers.length && !items.length"
|
||||
class="browser-empty"
|
||||
>
|
||||
<p>Ce dossier est vide</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.media-browser {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--spacing-lg);
|
||||
height: 100%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--spacing-lg);
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
/* Loading */
|
||||
.browser-loading {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: var(--spacing-md);
|
||||
color: var(--color-text-secondary);
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: var(--spacing-md);
|
||||
color: var(--color-text-secondary);
|
||||
}
|
||||
|
||||
.spinner {
|
||||
animation: spin 1s linear infinite;
|
||||
animation: spin 1s linear infinite;
|
||||
}
|
||||
|
||||
@keyframes spin {
|
||||
from {
|
||||
transform: rotate(0deg);
|
||||
}
|
||||
to {
|
||||
transform: rotate(360deg);
|
||||
}
|
||||
from {
|
||||
transform: rotate(0deg);
|
||||
}
|
||||
to {
|
||||
transform: rotate(360deg);
|
||||
}
|
||||
}
|
||||
|
||||
/* Error */
|
||||
.browser-error {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: var(--spacing-md);
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: var(--spacing-md);
|
||||
}
|
||||
|
||||
.error-message {
|
||||
font-size: var(--text-base);
|
||||
color: var(--status-offline);
|
||||
margin: 0;
|
||||
font-size: var(--text-base);
|
||||
color: var(--status-offline);
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
/* Content */
|
||||
.browser-content {
|
||||
flex: 1;
|
||||
overflow-y: auto;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--spacing-xl);
|
||||
padding-right: var(--spacing-xs);
|
||||
flex: 1;
|
||||
overflow-y: auto;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--spacing-xl);
|
||||
padding-right: var(--spacing-xs);
|
||||
}
|
||||
|
||||
.browser-section {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--spacing-md);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--spacing-md);
|
||||
}
|
||||
|
||||
.section-title {
|
||||
font-size: var(--text-lg);
|
||||
font-weight: 600;
|
||||
color: var(--color-text);
|
||||
margin: 0;
|
||||
padding-bottom: var(--spacing-sm);
|
||||
border-bottom: 1px solid var(--color-border);
|
||||
font-size: var(--text-lg);
|
||||
font-weight: 600;
|
||||
color: var(--color-text);
|
||||
margin: 0;
|
||||
padding-bottom: var(--spacing-sm);
|
||||
border-bottom: 1px solid var(--color-border);
|
||||
}
|
||||
|
||||
.entries-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--spacing-xs);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--spacing-xs);
|
||||
}
|
||||
|
||||
/* Empty state */
|
||||
.browser-empty {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
color: var(--color-text-tertiary);
|
||||
font-size: var(--text-base);
|
||||
padding: var(--spacing-xl);
|
||||
flex: 1;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
color: var(--color-text-tertiary);
|
||||
font-size: var(--text-base);
|
||||
padding: var(--spacing-xl);
|
||||
}
|
||||
|
||||
/* Scrollbar styling */
|
||||
.browser-content::-webkit-scrollbar {
|
||||
width: 6px;
|
||||
width: 6px;
|
||||
}
|
||||
|
||||
.browser-content::-webkit-scrollbar-track {
|
||||
background: var(--color-bg-secondary);
|
||||
border-radius: var(--radius-full);
|
||||
background: var(--color-bg-secondary);
|
||||
border-radius: var(--radius-full);
|
||||
}
|
||||
|
||||
.browser-content::-webkit-scrollbar-thumb {
|
||||
background: var(--color-border);
|
||||
border-radius: var(--radius-full);
|
||||
background: var(--color-border);
|
||||
border-radius: var(--radius-full);
|
||||
}
|
||||
|
||||
.browser-content::-webkit-scrollbar-thumb:hover {
|
||||
background: var(--color-text-tertiary);
|
||||
background: var(--color-text-tertiary);
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -112,8 +112,8 @@ impl ControlPoint {
|
||||
];
|
||||
|
||||
loop {
|
||||
// Attendre 60 secondes avant le prochain cycle
|
||||
thread::sleep(Duration::from_secs(60));
|
||||
// Attendre 10 secondes avant le prochain cycle pour découverte rapide
|
||||
thread::sleep(Duration::from_secs(10));
|
||||
|
||||
debug!("Sending periodic M-SEARCH for device discovery");
|
||||
|
||||
@@ -303,9 +303,9 @@ impl ControlPoint {
|
||||
new_snapshot.state = Some(logical_state);
|
||||
}
|
||||
|
||||
// Poll volume and mute less frequently (every 3 seconds)
|
||||
// to reduce SOAP overhead without impacting UI responsiveness
|
||||
if tick % 3 == 0 {
|
||||
// Poll volume and mute every second (every 2 ticks at 500ms)
|
||||
// for responsive volume control feedback
|
||||
if tick % 2 == 0 {
|
||||
if let Ok(volume) = renderer.volume() {
|
||||
if prev_snapshot.last_volume != Some(volume) {
|
||||
polling_cp.emit_renderer_event(RendererEvent::VolumeChanged {
|
||||
@@ -334,8 +334,8 @@ impl ControlPoint {
|
||||
}
|
||||
|
||||
tick = tick.wrapping_add(1);
|
||||
// Keep 1 second polling for smooth position updates
|
||||
thread::sleep(Duration::from_secs(1));
|
||||
// 500ms polling for smoother position updates and progress bar
|
||||
thread::sleep(Duration::from_millis(500));
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -1497,87 +1497,79 @@ async fn play_content(
|
||||
})?;
|
||||
|
||||
let control_point = Arc::clone(&state.control_point);
|
||||
let rid_for_log = rid.clone();
|
||||
let object_id_for_log = object_id.clone();
|
||||
let object_id_for_debug = object_id_for_log.clone();
|
||||
|
||||
// Spawn blocking task for content loading
|
||||
let play_task = tokio::task::spawn_blocking(move || {
|
||||
// Fetch playback items from server
|
||||
let items = fetch_playback_items(&control_point, &sid, &object_id)?;
|
||||
// Launch the command in background and return immediately
|
||||
// The UI will be updated via SSE events when playback starts
|
||||
tokio::task::spawn(async move {
|
||||
let result = tokio::task::spawn_blocking(move || {
|
||||
// Fetch playback items from server
|
||||
let items = fetch_playback_items(&control_point, &sid, &object_id)?;
|
||||
|
||||
if items.is_empty() {
|
||||
return Err(anyhow::anyhow!("No playable content found"));
|
||||
if items.is_empty() {
|
||||
return Err(anyhow::anyhow!("No playable content found"));
|
||||
}
|
||||
|
||||
if items.len() > 1 {
|
||||
debug!(
|
||||
renderer = rid.0.as_str(),
|
||||
server = sid.0.as_str(),
|
||||
object = object_id.as_str(),
|
||||
item_count = items.len(),
|
||||
"Auto-binding playlist to renderer queue (auto_play = true)"
|
||||
);
|
||||
control_point.attach_queue_to_playlist_with_options(
|
||||
&rid,
|
||||
sid.clone(),
|
||||
object_id.clone(),
|
||||
true,
|
||||
)?;
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
// Clear queue
|
||||
control_point.clear_queue(&rid)?;
|
||||
|
||||
// Enqueue items
|
||||
control_point.enqueue_items(&rid, items)?;
|
||||
|
||||
// Start playback
|
||||
// Pour les renderers OpenHome, play_current_from_queue() va gérer automatiquement
|
||||
// la lecture depuis la playlist native si elle existe
|
||||
control_point.play_current_from_queue(&rid)?;
|
||||
|
||||
Ok::<(), anyhow::Error>(())
|
||||
})
|
||||
.await;
|
||||
|
||||
match result {
|
||||
Ok(Ok(())) => {
|
||||
debug!(
|
||||
"Successfully started playing content {} on renderer {}",
|
||||
object_id_for_log, rid_for_log.0
|
||||
);
|
||||
}
|
||||
Ok(Err(e)) => {
|
||||
warn!(
|
||||
"Failed to play content on renderer {}: {}",
|
||||
rid_for_log.0, e
|
||||
);
|
||||
}
|
||||
Err(e) => {
|
||||
warn!(
|
||||
"Task join error during play content for renderer {}: {}",
|
||||
rid_for_log.0, e
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if items.len() > 1 {
|
||||
debug!(
|
||||
renderer = rid.0.as_str(),
|
||||
server = sid.0.as_str(),
|
||||
object = object_id.as_str(),
|
||||
item_count = items.len(),
|
||||
"Auto-binding playlist to renderer queue (auto_play = true)"
|
||||
);
|
||||
control_point.attach_queue_to_playlist_with_options(
|
||||
&rid,
|
||||
sid.clone(),
|
||||
object_id.clone(),
|
||||
true,
|
||||
)?;
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
// Clear queue
|
||||
control_point.clear_queue(&rid)?;
|
||||
|
||||
// Enqueue items
|
||||
control_point.enqueue_items(&rid, items)?;
|
||||
|
||||
// Start playback
|
||||
// Pour les renderers OpenHome, play_current_from_queue() va gérer automatiquement
|
||||
// la lecture depuis la playlist native si elle existe
|
||||
control_point.play_current_from_queue(&rid)?;
|
||||
|
||||
Ok::<(), anyhow::Error>(())
|
||||
});
|
||||
|
||||
time::timeout(QUEUE_COMMAND_TIMEOUT, play_task)
|
||||
.await
|
||||
.map_err(|_| {
|
||||
warn!(
|
||||
"Play content command for renderer {} exceeded {:?}",
|
||||
renderer_id, QUEUE_COMMAND_TIMEOUT
|
||||
);
|
||||
(
|
||||
StatusCode::GATEWAY_TIMEOUT,
|
||||
Json(ErrorResponse {
|
||||
error: format!(
|
||||
"Play content timed out after {}s",
|
||||
QUEUE_COMMAND_TIMEOUT.as_secs()
|
||||
),
|
||||
}),
|
||||
)
|
||||
})?
|
||||
.map_err(|e| {
|
||||
warn!("Task join error during play content: {}", e);
|
||||
(
|
||||
StatusCode::INTERNAL_SERVER_ERROR,
|
||||
Json(ErrorResponse {
|
||||
error: format!("Internal task error: {}", e),
|
||||
}),
|
||||
)
|
||||
})?
|
||||
.map_err(|e| {
|
||||
warn!("Failed to play content on renderer {}: {}", renderer_id, e);
|
||||
(
|
||||
StatusCode::INTERNAL_SERVER_ERROR,
|
||||
Json(ErrorResponse {
|
||||
error: format!("Failed to play content: {}", e),
|
||||
}),
|
||||
)
|
||||
})?;
|
||||
|
||||
debug!(
|
||||
renderer = renderer_id.as_str(),
|
||||
server = req.server_id.as_str(),
|
||||
object = object_id_for_log.as_str(),
|
||||
object = object_id_for_debug.as_str(),
|
||||
"Content playing via HTTP API"
|
||||
);
|
||||
|
||||
@@ -1626,65 +1618,54 @@ async fn add_to_queue(
|
||||
})?;
|
||||
|
||||
let control_point = Arc::clone(&state.control_point);
|
||||
let rid_for_log = rid.clone();
|
||||
let object_id_for_log = object_id.clone();
|
||||
let object_id_for_debug = object_id_for_log.clone();
|
||||
|
||||
// Spawn blocking task for content loading
|
||||
let add_task = tokio::task::spawn_blocking(move || {
|
||||
// Fetch playback items from server
|
||||
let items = fetch_playback_items(&control_point, &sid, &object_id)?;
|
||||
// Launch the command in background and return immediately
|
||||
// The UI will be updated via SSE events when the queue changes
|
||||
tokio::task::spawn(async move {
|
||||
let result = tokio::task::spawn_blocking(move || {
|
||||
// Fetch playback items from server
|
||||
let items = fetch_playback_items(&control_point, &sid, &object_id)?;
|
||||
|
||||
if items.is_empty() {
|
||||
return Err(anyhow::anyhow!("No playable content found"));
|
||||
if items.is_empty() {
|
||||
return Err(anyhow::anyhow!("No playable content found"));
|
||||
}
|
||||
|
||||
// Enqueue items
|
||||
control_point.enqueue_items(&rid, items)?;
|
||||
|
||||
Ok::<(), anyhow::Error>(())
|
||||
})
|
||||
.await;
|
||||
|
||||
match result {
|
||||
Ok(Ok(())) => {
|
||||
debug!(
|
||||
"Successfully added content {} to queue for renderer {}",
|
||||
object_id_for_log, rid_for_log.0
|
||||
);
|
||||
}
|
||||
Ok(Err(e)) => {
|
||||
warn!(
|
||||
"Failed to add content to queue for renderer {}: {}",
|
||||
rid_for_log.0, e
|
||||
);
|
||||
}
|
||||
Err(e) => {
|
||||
warn!(
|
||||
"Task join error during add to queue for renderer {}: {}",
|
||||
rid_for_log.0, e
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Enqueue items
|
||||
control_point.enqueue_items(&rid, items)?;
|
||||
|
||||
Ok::<(), anyhow::Error>(())
|
||||
});
|
||||
|
||||
time::timeout(QUEUE_COMMAND_TIMEOUT, add_task)
|
||||
.await
|
||||
.map_err(|_| {
|
||||
warn!(
|
||||
"Add to queue command for renderer {} exceeded {:?}",
|
||||
renderer_id, QUEUE_COMMAND_TIMEOUT
|
||||
);
|
||||
(
|
||||
StatusCode::GATEWAY_TIMEOUT,
|
||||
Json(ErrorResponse {
|
||||
error: format!(
|
||||
"Add to queue timed out after {}s",
|
||||
QUEUE_COMMAND_TIMEOUT.as_secs()
|
||||
),
|
||||
}),
|
||||
)
|
||||
})?
|
||||
.map_err(|e| {
|
||||
warn!("Task join error during add to queue: {}", e);
|
||||
(
|
||||
StatusCode::INTERNAL_SERVER_ERROR,
|
||||
Json(ErrorResponse {
|
||||
error: format!("Internal task error: {}", e),
|
||||
}),
|
||||
)
|
||||
})?
|
||||
.map_err(|e| {
|
||||
warn!(
|
||||
"Failed to add content to queue for renderer {}: {}",
|
||||
renderer_id, e
|
||||
);
|
||||
(
|
||||
StatusCode::INTERNAL_SERVER_ERROR,
|
||||
Json(ErrorResponse {
|
||||
error: format!("Failed to add to queue: {}", e),
|
||||
}),
|
||||
)
|
||||
})?;
|
||||
|
||||
debug!(
|
||||
renderer = renderer_id.as_str(),
|
||||
server = req.server_id.as_str(),
|
||||
object = object_id_for_log.as_str(),
|
||||
object = object_id_for_debug.as_str(),
|
||||
"Content added to queue via HTTP API"
|
||||
);
|
||||
|
||||
@@ -1734,69 +1715,58 @@ async fn add_after_current(
|
||||
})?;
|
||||
|
||||
let control_point = Arc::clone(&state.control_point);
|
||||
let rid_for_log = rid.clone();
|
||||
let object_id_for_log = object_id.clone();
|
||||
let object_id_for_debug = object_id_for_log.clone();
|
||||
|
||||
// Spawn blocking task for content loading
|
||||
let add_task = tokio::task::spawn_blocking(move || {
|
||||
// Fetch playback items from server
|
||||
let items = fetch_playback_items(&control_point, &sid, &object_id)?;
|
||||
// Launch the command in background and return immediately
|
||||
// The UI will be updated via SSE events when the queue changes
|
||||
tokio::task::spawn(async move {
|
||||
let result = tokio::task::spawn_blocking(move || {
|
||||
// Fetch playback items from server
|
||||
let items = fetch_playback_items(&control_point, &sid, &object_id)?;
|
||||
|
||||
if items.is_empty() {
|
||||
return Err(anyhow::anyhow!("No playable content found"));
|
||||
if items.is_empty() {
|
||||
return Err(anyhow::anyhow!("No playable content found"));
|
||||
}
|
||||
|
||||
// Insert items after current using the new method
|
||||
control_point.enqueue_items_with_mode(
|
||||
&rid,
|
||||
items,
|
||||
crate::queue::EnqueueMode::InsertAfterCurrent,
|
||||
)?;
|
||||
|
||||
Ok::<(), anyhow::Error>(())
|
||||
})
|
||||
.await;
|
||||
|
||||
match result {
|
||||
Ok(Ok(())) => {
|
||||
debug!(
|
||||
"Successfully added content {} after current for renderer {}",
|
||||
object_id_for_log, rid_for_log.0
|
||||
);
|
||||
}
|
||||
Ok(Err(e)) => {
|
||||
warn!(
|
||||
"Failed to add content after current for renderer {}: {}",
|
||||
rid_for_log.0, e
|
||||
);
|
||||
}
|
||||
Err(e) => {
|
||||
warn!(
|
||||
"Task join error during add after current for renderer {}: {}",
|
||||
rid_for_log.0, e
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Insert items after current using the new method
|
||||
control_point.enqueue_items_with_mode(
|
||||
&rid,
|
||||
items,
|
||||
crate::queue::EnqueueMode::InsertAfterCurrent,
|
||||
)?;
|
||||
|
||||
Ok::<(), anyhow::Error>(())
|
||||
});
|
||||
|
||||
time::timeout(QUEUE_COMMAND_TIMEOUT, add_task)
|
||||
.await
|
||||
.map_err(|_| {
|
||||
warn!(
|
||||
"Add after current command for renderer {} exceeded {:?}",
|
||||
renderer_id, QUEUE_COMMAND_TIMEOUT
|
||||
);
|
||||
(
|
||||
StatusCode::GATEWAY_TIMEOUT,
|
||||
Json(ErrorResponse {
|
||||
error: format!(
|
||||
"Add after current timed out after {}s",
|
||||
QUEUE_COMMAND_TIMEOUT.as_secs()
|
||||
),
|
||||
}),
|
||||
)
|
||||
})?
|
||||
.map_err(|e| {
|
||||
warn!("Task join error during add after current: {}", e);
|
||||
(
|
||||
StatusCode::INTERNAL_SERVER_ERROR,
|
||||
Json(ErrorResponse {
|
||||
error: format!("Internal task error: {}", e),
|
||||
}),
|
||||
)
|
||||
})?
|
||||
.map_err(|e| {
|
||||
warn!(
|
||||
"Failed to add content after current for renderer {}: {}",
|
||||
renderer_id, e
|
||||
);
|
||||
(
|
||||
StatusCode::INTERNAL_SERVER_ERROR,
|
||||
Json(ErrorResponse {
|
||||
error: format!("Failed to add after current: {}", e),
|
||||
}),
|
||||
)
|
||||
})?;
|
||||
|
||||
debug!(
|
||||
renderer = renderer_id.as_str(),
|
||||
server = req.server_id.as_str(),
|
||||
object = object_id_for_log.as_str(),
|
||||
object = object_id_for_debug.as_str(),
|
||||
"Content added after current via HTTP API"
|
||||
);
|
||||
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
0.3.0
|
||||
Reference in New Issue
Block a user