amélioration de la webapp
This commit is contained in:
@@ -43,11 +43,13 @@ async fn main() -> Result<()> {
|
||||
// Display all tracks
|
||||
println!("Available Tracks:");
|
||||
for (index, song) in block.songs_ordered() {
|
||||
println!(" {}. {} - {} ({:.1}s)",
|
||||
index,
|
||||
song.artist,
|
||||
song.title,
|
||||
song.duration as f64 / 1000.0);
|
||||
println!(
|
||||
" {}. {} - {} ({:.1}s)",
|
||||
index,
|
||||
song.artist,
|
||||
song.title,
|
||||
song.duration as f64 / 1000.0
|
||||
);
|
||||
}
|
||||
println!();
|
||||
|
||||
@@ -67,7 +69,10 @@ async fn main() -> Result<()> {
|
||||
println!("Track Metadata:");
|
||||
println!(" Sample Rate: {} Hz", track_stream.metadata.sample_rate);
|
||||
println!(" Channels: {}", track_stream.metadata.channels);
|
||||
println!(" Bits Per Sample: {}", track_stream.metadata.bits_per_sample);
|
||||
println!(
|
||||
" Bits Per Sample: {}",
|
||||
track_stream.metadata.bits_per_sample
|
||||
);
|
||||
println!(" Total Samples: {}", track_stream.metadata.total_samples);
|
||||
println!();
|
||||
|
||||
@@ -86,10 +91,15 @@ async fn main() -> Result<()> {
|
||||
let (start, duration) = client.track_position_seconds(&block, index)?;
|
||||
println!("Track {}: {} - {}", index, song.artist, song.title);
|
||||
println!(" mpv command:");
|
||||
println!(" mpv --start={:.3} --length={:.3} '{}'", start, duration, block.url);
|
||||
println!(
|
||||
" mpv --start={:.3} --length={:.3} '{}'",
|
||||
start, duration, block.url
|
||||
);
|
||||
println!(" ffmpeg command (extract to file):");
|
||||
println!(" ffmpeg -ss {:.3} -t {:.3} -i '{}' -c copy track_{}.flac",
|
||||
start, duration, block.url, index);
|
||||
println!(
|
||||
" ffmpeg -ss {:.3} -t {:.3} -i '{}' -c copy track_{}.flac",
|
||||
start, duration, block.url, index
|
||||
);
|
||||
println!();
|
||||
}
|
||||
|
||||
|
||||
@@ -48,9 +48,11 @@ async fn main() -> Result<()> {
|
||||
if let Some(rating) = song.rating {
|
||||
println!(" Rating: {:.1}/10", rating);
|
||||
}
|
||||
println!(" Duration: {}:{:02}",
|
||||
song.duration / 60000,
|
||||
(song.duration % 60000) / 1000);
|
||||
println!(
|
||||
" Duration: {}:{:02}",
|
||||
song.duration / 60000,
|
||||
(song.duration % 60000) / 1000
|
||||
);
|
||||
|
||||
// Display cover URL
|
||||
if let Some(cover) = &song.cover {
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
//! - Accessing the embedded WebP image
|
||||
//! - Optionally saving it to a file
|
||||
|
||||
use pmoparadise::{RadioParadiseSource, RadioParadiseClient};
|
||||
use pmoparadise::{RadioParadiseClient, RadioParadiseSource};
|
||||
use pmosource::MusicSource;
|
||||
use std::fs;
|
||||
use std::io::Write;
|
||||
|
||||
@@ -38,7 +38,10 @@ async fn main() -> Result<()> {
|
||||
eprintln!("Current Block:");
|
||||
eprintln!(" Event: {}", current_block.event);
|
||||
eprintln!(" Songs: {}", current_block.song_count());
|
||||
eprintln!(" Duration: {:.1} minutes", current_block.length as f64 / 60000.0);
|
||||
eprintln!(
|
||||
" Duration: {:.1} minutes",
|
||||
current_block.length as f64 / 60000.0
|
||||
);
|
||||
eprintln!(" URL: {}\n", current_block.url);
|
||||
|
||||
// Display tracklist
|
||||
@@ -51,7 +54,10 @@ async fn main() -> Result<()> {
|
||||
// Prefetch next block in advance
|
||||
eprintln!("Prefetching next block...");
|
||||
client.prefetch_next(¤t_block).await?;
|
||||
eprintln!("Next block prefetched: {}\n", client.next_block_url().unwrap());
|
||||
eprintln!(
|
||||
"Next block prefetched: {}\n",
|
||||
client.next_block_url().unwrap()
|
||||
);
|
||||
|
||||
// Stream the block
|
||||
eprintln!("Streaming block... (writing to stdout)");
|
||||
@@ -71,12 +77,18 @@ async fn main() -> Result<()> {
|
||||
|
||||
// Progress indicator (to stderr so it doesn't interfere with piped audio)
|
||||
if total_bytes % (1024 * 1024) == 0 {
|
||||
eprintln!(" Downloaded: {:.1} MB", total_bytes as f64 / 1024.0 / 1024.0);
|
||||
eprintln!(
|
||||
" Downloaded: {:.1} MB",
|
||||
total_bytes as f64 / 1024.0 / 1024.0
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
eprintln!("\nBlock streaming complete!");
|
||||
eprintln!("Total downloaded: {:.2} MB", total_bytes as f64 / 1024.0 / 1024.0);
|
||||
eprintln!(
|
||||
"Total downloaded: {:.2} MB",
|
||||
total_bytes as f64 / 1024.0 / 1024.0
|
||||
);
|
||||
|
||||
// In a real application, you would now:
|
||||
// 1. Get the next block using prefetched metadata
|
||||
|
||||
@@ -48,7 +48,10 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
println!("Look for 'Radio Paradise FLAC' in your DLNA/UPnP clients.");
|
||||
println!();
|
||||
println!("ContentDirectory service available at:");
|
||||
println!(" http://localhost:8080/upnp/device/{}/service/ContentDirectory", server.udn());
|
||||
println!(
|
||||
" http://localhost:8080/upnp/device/{}/service/ContentDirectory",
|
||||
server.udn()
|
||||
);
|
||||
println!();
|
||||
println!("Press Ctrl+C to stop the server.");
|
||||
println!();
|
||||
|
||||
@@ -8,9 +8,9 @@
|
||||
//! cargo run --example with_cache --features cache
|
||||
//! ```
|
||||
|
||||
use pmoparadise::{RadioParadiseClient, RadioParadiseSource};
|
||||
use pmocovers::Cache as CoverCache;
|
||||
use pmoaudiocache::AudioCache;
|
||||
use pmocovers::Cache as CoverCache;
|
||||
use pmoparadise::{RadioParadiseClient, RadioParadiseSource};
|
||||
use pmosource::MusicSource;
|
||||
use std::sync::Arc;
|
||||
use tokio::time::{sleep, Duration};
|
||||
@@ -64,7 +64,13 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
// Add current song to the source
|
||||
println!("➕ Adding current track to FIFO with caching...");
|
||||
if let Some(song) = &now_playing.current_song {
|
||||
source.add_song(block.clone(), song, now_playing.current_song_index.unwrap_or(0)).await?;
|
||||
source
|
||||
.add_song(
|
||||
block.clone(),
|
||||
song,
|
||||
now_playing.current_song_index.unwrap_or(0),
|
||||
)
|
||||
.await?;
|
||||
println!("✅ Track added and caching started!");
|
||||
println!(" - Cover image will be cached to: ./cache/covers/");
|
||||
println!(" - Audio will be cached to: ./cache/audio/\n");
|
||||
@@ -78,7 +84,8 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
println!("\n📋 Items in FIFO:");
|
||||
let items = source.get_items(0, 10).await?;
|
||||
for (i, item) in items.iter().enumerate() {
|
||||
println!(" {}. {} - {}",
|
||||
println!(
|
||||
" {}. {} - {}",
|
||||
i + 1,
|
||||
item.artist.as_deref().unwrap_or("Unknown"),
|
||||
item.title
|
||||
|
||||
Reference in New Issue
Block a user