* 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
This commit is contained in:
Stephan Aßmus 2010-04-22 15:34:12 +00:00
parent 8e9973a09d
commit d49d3f60d8
2 changed files with 9 additions and 4 deletions

View File

@ -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();

View File

@ -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;