Calling 'playQueueItem' immediately after changing the queue doesn't play, immediately resets queue when play called again later
🐛 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:
- [ ] :iphone: iOS
- [x] :robot: Android
- [ ] :checkered_flag: WPF
- [ ] :earth_americas: UWP
- [ ] :apple: MacOS
- [ ] :tv: tvOS
- [ ] :monkey: Xamarin.Forms
Quick update - can confirm that this isn't an issue running on iOS.
i am having the same issue on Android only. on iOS it is working fine.
same issue on android not playing
var inx = _mediaManager.Queue.IndexOf((IMediaItem)obj);
var r = await _mediaManager.PlayQueueItem(inx);
Same exact behavior on my end too (Android app)
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.
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.
~~@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.
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();
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?
@arahmancsd Here's the PR to fix this issue. https://github.com/Baseflow/XamarinMediaManager/pull/910