just_audio
just_audio copied to clipboard
Add ResolvingAudioSource;
Resolve url in time with headers;
Hi @cooaer , would you be able to mention your PR on the other PR #779 ? There has been a discussion there about the pros/cons of different approaches. Also, is there any reason you personally decided not to implement this as a subclass of StreamAudioSource
?
@ryanheise OK! First, thank you and this great project, this project has helped me a lot!Also, I just didn't understand StreamAudioSource before, and it's really a good idea to implement it. I will modify it.
@cooaer ~~Can you please add an example on how to use this?~~
A modified version of the example from the PR 779 works quite well.
final apiService = ApiService();
final queue = await apiService.getQueue();
final resolvingAudioSource = [
for (final queueItem in queue)
ResolvingAudioSource(
uniqueId: queueItem["id"],
resolveSoundUrl: ((uniqueId) async {
uniqueId = queueItem["id"];
return Uri.parse(await apiService.getUrl(queueItem));
}
}),
tag: queueItem),
];
_playlist.addAll(resolvingAudioSource);
await _audioPlayer.setAudioSource(_playlist);
Also I don't know if it was intentional or a typo, but the parameter of ResolveSoundUrl
is called uniquidId
.
Not working with youtube video urls. @shuyec @ryanheise
Not working with youtube video urls. @shuyec @ryanheise
It's not supposed to.
Does this work on ios and mac?