--- vdr-plugin-mp3-0.8.2.orig/menu-mplayer.c +++ vdr-plugin-mp3-0.8.2/menu-mplayer.c @@ -173,7 +173,9 @@ cProgressBar ProgressBar(Width() * cOsd::CellWidth(), cOsd::LineHeight(), Current, Total); Interface->SetBitmap(0, cOsd::LineHeight(), ProgressBar); Interface->Write(0,2,IndexToHMSF(Current)); + const char* total_buffer = IndexToHMSF(Total); + Interface->Write(Interface->Width()-strlen(total_buffer), 2, total_buffer); flush=true; lastCurrent=Current; lastTotal=Total; } --- vdr-plugin-mp3-0.8.2.orig/menu.c +++ vdr-plugin-mp3-0.8.2/menu.c @@ -113,10 +113,12 @@ cDirItem *item=list->First(); while(item) { - Add(new cMenuBrowseItem(item),(parent && !strcmp(item->Name,parent))); - item=list->Next(item); + if (item->Name[0] != '.') { + Add(new cMenuBrowseItem(item),(parent && !strcmp(item->Name,parent))); } + item=list->Next(item); + } return true; } --- vdr-plugin-mp3-0.8.2.orig/player-mplayer.c +++ vdr-plugin-mp3-0.8.2/player-mplayer.c @@ -187,6 +187,60 @@ return true; } +void MakeStoreFilename(const char* filename, char* storefile) { + // find the last slash in filename + unsigned int slash_pos(0); + for (unsigned int pos = 0; pos < strlen(filename); pos++) { + if ('/' == filename[pos]) { + slash_pos = pos+1; + } + } + // copy the directory (all intil the last slash inclusive + memcpy(storefile, filename, slash_pos); + // make a dot + storefile[slash_pos] = '.'; + strcpy(storefile+slash_pos+1, filename+slash_pos); +} + +const float GetStoredOldPosition(const char* file) { + float old_pos = 0.0; + char* storefilename = new char[strlen(file)+1]; + MakeStoreFilename(file, storefilename); + FILE* storefile = fopen(storefilename, "r"); + if (NULL != storefile) { + if (fscanf(storefile, "old_position=%f", &old_pos) != 1) { + // not exactly one item assigned -> read error + fprintf(stderr, "Parse error on storefile\n"); + old_pos = 0.0; + } + fclose(storefile); + } + delete[] storefilename; + return old_pos; +} + +void StoreCurrentPosition(const char* file, const float pos) { + if (pos == 0.0) { + return; + } + + float save_pos = pos; + if (save_pos > 99.0) { + save_pos = 99.0; + } + + char* storefilename = new char[strlen(file)+1]; + MakeStoreFilename(file, storefilename); + FILE* storefile = fopen(storefilename, "w+"); + if (NULL != storefile) { + fprintf(storefile, "old_position=%f\n", save_pos); + fclose(storefile); + } else { + fprintf(stderr, "Could not open storefile for writing\n"); + } + delete[] storefilename; +} + #define BSIZE 1024 #define TIME_INT 10 #define POS_INT 1 @@ -204,6 +258,8 @@ char buff[BSIZE+2]; // additional space for fake newline int c=0; bool force=true, slavePatch=false, trustedTotal=false, playBack=false; + bool firstLoop = true; + float current_pos = 0.0; while(run) { if(playMode==pmPlay && playBack) { int t=time(0); @@ -251,6 +307,7 @@ if(itime>0 && total>=0) index=total*itime/100; } else if(sscanf(buff,"SLAVE: time=%f position=%f",&ftime,&fpos)==2) { + current_pos = fpos; const float fr=(float)SecondsToFrames(1); itime=(int)(ftime*fr); if(saveIndex<0 || itime>saveIndex) { // prevent index jump-back @@ -259,6 +316,13 @@ //printf("buff=%s index=%d total=%d\n",buff,index,total); } slavePatch=playBack=true; + if (firstLoop) { + firstLoop = false; + float old_position = GetStoredOldPosition(filename); + if (old_position != 0.0) { + MPlayerControl("seek %f 1", old_position); + } + } } #ifdef DEBUG else printf("%s%c",buff,cc); @@ -271,6 +335,8 @@ SetMPlayerVolume(index>=0 && force); force=false; } + + StoreCurrentPosition(filename, current_pos); dsyslog("mplayer: player thread ended (pid=%d)", getpid()); }
Attachment:
signature.asc
Description: OpenPGP digital signature