@@ -221,6 +221,21 @@ MainView {
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
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")
235+ player.restorePosition()
224 MediaPlayer {
239 MediaPlayer {
225 id: player
240 id: player
@@ -275,6 +290,14 @@ MainView {
293+ function restorePosition() {
294+ if (playbackState === MediaPlayer.PlayingState && pendingSeek !== 0) {
295+ player.seek(pendingSeek)
296+ player.clearPosition()
278 function clearPosition() {
301 function clearPosition() {
279 if (currentGuid) {
302 if (currentGuid) {
280 var db = Podcasts.init()
303 var db = Podcasts.init()
@@ -285,6 +308,8 @@ MainView {
287 function playEpisode(guid, image, name, artist, url, position) {
310 function playEpisode(guid, image, name, artist, url, position) {
288 // Clear current queue
313 // Clear current queue
289 player.playlist.clear()
314 player.playlist.clear()
290 Podcasts.clearQueue()
315 Podcasts.clearQueue()
@@ -295,7 +320,7 @@ MainView {
296 // Play episode
321 // Play episode
297 pendingSeek = position
322 pendingSeek = position
298− player.play()
323+ playStarter.restart()
301 function addEpisodeToQueue(guid, image, name, artist, url, position) {
326 function addEpisodeToQueue(guid, image, name, artist, url, position) {
@@ -337,23 +362,11 @@ MainView {
339 onPlaybackStateChanged: {
364 onPlaybackStateChanged: {
340− if (playbackState === MediaPlayer.PlayingState && pendingSeek !== 0) {
365+ restorePosition()
341− player.seek(pendingSeek)
342− player.clearPosition()
347 onStatusChanged: {
368 onStatusChanged: {
348− if (status === MediaPlayer.Loading) {
369+ if (status === MediaPlayer.EndOfMedia) {
349− if (playbackState === MediaPlayer.PlayingState && pendingSeek !== 0) {
350− player.seek(pendingSeek)
351− player.clearPosition()
356− } else if (status === MediaPlayer.EndOfMedia) {
357 console.log("[LOG]: End of Media. Stopping.")
370 console.log("[LOG]: End of Media. Stopping.")
358 endOfMedia = true
371 endOfMedia = true