ionic-audio
ionic-audio copied to clipboard
Augment iAudioTrack with useful state change events
Basically, for change detection reasons my app needs access to these state changes so that I don't have to use setInterval. I need to be able to implement the OnPush change detection strategy, which is extremely hard when a setInterval is needed to detect changes to these objects.
The following events are added to IAudioTrack and implemented in both classes:
onLoaded: Subject<IAudioTrack>;
onPlaying: Subject<IAudioTrack>;
onStop: Subject<IAudioTrack>;
onPause: Subject<IAudioTrack>;
onFinished: Subject<IAudioTrack>;
onProgressChange: Subject<IAudioTrack>;
onError: Subject<IAudioTrackError>;
...
export interface IAudioTrackError {
track: IAudioTrack,
error: ErrorEvent,
}
This also incorporates #115 so you'll see the same set of changes.
@arielfaur let me know what you think. I'm not convinced this is the best implementation but it is the most obvious.
@codinronan thanks for reviewing my intents. This is exactly what I wanted. @arielfaur let us know if theses changes are ok for you