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

Calling 'playQueueItem' immediately after changing the queue doesn't play, immediately resets queue when play called again later #856

Open
1 of 7 tasks
BenDTU opened this issue Apr 4, 2022 · 11 comments

Comments

@BenDTU
Copy link

BenDTU commented Apr 4, 2022

🐛 Bug Report

Running the latest version of XamarinMediaManager, loading a queue and playing a song in the queue other than the first one is not behaving as expected. Calling 'PlayQueueItem' changes the 'current' item but it does not play. Calling 'play' later causes the current item to reset back to the first item in the queue.

Expected behavior

I would assume 'PlayQueueItem' would immediately start playing the song in the location in the queue specified.

Reproduction steps

await CrossMediaManager.Current.Stop();            
CrossMediaManager.Current.Queue.Clear();
foreach (var item in mediaItemPlaylist)
{
    CrossMediaManager.Current.Queue.Add(item);
}
await CrossMediaManager.Current.PlayQueueItem(selectedSongIndex)

This will cause the current item to change but nothing will play. Calling CrossMediaManager.Current.Play() later will reset the queue.

Configuration

Xamarin.Forms 5.0.0.2337
Xamarin Essentials 1.7.1
Plugin.MediaManager 1.1.0

Version: 1.x

Platform:

  • 📱 iOS
  • 🤖 Android
  • 🏁 WPF
  • 🌎 UWP
  • 🍎 MacOS
  • 📺 tvOS
  • 🐒 Xamarin.Forms
@BenDTU
Copy link
Author

BenDTU commented Apr 5, 2022

Quick update - can confirm that this isn't an issue running on iOS.

@Dirwaz
Copy link

Dirwaz commented Apr 20, 2022

i am having the same issue on Android only. on iOS it is working fine.

@SalimiHabib
Copy link

same issue on android
not playing

var inx = _mediaManager.Queue.IndexOf((IMediaItem)obj);
 var r = await _mediaManager.PlayQueueItem(inx);

@Shrp77
Copy link

Shrp77 commented Sep 10, 2022

Same exact behavior on my end too (Android app)

@arahmancsd
Copy link

same here, I tried the overloaded PlayQueueItem with IMediaItem but it doesn't play the item specified in the queue.
await CrossMediaManager.Current.PlayQueueItem(CrossMediaManager.Current.Queue.FirstOrDefault());
Change it to any item in the queue it doesn't work as expected.

@janwiebe-jump
Copy link
Contributor

janwiebe-jump commented Oct 26, 2022

It might be caused by this line, but I'm unsure why:
https://github.com/Baseflow/XamarinMediaManager/blob/develop/MediaManager/Platforms/Android/MediaManagerImplementation.cs#L300

The queue of the MediaController is empty at this point, so that's might be why it cannot jump to the specified queue item.

@janwiebe-jump
Copy link
Contributor

janwiebe-jump commented Nov 2, 2022

@BenDTU What happens if you call an

await (MediaManagerBase)CrossMediaManager.Current).Play()

at the end?

This doesn't work for me.

I have no clue how to fix this, I hope someone else does, or has a workaround.

@szurgot
Copy link

szurgot commented Sep 16, 2023

Old issue, but I found it's due to the Transport Controls not being prepared.

https://github.com/Baseflow/XamarinMediaManager/blob/develop/MediaManager/Platforms/Android/MediaManagerImplementation.cs#L300

Adding this at line 302 fix it for me.
if (this.IsStopped())
MediaController.GetTransportControls().Prepare();

@arahmancsd
Copy link

Old issue, but I found it's due to the Transport Controls not being prepared.

https://github.com/Baseflow/XamarinMediaManager/blob/develop/MediaManager/Platforms/Android/MediaManagerImplementation.cs#L300

Adding this at line 302 fix it for me. if (this.IsStopped()) MediaController.GetTransportControls().Prepare();

@szurgot Would you mind creating a PR for this, please?

@szurgot
Copy link

szurgot commented Oct 4, 2023

@arahmancsd Here's the PR to fix this issue. #910

@BenDTU
Copy link
Author

BenDTU commented Jun 29, 2024

I tried adding the above PR but it still didn't work, playing a queue and then trying to play an item in that queue still results in the first item being played.

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

No branches or pull requests

7 participants