XamarinMediaManager icon indicating copy to clipboard operation
XamarinMediaManager copied to clipboard

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

Open BenDTU opened this issue 3 years ago • 12 comments

🐛 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

BenDTU avatar Apr 04 '22 13:04 BenDTU

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

BenDTU avatar Apr 05 '22 08:04 BenDTU

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

Dirwaz avatar Apr 20 '22 09:04 Dirwaz

same issue on android not playing

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

SalimiHabib avatar Jun 03 '22 18:06 SalimiHabib

Same exact behavior on my end too (Android app)

Shrp77 avatar Sep 10 '22 09:09 Shrp77

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.

arahmancsd avatar Oct 16 '22 00:10 arahmancsd

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 avatar Oct 26 '22 13:10 janwiebe-jump

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

janwiebe-jump avatar Nov 02 '22 14:11 janwiebe-jump

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 avatar Sep 16 '23 18:09 szurgot

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 avatar Sep 18 '23 08:09 arahmancsd

@arahmancsd Here's the PR to fix this issue. https://github.com/Baseflow/XamarinMediaManager/pull/910

szurgot avatar Oct 04 '23 21:10 szurgot