зеркало из https://github.com/GoogleChrome/kino.git
Merge pull request #177 from GoogleChrome/fix/pause-downloads
Fix download auto-pausing when network is cut
This commit is contained in:
Коммит
9a352a1479
|
@ -226,7 +226,11 @@ export default class DownloadManager {
|
|||
*/
|
||||
forcePause() {
|
||||
this.pause();
|
||||
this.internal.videoDownloader.downloading = false;
|
||||
|
||||
if (document) {
|
||||
const pauseEvent = new CustomEvent('pausedownload', { detail: this.videoId });
|
||||
document.dispatchEvent(pauseEvent);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -27,6 +27,10 @@ export default class VideoDownloaderRegistry {
|
|||
constructor({ connectionStatus }) {
|
||||
this.instances = new Map();
|
||||
this.connectionStatus = connectionStatus;
|
||||
|
||||
if (document) {
|
||||
document.addEventListener('pausedownload', this.onPauseDownload.bind(this));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -67,4 +71,18 @@ export default class VideoDownloaderRegistry {
|
|||
destroyAll() {
|
||||
this.instances.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* When a pause request is received, we need to pause the download.
|
||||
*
|
||||
* @param {CustomEvent} e Pause event.
|
||||
* @param {string} e.detail Video ID.
|
||||
*/
|
||||
onPauseDownload(e) {
|
||||
const downloaderInstance = this.get(e.detail);
|
||||
|
||||
if (downloaderInstance) {
|
||||
downloaderInstance.downloading = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче