@@ -221,6 +221,21 @@ MainView {
221221 }
222222 }
223223
224+ // This reduces incidences of media-hub getting confused and
225+ // continuing to play the previous file when clearing a playlist
226+ // and starting a new episode
227+ Timer {
228+ id: playStarter
229+ interval: 500
230+ onTriggered: {
231+ // Ideally we'd check the buffer progress here and base it on that
232+ // but media-hub doesn't report it correctly
233+ console.log("Starting playback")
234+ player.play()
235+ player.restorePosition()
236+ }
237+ }
238+
224239 MediaPlayer {
225240 id: player
226241
@@ -275,6 +290,14 @@ MainView {
275290 }
276291 }
277292
293+ function restorePosition() {
294+ if (playbackState === MediaPlayer.PlayingState && pendingSeek !== 0) {
295+ player.seek(pendingSeek)
296+ player.clearPosition()
297+ pendingSeek = 0;
298+ }
299+ }
300+
278301 function clearPosition() {
279302 if (currentGuid) {
280303 var db = Podcasts.init()
@@ -285,6 +308,8 @@ MainView {
285308 }
286309
287310 function playEpisode(guid, image, name, artist, url, position) {
311+ player.pause()
312+
288313 // Clear current queue
289314 player.playlist.clear()
290315 Podcasts.clearQueue()
@@ -295,7 +320,7 @@ MainView {
295320
296321 // Play episode
297322 pendingSeek = position
298− player.play()
323+ playStarter.restart()
299324 }
300325
301326 function addEpisodeToQueue(guid, image, name, artist, url, position) {
@@ -337,23 +362,11 @@ MainView {
337362 }
338363
339364 onPlaybackStateChanged: {
340− if (playbackState === MediaPlayer.PlayingState && pendingSeek !== 0) {
341− player.seek(pendingSeek)
342− player.clearPosition()
343− pendingSeek = 0;
344− }
365+ restorePosition()
345366 }
346367
347368 onStatusChanged: {
348− if (status === MediaPlayer.Loading) {
349− if (playbackState === MediaPlayer.PlayingState && pendingSeek !== 0) {
350− player.seek(pendingSeek)
351− player.clearPosition()
352− pendingSeek = 0;
353− } else {
354− play()
355− }
356− } else if (status === MediaPlayer.EndOfMedia) {
369+ if (status === MediaPlayer.EndOfMedia) {
357370 console.log("[LOG]: End of Media. Stopping.")
358371 endOfMedia = true
359372 stop()