arielfaur / ionic-audio

An audio player for Ionic 3 and Angular 4. Works with HTML 5 audio or native audio using Cordova Media plugin.
http://arielfaur.github.io/ionic-audio/2.0/index.html
MIT License
321 stars 163 forks source link

Structure of this._audioProvider.tracks duration seeking #198

Open rdai opened 6 years ago

rdai commented 6 years ago

Hi,

I am trying to store the location of the last play/pause event, then move the progress to that location on the next launch, a common feature I feel I should provide. I have my project all working nicely then I realized it breaks for Android <=5? Because I am storing the entire this._audioProvider.tracks[i] object via something like this.storage.set(curTrack, this._audioProvider.tracks[audioID]); and the Storage module uses JSON.stringfy which threws an error about circular reference for Android <=5.

It is bit of a mystery why it worked on Android 7 anyway since it is still calling JSON.stringfy I am assuming?

I am storing the whole object as opposed to individual pieces because I spent a lot of time trying to figure out the structure of the this._audioProvider.tracks[audioID]) and manually setting duration progress and completed doesn't seem to get the job done because some of the variables are private/not writable?

I tried to use other JSON stringfy libraries but that means I have to not use Storage or hack it.

Anyway, any advice would be welcome. Maybe on the structure of the this._audioProvider.tracks[audioID]), or advice on how to storage progress and duration and setting those on next launch. Thanks!