gaucidaniel / native-audio

MIT License
16 stars 7 forks source link

Seek Bar not updating - iOS and Android #14

Open Sun3 opened 4 years ago

Sun3 commented 4 years ago

It looks like the seek bar on the lock screen does not update for both iOS and Android.

Thank you.

YaarPatandarAA commented 4 years ago

Working on figuring out iOS Seek bar, hopefully have it by this weekend. Android only has seek bar for Android 10, have made a pull request for that. Waiting on @gaucidaniel to accept the pull.

Sun3 commented 4 years ago

That is great news, thank you.

gaucidaniel commented 4 years ago

Just accepted the pull request and will be releasing an update to the library tomorrow (eventually I'll hook this up to a CI flow). Once again, thanks for all of your work on this @YaarPatandarAA.

Sun3 commented 4 years ago

I did a quick look at the iOS swift code and to update the seek bar I looks like it needs the following code:

MPNowPlayingInfoCenter.default().nowPlayingInfo?[MPNowPlayingInfoPropertyElapsedPlaybackTime] = self.player.currentItem?.currentTime().seconds
YaarPatandarAA commented 4 years ago

Hmm, I tried something similar to this and it didn't work for me. I can give this another go and see if it makes any difference.

YaarPatandarAA commented 4 years ago

16 Adds the iOS Seek bar. Please give it a test and check. @Sun3

@gaucidaniel Please check if you might need to clean up the code.

YaarPatandarAA commented 4 years ago

Forgot to make the duration update based on Seek will submit it another pull request in morning.

Sun3 commented 4 years ago

I will test it once you get the new pull request. Thank you.

YaarPatandarAA commented 4 years ago

@Sun3 sorry for the delay, thought I would have time this morning to get it done and pushed. Pull request #16 should have the updated code with seek bar elapsed time update and the other seek bar code to have a working iOS Seek Bar. @gaucidaniel you can go ahead and check the code and then merge.

YaarPatandarAA commented 4 years ago

Android Media Notification has a problem where it will not show the seek bar on the initial played media and for the next played media it will show the total duration from the previous played media. This is due to the notification being shown before the total duration is loaded. Thus making MediaMetadata.METADATA_KEY_DURATION contain a 0 value.

17 Fixes this issue by moving the metadata to private var outside the scope the function. Setting them in the Play function and calling show notification when loaded and passing the metadata.

Tested and Working. @gaucidaniel you can go ahead and check the code and then merge.

Sun3 commented 4 years ago

@YaarPatandarAA I manually tested the iOS changes and they work great. I look forward to the Android Seek Bar.

Thank you so much.

YaarPatandarAA commented 4 years ago

@Sun3 Android seekbar should be working and already pulled by @gaucidaniel. There was a issues with it not showing the seek bar for the initial media played which I made a pull request for fixing. Please check out pull request #17 for a fully working Android Seek Bar.

Please do note that Android Seek bar is only available on Android 10.

Sun3 commented 4 years ago

@YaarPatandarAA Got it. I tested with Android 10 and works great (with #17) . I would love to see support for the Android Seek Bar with earlier version of Android. For example Android 8.1 only has a little over 1% of the users.

Thank you.

YaarPatandarAA commented 4 years ago

@Sun3 Android does NOT have seek bar on any android version other than Android 10. SeekBar in MediaStyle notifications was introduced in Android 10. Please refer too the following: https://developer.android.com/about/versions/10/features#media-notifications

Sun3 commented 4 years ago

Thanks for clarifying. Coming from the iOS platform I am a bit spoiled :)

YaarPatandarAA commented 4 years ago

This can be closed now @gaucidaniel