From d49d3f60d87fa4e6fd03865d2b3f4c252477bb30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20A=C3=9Fmus?= Date: Thu, 22 Apr 2010 15:34:12 +0000 Subject: [PATCH] * Playlist::SetCurrentItemIndex() will keep the index in range when requesting an index greater than CountItems(). (Setting an index smaller than 0 will still work.) This change will prevent the window from setting an invalid current playlist item index when the end of the last file is reached. The negative effect of this would be that the transport buttons would indicate seemingly confused navigation capabilities (being able to skip to the *next* item from the last item, internally it true (you can skip from -1 to 0), but the player still showed the last item as currently loaded item)... * ControllerView::TogglePlayback() will now check if the end of the last item is reached and go to the first playlist item then. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36418 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/apps/mediaplayer/ControllerView.cpp | 6 ++++-- src/apps/mediaplayer/playlist/Playlist.cpp | 7 +++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/apps/mediaplayer/ControllerView.cpp b/src/apps/mediaplayer/ControllerView.cpp index 6dc2a25d3c..4c9f03499b 100644 --- a/src/apps/mediaplayer/ControllerView.cpp +++ b/src/apps/mediaplayer/ControllerView.cpp @@ -98,8 +98,10 @@ void ControllerView::TogglePlaying() { BAutolock _(fPlaylist); - if (fPlaylist->CurrentItemIndex() < 0) { - // No valid playlist item - start again from the first one + if (fPlaylist->CurrentItemIndex() == fPlaylist->CountItems() - 1 + && Position() == 1.0) { + // Reached end of playlist and end of last item + // -> start again from the first item. fPlaylist->SetCurrentItemIndex(0); } else fController->TogglePlaying(); diff --git a/src/apps/mediaplayer/playlist/Playlist.cpp b/src/apps/mediaplayer/playlist/Playlist.cpp index b8f014c96e..ba16f10927 100644 --- a/src/apps/mediaplayer/playlist/Playlist.cpp +++ b/src/apps/mediaplayer/playlist/Playlist.cpp @@ -352,11 +352,14 @@ bool Playlist::SetCurrentItemIndex(int32 index) { bool result = true; - if (index >= CountItems() || index < 0) { + if (index >= CountItems()) { + index = CountItems() - 1; + result = false; + } + if (index < 0) { index = -1; result = false; } - if (index == fCurrentIndex) return result;