[haiku-commits] r36418 - in haiku/trunk/src/apps/mediaplayer: . playlist

  • From: superstippi@xxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Thu, 22 Apr 2010 17:34:12 +0200 (CEST)

Author: stippi
Date: 2010-04-22 17:34:12 +0200 (Thu, 22 Apr 2010)
New Revision: 36418
Changeset: http://dev.haiku-os.org/changeset/36418/haiku

Modified:
   haiku/trunk/src/apps/mediaplayer/ControllerView.cpp
   haiku/trunk/src/apps/mediaplayer/playlist/Playlist.cpp
Log:
 * 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.


Modified: haiku/trunk/src/apps/mediaplayer/ControllerView.cpp
===================================================================
--- haiku/trunk/src/apps/mediaplayer/ControllerView.cpp 2010-04-22 15:28:39 UTC 
(rev 36417)
+++ haiku/trunk/src/apps/mediaplayer/ControllerView.cpp 2010-04-22 15:34:12 UTC 
(rev 36418)
@@ -98,8 +98,10 @@
 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();

Modified: haiku/trunk/src/apps/mediaplayer/playlist/Playlist.cpp
===================================================================
--- haiku/trunk/src/apps/mediaplayer/playlist/Playlist.cpp      2010-04-22 
15:28:39 UTC (rev 36417)
+++ haiku/trunk/src/apps/mediaplayer/playlist/Playlist.cpp      2010-04-22 
15:34:12 UTC (rev 36418)
@@ -352,11 +352,14 @@
 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;
 


Other related posts:

  • » [haiku-commits] r36418 - in haiku/trunk/src/apps/mediaplayer: . playlist - superstippi