-
Notifications
You must be signed in to change notification settings - Fork 765
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
feat: add durationUpdate callback #197
Conversation
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
(Thanks for the updates on the text, I cleaned up the comments a bit by hiding.) Interesting change. I understand both parts of what you wrote:
But to be honest I don't really get how those are connected. Can you elaborate maybe? |
6a7b975
to
af39961
Compare
Yes, I can elaborate. In the newer versions of android, after about five minutes of background activity, android shuts down the web container that is running the app. So when you try to use a background task to query for the duration with a What I mean by subscribing, is basically just attaching a callback to allow the native code to run the callback when the audio player assigns duration. By doing this, you always get a real duration and don't have to worry about getting a "-1" duration as it only reports the duration after the audio player actually initializes and has the real duration. This removes the need to query for duration with a setTimeout, which prevents the situation above from happening. Does that help? |
I very much hoe so: If so, best add this as an "Android Quirk" under the |
Great! I'm getting ready to leave the office but I'll update the README later tonight after the kids go to bed. 👍 |
af39961
to
a2b5224
Compare
@janpio ugh, i'm sorry this took until Monday to get to! My weekend was a lot busier than I had planned on. I've updated the README with the Android quirk requested! :) |
Co-Authored-By: BuddyLReno <buddy.reno@daveramsey.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code looks good 💯 💕
Would prefer a second review from someone that actually tested the functionality. Maybe a demo app on GitHub one can checkout to "demo" the functionality @BuddyLReno?
Definitely. I'll write up a test app that utilizes this functionality and link it here. |
@janpio would it be alright if I created a test app using Ionic? I'm most familiar with that platform. |
Sure, whatever you are comfortable with. Shouldn't be to hard to recreate with Cordova though later on. Maybe I can fork your app then and transform it to pure Cordova. |
@janpio here's the demo project! Let me know if you have issues getting it to install. https://github.com/BuddyLReno/cordova-plugin-media-duration-demo |
Once we get this pr merged in, I'm going to update the media dependency to use the public one. |
Platforms affected
What does this PR do?
This particular change helps deal with the fact that Android shuts down webapps in the background after a few minutes. You can subscribe to this callback and let the audio player report the duration to you when it's available instead of querying for it.
What testing has been done on this change?
Physical device testing on:
Checklist