[network/neochat] src/messagecontent: Fix autoplay of audio message after downloading

Joshua Goins <[email protected]>
Newsgroups gmane.comp.kde.cvs
Message-ID <[email protected]>
Git commit aa22b86bff639117ac68f1165cb5e0318f0a2e4d by Joshua Goins.
Committed on 03/08/2026 at 20:29.
Pushed by redstrate into branch 'master'.

Fix autoplay of audio message after downloading

This was intended behavior, but didn't work for whatever reason.

CCBUG: 523783

M  +9    -7    src/messagecontent/AudioComponent.qml

https://invent.kde.org/network/neochat/-/commit/aa22b86bff639117ac68f1165cb5e0318f0a2e4d

diff --git a/src/messagecontent/AudioComponent.qml b/src/messagecontent/AudioComponent.qml
index ab5b6b061..012e3ffb4 100644
--- a/src/messagecontent/AudioComponent.qml
+++ b/src/messagecontent/AudioComponent.qml
@@ -32,8 +32,8 @@ ColumnLayout {
      * @brief Whether the media has been downloaded.
      */
     readonly property bool downloaded: block.fileTransferInfo && block.fileTransferInfo.completed
-    onDownloadedChanged: if (downloaded) {
-        audio.play();
+    onDownloadedChanged:  if (downloaded) {
+        beginPlayback();
     }
 
     /**
@@ -41,6 +41,12 @@ ColumnLayout {
      */
     required property bool editable
 
+    function beginPlayback(): void {
+        audio.source = root.block.fileTransferInfo.localPath;
+        MediaManager.startPlayback();
+        audio.play();
+    }
+
     MediaPlayer {
         id: audio
         onErrorOccurred: (error, errorString) => console.warn("Audio playback error:" + error + errorString)
@@ -75,11 +81,7 @@ ColumnLayout {
             when: root.block.fileTransferInfo.completed && (audio.playbackState === MediaPlayer.StoppedState || audio.playbackState === MediaPlayer.PausedState)
             PropertyChanges {
                 playButton.icon.name: "media-playback-start"
-                playButton.onClicked: {
-                    audio.source = root.block.fileTransferInfo.localPath;
-                    MediaManager.startPlayback();
-                    audio.play();
-                }
+                playButton.onClicked: root.beginPlayback()
             }
         },
         State {
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.