From 86c28576cca47e5a7e23dc9116604880d684665b Mon Sep 17 00:00:00 2001

From: =?UTF-8?q?Jaakko=20Ker=C3=A4nen?= jaakko.keranen@iki.fi

Date: Sun, 11 Oct 2020 13:18:00 +0300

Subject: [PATCH 1/1] Media: Pause other players when a new one starts


src/media.c | 8 +++++++-

src/media.h | 1 +

src/ui/documentwidget.c | 14 ++++++++++++++

3 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/src/media.c b/src/media.c

index c0d6d3de..dcda0664 100644

--- a/src/media.c

+++ b/src/media.c

@@ -24,6 +24,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */

#include "gmdocument.h"

#include "ui/window.h"

#include "audio/player.h"

+#include "app.h"

#include <the_Foundation/ptrarray.h>

#include <stb_image.h>

@@ -214,8 +215,9 @@ void setData_Media(iMedia *d, iGmLinkId linkId, const iString *mime, const iBloc

             updateSourceData_Player(audio->player, NULL, NULL, complete_PlayerUpdate);

         }

         pushBack_PtrArray(&d->audio, audio);

         start_Player(audio->player);

     }

 }

}

@@ -231,6 +233,10 @@ iMediaId findLinkImage_Media(const iMedia *d, iGmLinkId linkId) {

 return 0;

}

+size_t numAudio_Media(const iMedia *d) {

+}

iMediaId findLinkAudio_Media(const iMedia *d, iGmLinkId linkId) {

 /* TODO: use a hash */

 iConstForEach(PtrArray, i, &d->audio) {

diff --git a/src/media.h b/src/media.h

index c19ad8ae..9db6659d 100644

--- a/src/media.h

+++ b/src/media.h

@@ -60,6 +60,7 @@ iMediaId findLinkImage_Media (const iMedia *, uint16_t linkId);

iBool imageInfo_Media (const iMedia *, iMediaId imageId, iGmImageInfo *info_out);

SDL_Texture * imageTexture_Media (const iMedia *, iMediaId imageId);

+size_t numAudio_Media (const iMedia *);

iMediaId findLinkAudio_Media (const iMedia *, uint16_t linkId);

iBool audioInfo_Media (const iMedia *, iMediaId audioId, iGmAudioInfo *info_out);

iPlayer * audioPlayer_Media (const iMedia *, iMediaId audioId);

diff --git a/src/ui/documentwidget.c b/src/ui/documentwidget.c

index b977e4d9..573cd3e3 100644

--- a/src/ui/documentwidget.c

+++ b/src/ui/documentwidget.c

@@ -1421,6 +1421,18 @@ static iBool handleCommand_DocumentWidget_(iDocumentWidget *d, const char *cmd)

 else if (equal_Command(cmd, "media.updated") || equal_Command(cmd, "media.finished")) {

     return handleMediaCommand_DocumentWidget_(d, cmd);

 }

 else if (equal_Command(cmd, "document.stop") && document_App() == d) {

     if (d->request) {

         postCommandf_App(

@@ -2064,6 +2076,8 @@ static iBool processEvent_DocumentWidget_(iDocumentWidget *d, const SDL_Event *e

                                 if (!isFinished_GmRequest(req->req)) {

                                     cancel_GmRequest(req->req);

                                     removeMediaRequest_DocumentWidget_(d, linkId);

                                 }

                             }

                             redoLayout_GmDocument(d->doc);

--

2.25.1

Proxy Information
Original URL
gemini://git.skyjake.fi/lagrange/work%2Fv1.7/patch/86c28576cca47e5a7e23dc9116604880d684665b.patch
Status Code
Success (20)
Meta
text/plain
Capsule Response Time
56.10151 milliseconds
Gemini-to-HTML Time
1.399864 milliseconds

This content has been proxied by September (ba2dc).