Bug 23171 - MediaPlayer.CurrentPosition Keeps Progressing After a Play/Pause Cycle
Summary: MediaPlayer.CurrentPosition Keeps Progressing After a Play/Pause Cycle
Status: RESOLVED UPSTREAM
Alias: None
Product: Android
Classification: Xamarin
Component: General ()
Version: 4.18.0
Hardware: PC Mac OS
: --- normal
Target Milestone: ---
Assignee: dean.ellis
URL:
Depends on:
Blocks:
 
Reported: 2014-09-18 21:52 UTC by Cody Beyer (MSFT)
Modified: 2014-10-12 14:15 UTC (History)
4 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED UPSTREAM

Description Cody Beyer (MSFT) 2014-09-18 21:52:32 UTC
When Play and Pause are called in a quick succession on Android's MediaPlayer, the CurrentPosition is updated like the song is playing.

Sample project (make sure to set it to a correct song in Game1.cs:44):

https://mega.co.nz/#!sZ81nIbA!8eiajEmn9BBU6Y90wtriiLiOmEywGMsFhc5GS6C7yak

Xamarin 3.5.58.0 (6b70b1e28c5a733187f7659220da4c0ff61ab2b1)

Visual Studio extension to enable development for Xamarin.iOS and
Xamarin.Android
Comment 3 dean.ellis 2014-09-26 06:35:10 UTC
It looks like there are a host of issues with the underlying android media player see

http://code.google.com/p/android/issues/detail?id=11590
http://code.google.com/p/android/issues/detail?id=2559
http://stackoverflow.com/questions/9437304/videoview-getcurrentposition-irregularity-on-acer-iconia-a200

So I knocked up a sample in Java and managed to get it to exhibit the same behaviour, but only on short .wav files. longer .mp3 songs seemed to work ok. So this looks like an upstream issue. 

That said it does look like the media player is correctly reporting when it is paused. So this probably needs to be worked around within the MonoGame framework. Something like this might do the trick

https://gist.github.com/dellis1972/3388ac1cda466ebff2a1

It seems to work here locally. If you can confirm then I'll submit a PR to the MonoGame guys to see if we can get this fixed.
Comment 4 Adam Kapos 2014-10-02 18:01:06 UTC
Hello Dean!
I hope you received my message from the support team. Did you have a chance to submit this to MonoGame yet?
Comment 5 dean.ellis 2014-10-03 04:03:29 UTC
Hi Adam

I was waiting to hear if the work around I posted worked for you too? If it does then I'll submit a PR this weekend
Comment 6 Adam Kapos 2014-10-03 04:27:04 UTC
Yes, it worked :)
Comment 7 dean.ellis 2014-10-03 04:31:24 UTC
Awesome, I'll put this PR up over the weekend
Comment 8 Adam Kapos 2014-10-11 08:22:14 UTC
Did you submit the PR?
Comment 9 Adam Kapos 2014-10-12 14:15:51 UTC
I have submitted it:
https://github.com/mono/MonoGame/pull/3074