<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Play multiple mp3 files with QMediaPlayer]]></title><description><![CDATA[<p dir="auto">Hi everybody,<br />
I am trying to develop a software that can play sound from mp3 files, I am trying to do this with QMediaPlayer but it only plays the last file that i give him, here is my code:</p>
<pre><code>self.player=QMediaPlayer()
self.audioOutput = QAudioOutput()

self.player.setAudioOutput(self.audioOutput)

self.player.setSource(QUrl.fromLocalFile(“sound/001000.mp3”))

self.player.play()

while self.player.isPlaying():

time.sleep(2)

self.player.setSource(QUrl.fromLocalFile(“sound/001001.mp3”))

self.player.play()
</code></pre>
]]></description><link>https://forum.qt.io/topic/164351/play-multiple-mp3-files-with-qmediaplayer</link><generator>RSS for Node</generator><lastBuildDate>Wed, 22 Apr 2026 11:28:16 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/164351.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 02 Mar 2026 07:44:59 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Play multiple mp3 files with QMediaPlayer on Thu, 05 Mar 2026 16:18:33 GMT]]></title><description><![CDATA[<p dir="auto">I found a solution, it involves in connecting the signal "playingChanged" of QMediaPlayer to a function that plays the next track.</p>
<pre><code>self.player=QMediaPlayer()
self.audioOutput = QAudioOutput()
self.player.setAudioOutput(self.audioOutput)
self.player.playingChanged.connect(self.play_next)

def play_next(self):
    if self.player.playbackState()!=QMediaPlayer.PlaybackState.PlayingState:
        self.player.setSource(QUrl.fromLocalFile("next_track.mp3")) 
        self.player.play()
</code></pre>
]]></description><link>https://forum.qt.io/post/836812</link><guid isPermaLink="true">https://forum.qt.io/post/836812</guid><dc:creator><![CDATA[Mahmoud_213]]></dc:creator><pubDate>Thu, 05 Mar 2026 16:18:33 GMT</pubDate></item><item><title><![CDATA[Reply to Play multiple mp3 files with QMediaPlayer on Mon, 02 Mar 2026 08:44:14 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/mahmoud_213">@<bdi>Mahmoud_213</bdi></a><br />
I know nothing about this, but by the sound of it the Qt event loop needs to be running for stuff to play/sound?  So you cannot use <code>time.sleep(2)</code> and then change the source I imagine?  Remove that and replace with a <code>QTimer()</code> for 2 seconds: in the slot attached to that change the source for the player.  I am guessing that is what is required.</p>
]]></description><link>https://forum.qt.io/post/836701</link><guid isPermaLink="true">https://forum.qt.io/post/836701</guid><dc:creator><![CDATA[JonB]]></dc:creator><pubDate>Mon, 02 Mar 2026 08:44:14 GMT</pubDate></item></channel></rss>