[1mdiff --git a/src/media.c b/src/media.c[m
[1mindex c0d6d3de..dcda0664 100644[m
[1m--- a/src/media.c[m
[1m+++ b/src/media.c[m
[36m@@ -24,6 +24,7 @@[m [mSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */[m
#include "gmdocument.h"[m
#include "ui/window.h"[m
#include "audio/player.h"[m
[32m+[m[32m#include "app.h"[m
[m
#include <the_Foundation/ptrarray.h>[m
#include <stb_image.h>[m
[36m@@ -214,8 +215,9 @@[m [mvoid setData_Media(iMedia *d, iGmLinkId linkId, const iString *mime, const iBloc[m
updateSourceData_Player(audio->player, NULL, NULL, complete_PlayerUpdate);[m
}[m
pushBack_PtrArray(&d->audio, audio);[m
[31m- /* TEST: Start playing right away. */[m
[32m+[m[32m /* Start playing right away. */[m
start_Player(audio->player);[m
[32m+[m[32m postCommandf_App("media.player.started player:%p", audio->player);[m
}[m
}[m
}[m
[36m@@ -231,6 +233,10 @@[m [miMediaId findLinkImage_Media(const iMedia *d, iGmLinkId linkId) {[m
return 0;[m
}[m
[m
[32m+[m[32msize_t numAudio_Media(const iMedia *d) {[m
[32m+[m[32m return size_PtrArray(&d->audio);[m
[32m+[m[32m}[m
[32m+[m
iMediaId findLinkAudio_Media(const iMedia *d, iGmLinkId linkId) {[m
/* TODO: use a hash */[m
iConstForEach(PtrArray, i, &d->audio) {[m
[1mdiff --git a/src/media.h b/src/media.h[m
[1mindex c19ad8ae..9db6659d 100644[m
[1m--- a/src/media.h[m
[1m+++ b/src/media.h[m
[36m@@ -60,6 +60,7 @@[m [miMediaId findLinkImage_Media (const iMedia *, uint16_t linkId);[m
iBool imageInfo_Media (const iMedia *, iMediaId imageId, iGmImageInfo *info_out);[m
SDL_Texture * imageTexture_Media (const iMedia *, iMediaId imageId);[m
[m
[32m+[m[32msize_t numAudio_Media (const iMedia *);[m
iMediaId findLinkAudio_Media (const iMedia *, uint16_t linkId);[m
iBool audioInfo_Media (const iMedia *, iMediaId audioId, iGmAudioInfo *info_out);[m
iPlayer * audioPlayer_Media (const iMedia *, iMediaId audioId);[m
[1mdiff --git a/src/ui/documentwidget.c b/src/ui/documentwidget.c[m
[1mindex b977e4d9..573cd3e3 100644[m
[1m--- a/src/ui/documentwidget.c[m
[1m+++ b/src/ui/documentwidget.c[m
[36m@@ -1421,6 +1421,18 @@[m [mstatic iBool handleCommand_DocumentWidget_(iDocumentWidget *d, const char *cmd)[m
else if (equal_Command(cmd, "media.updated") || equal_Command(cmd, "media.finished")) {[m
return handleMediaCommand_DocumentWidget_(d, cmd);[m
}[m
[32m+[m[32m else if (equal_Command(cmd, "media.player.started")) {[m
[32m+[m[32m /* When one media player starts, pause the others that may be playing. */[m
[32m+[m[32m const iPlayer *startedPlr = pointerLabel_Command(cmd, "player");[m
[32m+[m[32m const iMedia * media = media_GmDocument(d->doc);[m
[32m+[m[32m const size_t num = numAudio_Media(media);[m
[32m+[m[32m for (size_t id = 1; id <= num; id++) {[m
[32m+[m[32m iPlayer *plr = audioPlayer_Media(media, id);[m
[32m+[m[32m if (plr != startedPlr) {[m
[32m+[m[32m setPaused_Player(plr, iTrue);[m
[32m+[m[32m }[m
[32m+[m[32m }[m
[32m+[m[32m }[m
else if (equal_Command(cmd, "document.stop") && document_App() == d) {[m
if (d->request) {[m
postCommandf_App([m
[36m@@ -2064,6 +2076,8 @@[m [mstatic iBool processEvent_DocumentWidget_(iDocumentWidget *d, const SDL_Event *e[m
if (!isFinished_GmRequest(req->req)) {[m
cancel_GmRequest(req->req);[m
removeMediaRequest_DocumentWidget_(d, linkId);[m
[32m+[m[32m /* Note: Some of the audio IDs have changed now, layout must[m
[32m+[m[32m be redone. */[m
}[m
}[m
redoLayout_GmDocument(d->doc);[m
text/plain
This content has been proxied by September (ba2dc).