mirror of
https://github.com/chuot/rdio-scanner.git
synced 2026-08-13 16:33:01 -06:00
Radio.service progress handler optimizations
This commit is contained in:
parent
c821b09a85
commit
dbc866b7eb
|
|
@ -316,17 +316,24 @@ export class AppRadioService implements OnDestroy {
|
||||||
private _configureAudio(): void {
|
private _configureAudio(): void {
|
||||||
if (!this._audio) {
|
if (!this._audio) {
|
||||||
let playing = false;
|
let playing = false;
|
||||||
|
let progress = 0;
|
||||||
let watchdog = null;
|
let watchdog = null;
|
||||||
|
|
||||||
const progressHandler = () => {
|
const progressHandler = () => {
|
||||||
if (this._call.current && playing) {
|
if (this._call.current && playing) {
|
||||||
|
// Hack for audio.currentTime that sometime returns unreliable values
|
||||||
|
if (this._audio.currentTime - progress < 5) {
|
||||||
this._emitTimeEvent();
|
this._emitTimeEvent();
|
||||||
|
}
|
||||||
|
|
||||||
|
progress = this._audio.currentTime;
|
||||||
|
|
||||||
if (watchdog) {
|
if (watchdog) {
|
||||||
clearTimeout(watchdog);
|
clearTimeout(watchdog);
|
||||||
}
|
}
|
||||||
|
|
||||||
watchdog = setTimeout(() => stopHandler(), 2000);
|
// Hack for IOS devices that don't always send stop events
|
||||||
|
watchdog = setTimeout(() => stopHandler(), 1000);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue