Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ResolvingAudioSource; #800

Open
wants to merge 3 commits into
base: minor
Choose a base branch
from

Conversation

cooaer
Copy link

@cooaer cooaer commented Aug 24, 2022

Resolve url in time with headers;

@ryanheise
Copy link
Owner

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?

@cooaer
Copy link
Author

cooaer commented Aug 24, 2022

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

@shuyec
Copy link

shuyec commented Aug 29, 2022

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

@cometothed4rkside
Copy link

cometothed4rkside commented Sep 16, 2022

Not working with youtube video urls. @shuyec @ryanheise

@bleonard252
Copy link

Not working with youtube video urls. @shuyec @ryanheise

It's not supposed to.

@canxin121
Copy link
Contributor

Does this work on ios and mac?

Jorge-Anton added a commit to Jorge-Anton/just_audio that referenced this pull request May 31, 2024
@jonathanMNg
Copy link

Does this work on ios and mac?

I tried on IOS and it doesn't seem to work

        audioSource = ResolvingAudioSource(uniqueId: audioId,
            resolveSoundUrl: (audioId) async {
              final manifest = (await _yt.videos.streamsClient
                  .getManifest(audioId));
              final audioUri = Platform.isIOS ? manifest.muxed.withHighestBitrate().url
                  : manifest.audioOnly.withHighestBitrate().url;
              return audioUri;
        }, tag: tag);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants