Has anyone actually implemented an audio player on android using Ionic 2? I’ve tried using the Media Plugin, but there’s several issues with it, one of which is that the duration seems to almost always return -1; on very rare occasions, with the exact same code - of doing .getDuration() after preparing the mediaObject - have I actually gotten the audio duration.
@arfons Hey I think I have a solution for this…In my app, I wait until the audio begins to play by polling the .getCurrentPosition() until it returns a value, then do your .getDuration(). Sadly this way you can’t display the duration before the user plays the audio, but it solves the -1 issue.
I learned that the audio needs to be playing before it will return the duration properly. This fixed in the new version of the Media plugin, but there are other issues with that one so stick with this one for now. Hope this helps
@mcihak If I remember correctly there were issues with the version of the Media Plugin which had this error…try updating to the latest cordova plugins…or downgrading the plugin to an earlier release (which may have other bugs that may not effect you)…in the end I went with a WebAudio solution until this all gets straightened out.