diff options
author | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-06-10 06:33:05 +0300 |
---|---|---|
committer | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-06-10 06:33:05 +0300 |
commit | fdfd11b8a1a2d00c850039c8237208010236f765 (patch) | |
tree | 91b43b5f018312913d81fc0c3c27b4a9d63ea80f /src/ui | |
parent | f63ed76597b462c60b3a6ad89f8c165ffb87d00c (diff) |
DocumentWidget: Pause audio when document changes
While document media is now kept in memory even in history, it's quite strange if audio players keep playing on a page viewed in the past without a way to control the playback.
Diffstat (limited to 'src/ui')
-rw-r--r-- | src/ui/documentwidget.c | 6 |
1 files changed, 5 insertions, 1 deletions
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 | ||