440 } |
440 } |
441 |
441 |
442 cMP3PlayInfo *mode=new cMP3PlayInfo; |
442 cMP3PlayInfo *mode=new cMP3PlayInfo; |
443 bool valid=mgr->Info(-1,mode); |
443 bool valid=mgr->Info(-1,mode); |
444 bool changed=(!lastMode || mode->Hash!=lastMode->Hash); |
444 bool changed=(!lastMode || mode->Hash!=lastMode->Hash); |
445 char buf[256]; |
|
446 if(changed) { d(printf("mp3-ctrl: mode change detected\n")) } |
445 if(changed) { d(printf("mp3-ctrl: mode change detected\n")) } |
447 |
446 |
448 if(valid) { // send progress to status monitor |
447 if(valid) { // send progress to status monitor |
449 if(changed || mode->Loop!=lastMode->Loop || mode->Shuffle!=lastMode->Shuffle) { |
448 if(changed || mode->Loop!=lastMode->Loop || mode->Shuffle!=lastMode->Shuffle) |
450 snprintf(buf,sizeof(buf),"[%c%c] (%d/%d) %s", |
449 cStatus::MsgReplaying(this,cString::sprintf("[%c%c] (%d/%d) %s",mode->Loop?'L':'.',mode->Shuffle?'S':'.',mode->Num,mode->MaxNum,*TitleArtist(mode->Title,mode->Artist)),mode->Filename[0]?mode->Filename:0,true); |
451 mode->Loop?'L':'.',mode->Shuffle?'S':'.',mode->Num,mode->MaxNum,*TitleArtist(mode->Title,mode->Artist)); |
|
452 cStatus::MsgReplaying(this,buf,mode->Filename[0]?mode->Filename:0,true); |
|
453 } |
|
454 } |
450 } |
455 |
451 |
456 if(visible) { // refresh the OSD progress display |
452 if(visible) { // refresh the OSD progress display |
457 bool flush=false; |
453 bool flush=false; |
458 |
454 |
468 flush=true; |
464 flush=true; |
469 } |
465 } |
470 } |
466 } |
471 else { |
467 else { |
472 if(!selecting && changed && !statusActive) { |
468 if(!selecting && changed && !statusActive) { |
473 snprintf(buf,sizeof(buf),"(%d/%d)",mode->Num,mode->MaxNum); |
469 Write(0,-2,CTAB,cString::sprintf("(%d/%d)",mode->Num,mode->MaxNum)); |
474 Write(0,-2,CTAB,buf); |
|
475 flush=true; |
470 flush=true; |
476 } |
471 } |
477 |
472 |
478 if(!lastMode || mode->Loop!=lastMode->Loop) { |
473 if(!lastMode || mode->Loop!=lastMode->Loop) { |
479 if(mode->Loop) Write(-4,-1,0,"L",clrBlack,clrYellow); |
474 if(mode->Loop) Write(-4,-1,0,"L",clrBlack,clrYellow); |
490 if(index!=lastIndex || total!=lastTotal) { |
485 if(index!=lastIndex || total!=lastTotal) { |
491 if(total>0) { |
486 if(total>0) { |
492 cProgressBar ProgressBar(bw-(CTAB+CTAB2)*fw,fh,index,total); |
487 cProgressBar ProgressBar(bw-(CTAB+CTAB2)*fw,fh,index,total); |
493 osd->DrawBitmap(CTAB*fw,bh-fh,ProgressBar); |
488 osd->DrawBitmap(CTAB*fw,bh-fh,ProgressBar); |
494 } |
489 } |
495 snprintf(buf,sizeof(buf),total?"%02d:%02d/%02d:%02d":"%02d:%02d",index/60,index%60,total/60,total%60); |
490 Write(0,-1,11,cString::sprintf(total?"%02d:%02d/%02d:%02d":"%02d:%02d",index/60,index%60,total/60,total%60)); |
496 Write(0,-1,11,buf); |
|
497 flush=true; |
491 flush=true; |
498 } |
492 } |
499 } |
493 } |
500 |
494 |
501 if(!jumpactive) { |
495 if(!jumpactive) { |
510 fliptime=time(0); |
504 fliptime=time(0); |
511 flip++; if(flip>=MP3Setup.DisplayMode) flip=0; |
505 flip++; if(flip>=MP3Setup.DisplayMode) flip=0; |
512 doflip=true; |
506 doflip=true; |
513 } |
507 } |
514 if(doflip) { |
508 if(doflip) { |
515 buf[0]=0; |
509 cString buff; |
516 switch(flip) { |
510 switch(flip) { |
517 default: |
511 default: |
518 flip=0; |
512 flip=0; |
519 // fall through |
513 // fall through |
520 case 0: |
514 case 0: |
521 snprintf(buf,sizeof(buf),"%s",*TitleArtist(mode->Title,mode->Artist)); |
515 buff=TitleArtist(mode->Title,mode->Artist); |
522 flipint=6; |
516 flipint=6; |
523 break; |
517 break; |
524 case 1: |
518 case 1: |
525 if(mode->Album[0]) { |
519 if(mode->Album[0]) { |
526 snprintf(buf,sizeof(buf),mode->Year>0?"from: %s (%d)":"from: %s",mode->Album,mode->Year); |
520 buff=cString::sprintf(mode->Year>0?"from: %s (%d)":"from: %s",mode->Album,mode->Year); |
527 flipint=4; |
521 flipint=4; |
|
522 break; |
528 } |
523 } |
529 else fliptime=0; |
524 flip++; |
530 break; |
525 // fall through |
531 case 2: |
526 case 2: |
532 if(mode->MaxBitrate>0) |
527 if(mode->MaxBitrate>0) |
533 snprintf(buf,sizeof(buf),"%.1f kHz, %d-%d kbps, %s",mode->SampleFreq/1000.0,mode->Bitrate/1000,mode->MaxBitrate/1000,mode->SMode); |
528 buff=cString::sprintf("%.1f kHz, %d-%d kbps, %s",mode->SampleFreq/1000.0,mode->Bitrate/1000,mode->MaxBitrate/1000,mode->SMode); |
534 else |
529 else |
535 snprintf(buf,sizeof(buf),"%.1f kHz, %d kbps, %s",mode->SampleFreq/1000.0,mode->Bitrate/1000,mode->SMode); |
530 buff=cString::sprintf("%.1f kHz, %d kbps, %s",mode->SampleFreq/1000.0,mode->Bitrate/1000,mode->SMode); |
536 flipint=3; |
531 flipint=3; |
537 break; |
532 break; |
538 } |
533 } |
539 if(buf[0]) { |
534 if(MP3Setup.ReplayDisplay) { |
540 if(MP3Setup.ReplayDisplay) { |
535 disp->SetTitle(cString::sprintf("[%c%c] (%d/%d) %s",mode->Loop?'L':'.',mode->Shuffle?'S':'.',mode->Num,mode->MaxNum,*buff)); |
541 char buf2[256]; |
536 flush=true; |
542 snprintf(buf2,sizeof(buf2),"[%c%c] (%d/%d) %s", |
537 } |
543 mode->Loop?'L':'.',mode->Shuffle?'S':'.',mode->Num,mode->MaxNum,buf); |
538 else { |
544 disp->SetTitle(buf2); |
539 if(!statusActive) { |
|
540 DisplayInfo(buff); |
545 flush=true; |
541 flush=true; |
546 } |
542 } |
547 else { |
543 else { d(printf("mp3-ctrl: display info skip due to status active\n")) } |
548 if(!statusActive) { |
|
549 DisplayInfo(buf); |
|
550 flush=true; |
|
551 } |
|
552 else { d(printf("mp3-ctrl: display info skip due to status active\n")) } |
|
553 } |
|
554 } |
544 } |
555 } |
545 } |
556 } |
546 } |
557 |
547 |
558 if(bigwin) { |
548 if(bigwin) { |
563 if(num<1) num=1; |
553 if(num<1) num=1; |
564 top=num; |
554 top=num; |
565 for(int i=0 ; i<rows && i<MAXROWS && num<=mode->MaxNum ; i++,num++) { |
555 for(int i=0 ; i<rows && i<MAXROWS && num<=mode->MaxNum ; i++,num++) { |
566 cMP3PlayInfo pi; |
556 cMP3PlayInfo pi; |
567 mgr->Info(num,&pi); if(!pi.Title[0]) break; |
557 mgr->Info(num,&pi); if(!pi.Title[0]) break; |
568 snprintf(buf,sizeof(buf),"%d.\t%s",num,*TitleArtist(pi.Title,pi.Artist)); |
558 cString buff=cString::sprintf("%d.\t%s",num,*TitleArtist(pi.Title,pi.Artist)); |
569 int fg=clrWhite, bg=clrGray50; |
559 int fg=clrWhite, bg=clrGray50; |
570 int hash=MakeHash(buf); |
560 int hash=MakeHash(buff); |
571 if(num==mode->Num) { fg=clrBlack; bg=clrCyan; hash=(hash^77) + 23; } |
561 if(num==mode->Num) { fg=clrBlack; bg=clrCyan; hash=(hash^77) + 23; } |
572 if(all || hash!=hashlist[i]) { |
562 if(all || hash!=hashlist[i]) { |
573 char *s=rindex(buf,'\t'); |
563 char *s=rindex(buff,'\t'); |
574 if(s) { |
564 if(s) { |
575 *s++=0; |
565 *s++=0; |
576 Write(0,i,5,buf,fg,bg); |
566 Write(0,i,5,buff,fg,bg); |
577 Write(5,i,bwc-5,s,fg,bg); |
567 Write(5,i,bwc-5,s,fg,bg); |
578 } |
568 } |
579 else |
569 else |
580 Write(0,i,bwc,buf,fg,bg); |
570 Write(0,i,bwc,buff,fg,bg); |
581 flush=true; |
571 flush=true; |
582 hashlist[i]=hash; |
572 hashlist[i]=hash; |
583 } |
573 } |
584 } |
574 } |
585 listtime=time(0); lastTop=top; |
575 listtime=time(0); lastTop=top; |