URL preprocessing in flutter audio-service

31 views Asked by At

I'm currently using the audio_service package in Flutter to play songs. I wanted to understand if there's any way I can preprocess URLs before they are played. Like, let's say a URL is encrypted, then I want to decrypt it before it plays. Or if a URL is empty, then I want to make an API call before it gets played. Right now, I'm decrypting them beforehand and passing the data. It's fine for smaller data, but when a playlist of let's say, 1000 songs is played, that preprocessing leads to a delay in actual playback.

That's how I'm currently initialising the service:

final _playlist = ConcatenatingAudioSource(children: []);
_player = AudioPlayer(audioPipeline: pipeline);
await _player!
    .setAudioSource(_playlist, preload: false)
    .onError((error, stackTrace) {
  _onError(error, stackTrace, stopService: true);
  return null;
});

I tried listening to mediaitem stream, but the issue with it is that I will have to modify that specific playlist item, which also I'm not able to achieve.

0

There are 0 answers