Tracklist for mp3 plugin using skin

Message ID 200604102230.43300.holger.brunn@stud.uni-karlsruhe.de
State New
Headers

Commit Message

Holger Brunn April 10, 2006, 8:30 p.m. UTC
  Hello list,
this patch provides a list view on the tracklist when using the skin to 
display progress information.
It tries to behave like in classic mode which succeeds save displaying 
progress while showing the list - I didn't find a way to merge menu and 
progress skin classes.
Features like jumping and scrolling work the same way as in classic display.

Any comments and suggestions on this are highly appreciated.

Regards
Holger

PS: The patch _should_ apply to 0.9.14 as well
  

Patch

diff -Nur mp3-0.9.15pre6/Makefile mp3/Makefile
--- mp3-0.9.15pre6/Makefile	2005-11-27 17:28:24.000000000 +0100
+++ mp3/Makefile	2006-04-10 21:27:31.000000000 +0200
@@ -37,6 +37,9 @@ 
 ### uncomment the following line, if you want to include debug symbols
 #DBG=1
 
+### comment to waste one line and have a progress display
+MP3_REPLAY_DISPLAY_FULL=1
+
 ### The C++ compiler and options:
 CXX      ?= g++
 CXXFLAGS ?= -O2 -fPIC -Wall -Woverloaded-virtual
@@ -117,6 +120,9 @@ 
 ifdef BROKEN_PCM
   DEFINES += -DBROKEN_PCM
 endif
+ifdef MP3_REPLAY_DISPLAY_FULL
+  DEFINES += -DMP3_REPLAY_DISPLAY_FULL
+endif
 
 OBJS2    = $(PLUGIN2).o $(COM_OBJS)\
             setup-mplayer.o player-mplayer.o
diff -Nur mp3-0.9.15pre6/mp3.c mp3/mp3.c
--- mp3-0.9.15pre6/mp3.c	2006-04-01 19:17:25.000000000 +0200
+++ mp3/mp3.c	2006-04-10 21:27:31.000000000 +0200
@@ -219,7 +219,7 @@ 
 #if VDRVERSNUM >= 10307
   cOsd *osd;
   const cFont *font;
-  cSkinDisplayReplay *disp;
+  cSkinDisplay *disp;
 #else
   bool statusInterfaceOpen;
 #endif
@@ -453,9 +453,21 @@ 
       HideStatus();
 #if VDRVERSNUM >= 10307
       if(MP3Setup.ReplayDisplay) {
+        if(bigWin)
+        {
+	        disp=Skins.Current()->DisplayMenu();
+          if(disp)
+          {
+            ((cSkinDisplayMenu*)disp)->SetTabs(5);
+            rows=((cSkinDisplayMenu*)disp)->MaxItems();
+          }
+        }
+        else
+        {
         disp=Skins.Current()->DisplayReplay(false);
+          rows=0;
+        }
         if(!disp) return;
-        bigWin=false;
         }
       else {
         int bt, bp;
@@ -529,17 +541,30 @@ 
 
 #if VDRVERSNUM >= 10307
       if(MP3Setup.ReplayDisplay) {
+        if(bigwin)
+        {
+          #ifdef MP3_REPLAY_DISPLAY_FULL
+          //Progress is not shown
+          #else
+          snprintf(buf,sizeof(buf),total?"%02d:%02d/%02d:%02d":"%02d:%02d",index/framesPerSecond/60,index/framesPerSecond%60,total/framesPerSecond/60,total/framesPerSecond%60);
+          snprintf(buf + strlen(buf), sizeof(buf), " %s", mode->Title);
+          ((cSkinDisplayMenu*)disp)->SetTitle(buf);
+          #endif
+        }
+        else
+        {
         if(!statusActive) {
-          if(total>0) disp->SetProgress(index,total);
-          disp->SetCurrent(IndexToHMSF(index));
-          disp->SetTotal(IndexToHMSF(total));
+          if(total>0) ((cSkinDisplayReplay*)disp)->SetProgress(index,total);
+          ((cSkinDisplayReplay*)disp)->SetCurrent(IndexToHMSF(index));
+          ((cSkinDisplayReplay*)disp)->SetTotal(IndexToHMSF(total));
           bool Play, Forward;
           int Speed;
           if(GetReplayMode(Play,Forward,Speed)) 
-            disp->SetMode(Play, Forward, Speed);
+              ((cSkinDisplayReplay*)disp)->SetMode(Play, Forward, Speed);
           flush=true;
           }
         }
+        }
       else {
 #endif
         if(!selecting && changed && !statusActive) {
@@ -622,7 +647,21 @@ 
               char buf2[256];
               snprintf(buf2,sizeof(buf2),"[%c%c] (%d/%d) %s",
                        mode->Loop?'L':'.',mode->Shuffle?'S':'.',mode->Num,mode->MaxNum,buf);
-              disp->SetTitle(buf2);
+              if(bigwin)
+              {          
+                #ifdef MP3_REPLAY_DISPLAY_FULL
+                snprintf(buf2,sizeof(buf2),"[%c%c] (%d/%d) %s",
+                       mode->Loop?'L':'.', mode->Shuffle?'S':'.', mode->Num, mode->MaxNum, buf);
+                ((cSkinDisplayMenu*)disp)->SetTitle(buf2);
+                #else
+                cSkinDisplayMenu* Menu=(cSkinDisplayMenu*)disp;
+                Menu->SetItem(buf2, Menu->MaxItems()-1, false, false);
+                #endif
+              }
+              else
+              {
+                ((cSkinDisplayReplay*)disp)->SetTitle(buf2);
+              }
               flush=true;
               }
             else {
@@ -640,6 +679,71 @@ 
         }
 
       if(bigwin) {
+#if VDRVERSNUM >= 10307
+        if(MP3Setup.ReplayDisplay)
+        {
+          cSkinDisplayMenu* Menu=(cSkinDisplayMenu*)disp;
+          //Update Buttons
+          if(!jumpactive && !selecting)
+          {
+            bool Play, Forward;
+            int Speed;
+            GetReplayMode(Play, Forward, Speed);
+            Menu->SetButtons(tr("Jump"), tr("L/S"), Play ? tr("Pause") : tr("Play"), tr("Stop"));
+          }
+          //Update List
+          if(top!=lastTop || changed || time(0)>listtime+2)
+          {
+            int PlaylistIndex=(top>0 && mode->Num==lastMode->Num) ? top : mode->Num - Menu->MaxItems() / 2;
+            if(PlaylistIndex + Menu->MaxItems() > mode->MaxNum)
+            {
+              PlaylistIndex=mode->MaxNum - Menu->MaxItems() + 1;
+            }
+            if(PlaylistIndex < 1)
+            {
+              PlaylistIndex=1;
+            }
+            top=PlaylistIndex;
+            //we need to overwrite the current Item for correct display in STTNG
+            if(lastMode && lastMode->Num > mode->Num)
+            {
+              if(lastMode->Num - lastTop > 0 && lastMode->Num - lastTop < Menu->MaxItems())
+              {
+                Menu->SetItem("", lastMode->Num - lastTop, false, true);
+              }
+            }
+            #ifdef MP3_REPLAY_DISPLAY_FULL
+            for(int i=0; i<Menu->MaxItems() && i<MAXROWS && PlaylistIndex<=mode->MaxNum; i++)
+            #else
+            for(int i=0; i<Menu->MaxItems() - 1 && i<MAXROWS && PlaylistIndex<=mode->MaxNum; i++)
+            #endif
+            {
+              cMP3PlayInfo TrackInfo;
+              mgr->Info(PlaylistIndex, &TrackInfo);
+              if(!TrackInfo.Title[0])
+              {
+                break;
+              }
+              snprintf(buf, sizeof(buf), TrackInfo.Artist[0]?"%d.\t%s - %s":"%d.\t%s", PlaylistIndex, TrackInfo.Title, TrackInfo.Artist);
+              int Hash=MakeHash(buf);
+              if(PlaylistIndex==mode->Num)
+              {
+                Hash=(Hash^77) + 23;
+              }
+              if(top!=lastTop || changed || Hash!=hashlist[i])
+              {
+                Menu->SetItem(buf, i, PlaylistIndex==mode->Num, true);
+                hashlist[i]=Hash;
+              }
+              
+              PlaylistIndex++;
+            }
+            listtime=time(0); lastTop=top;
+          }
+        }
+        else
+        {
+#endif
         bool all=(top!=lastTop || changed);
         if(all || time(0)>listtime+2) {
           int num=(top>0 && mode->Num==lastMode->Num) ? top : mode->Num - rows/2;
@@ -669,6 +773,9 @@ 
           listtime=time(0); lastTop=top;
           }
         }
+#if VDRVERSNUM >= 10307
+        }
+#endif
 
       if(flush) Flush();
       }
@@ -692,7 +799,14 @@ 
   else        sprintf(buf,"%s%d- %c",j,jumpmm,u);
 #if VDRVERSNUM >= 10307
   if(MP3Setup.ReplayDisplay) {
-    disp->SetJump(buf);
+    if(bigwin)
+    {
+      ((cSkinDisplayMenu*)disp)->SetMessage(mtStatus, buf);
+    }
+    else
+    {
+      ((cSkinDisplayReplay*)disp)->SetJump(buf);
+    }
     }
   else {
 #endif
@@ -732,7 +846,18 @@ 
   if(!jumpactive) {
     if(jumphide) Hide();
 #if VDRVERSNUM >= 10307
-    else if(MP3Setup.ReplayDisplay) disp->SetJump(0);
+    else if(MP3Setup.ReplayDisplay)
+    {
+      if(bigwin)
+      {
+        //TODO: Doesnt clear correcty in STTNG
+        ((cSkinDisplayMenu*)disp)->SetMessage(mtStatus, NULL);
+      }
+      else
+      {
+        ((cSkinDisplayReplay*)disp)->SetJump(0);
+      }
+    }
 #endif
     }
 }
@@ -841,7 +966,14 @@ 
 #if VDRVERSNUM >= 10307
         if(MP3Setup.ReplayDisplay) {
           snprintf(buf,sizeof(buf),"%s%d-/%d",tr("Jump: "),number,lastMode->MaxNum);
-          disp->SetJump(buf);
+          if(bigwin)
+          {
+            ((cSkinDisplayMenu*)disp)->SetMessage(mtStatus, buf);
+          }
+          else
+          {
+            ((cSkinDisplayReplay*)disp)->SetJump(buf);
+          }
           }
         else {
 #endif
@@ -862,12 +994,23 @@ 
         if(lastMode) lastMode->Hash=-1;
         number=0; selecting=selecthide=false;
 #if VDRVERSNUM >= 10307
-        if(MP3Setup.ReplayDisplay) disp->SetJump(0);
+        if(MP3Setup.ReplayDisplay)
+        {
+          if(bigwin)
+          {
+            //TODO: Doesnt clear correcty in STTNG
+            ((cSkinDisplayMenu*)disp)->SetMessage(mtStatus, NULL);
+          }
+          else
+          {
+            ((cSkinDisplayReplay*)disp)->SetJump(0);
+          }
+        }
 #endif
         }
       break;
     case kOk:
-      if(time(0)>oktime || MP3Setup.ReplayDisplay) {
+      if(time(0)>oktime) {
         visible ? Hide() : ShowTimed();
         }
       else {