Home > Blockchain >  Flutter: How can I update AudioSource MediaItem with the current snapshot data to display current ti
Flutter: How can I update AudioSource MediaItem with the current snapshot data to display current ti

Time:08-29

This is the Audio Background Notification service that displays the current song on the Radio Streaming, the radio streaming works fine(plays in the background) but it does not update the Notification of the currently playing song(title and artist).

Please anyone with how to resolve this?

final _playlist = ConcatenatingAudioSource(children: [
    ClippingAudioSource(
      child: AudioSource.uri(Uri.parse("https://streaming.com/listen")),
      tag: MediaItem(
        id: '1',
        title: "Current Song Title being streamed",// want to update this
        artist: "Current Song Artist being streamed",// want to update this
         artUri: Uri.parse("https://media.wnyc.org/i/1400/1400/l/80/1/ScienceFriday_WNYCStudios_1400.jpg"),
      ),
    ),
  ]);


StreamBuilder<IcyMetadata?>(
   stream: widget.player.icyMetadataStream,
   builder: (context, snapshot) {
     final metadata = snapshot.data;
     final title = metadata?.info?.title ?? '';
   }
//Title contains details needed
)

CodePudding user response:

just_audio_background does not support this. If you would like this feature, you can make a feature request on GitHub. However, the README of just_audio_background also mentions:

If your app has more complex requirements, it is recommended that you instead use the audio_service package directly.

audio_service does not specifically provide an example for radio streaming, but you can request one by making a documentation request on GitHub.

  • Related