Skip to content
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Address code review feedback: fix sentinel value, preserve audio titl…
…e, simplify JS checks

Agent-Logs-Url: https://github.com/ArcaneChat/android/sessions/57af82f8-b482-4d5a-977f-fc74ffd48db3

Co-authored-by: adbenitez <24558636+adbenitez@users.noreply.github.com>
  • Loading branch information
Copilot and adbenitez authored Apr 12, 2026
commit 3f442377e73cacb07c9c072dbf2034810bdbf653
5 changes: 4 additions & 1 deletion src/main/java/org/thoughtcrime/securesms/WebxdcActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ public class WebxdcActivity extends WebViewActivity implements DcEventCenter.DcE
private TextToSpeech tts;

private boolean isAudioPlaying = false;
private String currentAudioTitle = "";
private @Nullable MediaController webxdcMediaController;
private @Nullable ListenableFuture<MediaController> webxdcMediaControllerFuture;
private @Nullable BroadcastReceiver notificationControlReceiver;
Expand Down Expand Up @@ -824,6 +825,7 @@ public void notifyAudioStarted(String title) {
() -> {
if (webxdcMediaController == null) return;
isAudioPlaying = true;
currentAudioTitle = title;
Bundle args = new Bundle();
args.putString("title", title);
args.putString(
Expand All @@ -846,6 +848,7 @@ public void notifyAudioStopped() {
() -> {
if (webxdcMediaController == null) return;
isAudioPlaying = false;
currentAudioTitle = "";
webxdcMediaController.sendCustomCommand(
new SessionCommand(WebxdcMediaSessionService.COMMAND_AUDIO_STOPPED, new Bundle()),
Bundle.EMPTY);
Expand Down Expand Up @@ -877,7 +880,7 @@ public void notifyAudioResumed() {
if (webxdcMediaController == null) return;
isAudioPlaying = true;
Bundle args = new Bundle();
args.putString("title", "");
args.putString("title", currentAudioTitle);
args.putString(
"artist",
WebxdcActivity.this.dcAppMsg.getWebxdcInfo().optString("name", ""));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,13 +268,12 @@ public ListenableFuture<SessionResult> onCustomCommand(
// -------------------------------------------------------------------------

private void handleAudioStarted(Bundle args) {
if (args == null) args = Bundle.EMPTY;
String title = args.getString("title", "");
String artist = args.getString("artist", "");
int msgId = args.getInt("msg_id", 0);
int accountId = args.getInt("account_id", 0);

if (msgId != 0) {
if (args.containsKey("msg_id")) {
int msgId = args.getInt("msg_id");
int accountId = args.getInt("account_id", 0);
updateSessionActivity(accountId, msgId);
}
if (stubPlayer != null) {
Expand Down
12 changes: 3 additions & 9 deletions src/main/res/raw/webxdc.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,19 +191,13 @@ window.webxdc = (() => {
if (el._arcaneMediaListened) return;
el._arcaneMediaListened = true;
el.addEventListener('play', function() {
if (typeof InternalJSApi !== 'undefined' && InternalJSApi.notifyAudioStarted) {
InternalJSApi.notifyAudioStarted(document.title || '');
}
if (window.InternalJSApi) InternalJSApi.notifyAudioStarted(document.title || '');
});
el.addEventListener('pause', function() {
if (typeof InternalJSApi !== 'undefined' && InternalJSApi.notifyAudioPaused) {
InternalJSApi.notifyAudioPaused();
}
if (window.InternalJSApi) InternalJSApi.notifyAudioPaused();
});
el.addEventListener('ended', function() {
if (typeof InternalJSApi !== 'undefined' && InternalJSApi.notifyAudioStopped) {
InternalJSApi.notifyAudioStopped();
}
if (window.InternalJSApi) InternalJSApi.notifyAudioStopped();
});
})(elements[i]);
}
Expand Down