just_audio icon indicating copy to clipboard operation
just_audio copied to clipboard

Add ResolvingAudioSource;

Open cooaer opened this issue 2 years ago • 7 comments

Resolve url in time with headers;

cooaer avatar Aug 24 '22 03:08 cooaer

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 avatar Aug 24 '22 06:08 ryanheise

@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 avatar Aug 24 '22 17:08 cooaer

@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.

shuyec avatar Aug 29 '22 15:08 shuyec

Not working with youtube video urls. @shuyec @ryanheise

cometothed4rkside avatar Sep 16 '22 14:09 cometothed4rkside

Not working with youtube video urls. @shuyec @ryanheise

It's not supposed to.

bleonard252 avatar Nov 18 '22 19:11 bleonard252

Does this work on ios and mac?

canxin121 avatar May 14 '24 17:05 canxin121