diff options
Diffstat (limited to 'src/audio')
| -rw-r--r-- | src/audio/rodio.rs | 27 |
1 files changed, 13 insertions, 14 deletions
diff --git a/src/audio/rodio.rs b/src/audio/rodio.rs index 0f9fbb2..49ebe40 100644 --- a/src/audio/rodio.rs +++ b/src/audio/rodio.rs @@ -42,23 +42,22 @@ impl Rodio { .await .unwrap(); - sink.append( - Decoder::new(IcyMetadataReader::new( - reader, - // Since we requested icy metadata, the metadata interval header should be present in the - // response. This will allow us to parse the metadata within the stream - icy_headers.metadata_interval(), - |metadata| { - if let Ok(md) = metadata { - if let Some(tr) = md.stream_title() { - println!(" {tr}"); - } + let metadata_reader = IcyMetadataReader::new( + reader, + // Since we requested icy metadata, the metadata interval header should be present in the + // response. This will allow us to parse the metadata within the stream + icy_headers.metadata_interval(), + |metadata| { + if let Ok(md) = metadata { + if let Some(tr) = md.stream_title() { + println!(" {tr}"); } - }, - )) - .unwrap(), + } + }, ); + sink.append(Decoder::new(metadata_reader).unwrap()); + let handle = tokio::task::spawn_blocking(move || { sink.sleep_until_end(); }); |
