diff options
-rw-r--r-- | src/media.c | 9 | ||||
-rw-r--r-- | src/media.h | 1 | ||||
-rw-r--r-- | src/ui/documentwidget.c | 6 |
3 files changed, 15 insertions, 1 deletions
diff --git a/src/media.c b/src/media.c index 2ec2109d..180c28e6 100644 --- a/src/media.c +++ b/src/media.c | |||
@@ -469,6 +469,15 @@ iPlayer *audioPlayer_Media(const iMedia *d, iMediaId audioId) { | |||
469 | return NULL; | 469 | return NULL; |
470 | } | 470 | } |
471 | 471 | ||
472 | void pauseAllPlayers_Media(const iMedia *d, iBool setPaused) { | ||
473 | for (size_t i = 0; i < size_PtrArray(&d->audio); ++i) { | ||
474 | const iGmAudio *audio = constAt_PtrArray(&d->audio, i); | ||
475 | if (audio->player) { | ||
476 | setPaused_Player(audio->player, setPaused); | ||
477 | } | ||
478 | } | ||
479 | } | ||
480 | |||
472 | iBool downloadInfo_Media(const iMedia *d, iMediaId downloadId, iGmMediaInfo *info_out) { | 481 | iBool downloadInfo_Media(const iMedia *d, iMediaId downloadId, iGmMediaInfo *info_out) { |
473 | if (downloadId > 0 && downloadId <= size_PtrArray(&d->downloads)) { | 482 | if (downloadId > 0 && downloadId <= size_PtrArray(&d->downloads)) { |
474 | const iGmDownload *dl = constAt_PtrArray(&d->downloads, downloadId - 1); | 483 | const iGmDownload *dl = constAt_PtrArray(&d->downloads, downloadId - 1); |
diff --git a/src/media.h b/src/media.h index c6973b79..f7ad6efd 100644 --- a/src/media.h +++ b/src/media.h | |||
@@ -61,6 +61,7 @@ size_t numAudio_Media (const iMedia *); | |||
61 | iMediaId findLinkAudio_Media (const iMedia *, uint16_t linkId); | 61 | iMediaId findLinkAudio_Media (const iMedia *, uint16_t linkId); |
62 | iBool audioInfo_Media (const iMedia *, iMediaId audioId, iGmMediaInfo *info_out); | 62 | iBool audioInfo_Media (const iMedia *, iMediaId audioId, iGmMediaInfo *info_out); |
63 | iPlayer * audioPlayer_Media (const iMedia *, iMediaId audioId); | 63 | iPlayer * audioPlayer_Media (const iMedia *, iMediaId audioId); |
64 | void pauseAllPlayers_Media(const iMedia *, iBool setPaused); | ||
64 | 65 | ||
65 | iMediaId findLinkDownload_Media (const iMedia *, uint16_t linkId); | 66 | iMediaId findLinkDownload_Media (const iMedia *, uint16_t linkId); |
66 | iBool downloadInfo_Media (const iMedia *, iMediaId downloadId, iGmMediaInfo *info_out); | 67 | iBool downloadInfo_Media (const iMedia *, iMediaId downloadId, iGmMediaInfo *info_out); |
diff --git a/src/ui/documentwidget.c b/src/ui/documentwidget.c index 29e264e8..a3ac208a 100644 --- a/src/ui/documentwidget.c +++ b/src/ui/documentwidget.c | |||
@@ -392,6 +392,7 @@ void init_DocumentWidget(iDocumentWidget *d) { | |||
392 | } | 392 | } |
393 | 393 | ||
394 | void deinit_DocumentWidget(iDocumentWidget *d) { | 394 | void deinit_DocumentWidget(iDocumentWidget *d) { |
395 | pauseAllPlayers_Media(media_GmDocument(d->doc), iTrue); | ||
395 | removeTicker_App(animate_DocumentWidget_, d); | 396 | removeTicker_App(animate_DocumentWidget_, d); |
396 | removeTicker_App(prerender_DocumentWidget_, d); | 397 | removeTicker_App(prerender_DocumentWidget_, d); |
397 | remove_Periodic(periodic_App(), d); | 398 | remove_Periodic(periodic_App(), d); |
@@ -1046,6 +1047,7 @@ void setSource_DocumentWidget(iDocumentWidget *d, const iString *source) { | |||
1046 | } | 1047 | } |
1047 | 1048 | ||
1048 | static void replaceDocument_DocumentWidget_(iDocumentWidget *d, iGmDocument *newDoc) { | 1049 | static void replaceDocument_DocumentWidget_(iDocumentWidget *d, iGmDocument *newDoc) { |
1050 | pauseAllPlayers_Media(media_GmDocument(d->doc), iTrue); | ||
1049 | iRelease(d->doc); | 1051 | iRelease(d->doc); |
1050 | d->doc = ref_Object(newDoc); | 1052 | d->doc = ref_Object(newDoc); |
1051 | documentWasChanged_DocumentWidget_(d); | 1053 | documentWasChanged_DocumentWidget_(d); |
@@ -1581,6 +1583,7 @@ static void updateFromCachedResponse_DocumentWidget_(iDocumentWidget *d, float n | |||
1581 | clear_ObjectList(d->media); | 1583 | clear_ObjectList(d->media); |
1582 | delete_Gempub(d->sourceGempub); | 1584 | delete_Gempub(d->sourceGempub); |
1583 | d->sourceGempub = NULL; | 1585 | d->sourceGempub = NULL; |
1586 | pauseAllPlayers_Media(media_GmDocument(d->doc), iTrue); | ||
1584 | iRelease(d->doc); | 1587 | iRelease(d->doc); |
1585 | destroy_Widget(d->footerButtons); | 1588 | destroy_Widget(d->footerButtons); |
1586 | d->footerButtons = NULL; | 1589 | d->footerButtons = NULL; |
@@ -1867,6 +1870,7 @@ static void checkResponse_DocumentWidget_(iDocumentWidget *d) { | |||
1867 | /* Keep scroll position when reloading the same page. */ | 1870 | /* Keep scroll position when reloading the same page. */ |
1868 | reset_SmoothScroll(&d->scrollY); | 1871 | reset_SmoothScroll(&d->scrollY); |
1869 | } | 1872 | } |
1873 | pauseAllPlayers_Media(media_GmDocument(d->doc), iTrue); | ||
1870 | iRelease(d->doc); /* new content incoming */ | 1874 | iRelease(d->doc); /* new content incoming */ |
1871 | d->doc = new_GmDocument(); | 1875 | d->doc = new_GmDocument(); |
1872 | delete_Gempub(d->sourceGempub); | 1876 | delete_Gempub(d->sourceGempub); |
@@ -4673,7 +4677,7 @@ void setUrlAndSource_DocumentWidget(iDocumentWidget *d, const iString *url, cons | |||
4673 | initCurrent_Time(&resp->when); | 4677 | initCurrent_Time(&resp->when); |
4674 | set_String(&resp->meta, mime); | 4678 | set_String(&resp->meta, mime); |
4675 | set_Block(&resp->body, source); | 4679 | set_Block(&resp->body, source); |
4676 | updateFromCachedResponse_DocumentWidget_(d, 0, resp); | 4680 | updateFromCachedResponse_DocumentWidget_(d, 0, resp, NULL); |
4677 | delete_GmResponse(resp); | 4681 | delete_GmResponse(resp); |
4678 | } | 4682 | } |
4679 | 4683 | ||