Changeset 25410
- Timestamp:
- 05/10/08 06:12:23 (6 days ago)
- Files:
-
- haiku/trunk/src/apps/cdplayer/CDPlayer.cpp (modified) (17 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
haiku/trunk/src/apps/cdplayer/CDPlayer.cpp
r23935 r25410 70 70 71 71 72 CDPlayer::CDPlayer(BRect frame, const char *name, uint32 resizeMask, uint32 flags) 72 CDPlayer::CDPlayer(BRect frame, const char *name, uint32 resizeMask, 73 uint32 flags) 73 74 : BView(frame, name, resizeMask, flags | B_FRAME_EVENTS), 74 75 fCDQuery("freedb.freedb.org") 75 76 { 76 SetViewColor(216, 216,216);77 SetViewColor(216, 216, 216); 77 78 78 79 fVolume = 255; … … 81 82 82 83 if (fCDDrive.CountDrives() < 1) { 83 BAlert *alert = new BAlert("CDPlayer", "It appears that there are no CD drives"84 " on your computer or there is no system software"85 " tosupport one. Sorry.", "OK");84 BAlert *alert = new BAlert("CDPlayer", "It appears that there are no CD" 85 " drives on your computer or there is no system software to " 86 "support one. Sorry.", "OK"); 86 87 alert->Go(); 87 88 be_app->PostMessage(B_QUIT_REQUESTED); … … 125 126 126 127 float labelWidth, labelHeight; 127 fCDTitle = new BStringView(r, "CDTitle", "CD drive is empty", B_FOLLOW_LEFT_RIGHT); 128 fCDTitle = new BStringView(r, "CDTitle", "CD drive is empty", 129 B_FOLLOW_LEFT_RIGHT); 128 130 fCDTitle->GetPreferredSize(&labelWidth, &labelHeight); 129 131 fCDTitle->ResizeTo(r.Width(), labelHeight); … … 138 140 r.OffsetBy(0, r.Height() + 5); 139 141 r.right = r.left + (r.Width() / 2); 140 fTrackTime = new BStringView(r, "TrackTime", "Track: --:-- / --:--", B_FOLLOW_LEFT_RIGHT); 142 fTrackTime = new BStringView(r, "TrackTime", "Track: --:-- / --:--", 143 B_FOLLOW_LEFT_RIGHT); 141 144 box->AddChild(fTrackTime); 142 145 143 146 r.OffsetTo(box->Bounds().right / 2, r.top); 144 fDiscTime = new BStringView(r, "DiscTime", "Disc: --:-- / --:--", B_FOLLOW_RIGHT); 147 fDiscTime = new BStringView(r, "DiscTime", "Disc: --:-- / --:--", 148 B_FOLLOW_RIGHT); 145 149 fDiscTime->ResizeToPreferred(); 146 150 fDiscTime->ResizeBy(10, 0); … … 155 159 fStop->ResizeToPreferred(); 156 160 fStop->MoveTo(10, box->Frame().bottom + 15); 157 fStop->SetDisabled(BTranslationUtils::GetBitmap(B_PNG_FORMAT, "stop_disabled")); 161 fStop->SetDisabled(BTranslationUtils::GetBitmap(B_PNG_FORMAT, 162 "stop_disabled")); 158 163 AddChild(fStop); 159 164 float stopTop = fStop->Frame().top; … … 255 260 case M_STOP: 256 261 if (fWindowState == kPaused) { 257 fPlay->SetBitmaps(0, BTranslationUtils::GetBitmap(B_PNG_FORMAT, "play_up"), 262 fPlay->SetBitmaps(0, BTranslationUtils::GetBitmap(B_PNG_FORMAT, 263 "play_up"), 258 264 BTranslationUtils::GetBitmap(B_PNG_FORMAT, "play_down")); 259 265 fPlay->SetState(1); … … 269 275 fWindowState = kPaused; 270 276 fCDDrive.Pause(); 271 fPlay->SetBitmaps(0, BTranslationUtils::GetBitmap(B_PNG_FORMAT, "paused_up"), 277 fPlay->SetBitmaps(0, BTranslationUtils::GetBitmap(B_PNG_FORMAT, 278 "paused_up"), 272 279 BTranslationUtils::GetBitmap(B_PNG_FORMAT, "play_down")); 273 280 } else if (fWindowState == kPaused) { 274 281 fWindowState = kPlaying; 275 282 fCDDrive.Resume(); 276 fPlay->SetBitmaps(0, BTranslationUtils::GetBitmap(B_PNG_FORMAT, "play_up"), 283 fPlay->SetBitmaps(0, BTranslationUtils::GetBitmap(B_PNG_FORMAT, 284 "play_up"), 277 285 BTranslationUtils::GetBitmap(B_PNG_FORMAT, "play_down")); 278 286 } else { … … 448 456 fWindowState = kNoCD; 449 457 450 // Because we are changing play states, we will need to update the GUI 458 // Because we are changing play states, we will need to update 459 // the GUI 451 460 fCDData.SetDiscID(-1); 452 461 SetLabel(fCDTitle, "CD drive is empty"); … … 471 480 internalTrackChange = true; 472 481 473 // This means that the drive finished playing the song, so get the next one474 // from the list and play it482 // This means that the drive finished playing the song, so get 483 // the next one from the list and play it 475 484 int16 next = fPlayList.GetNextTrack(); 476 485 if (next > 0) … … 486 495 fPlay->SetState(0); 487 496 488 // If we got this far, then there must be a CD in the drive. The next order on the agenda489 // is to find out which CD it is497 // If we got this far, then there must be a CD in the drive. The next order 498 // on the agenda is to find out which CD it is 490 499 int32 discId = fCDDrive.GetDiscID(); 491 500 bool updateTrackGui = false; … … 499 508 500 509 if (fCDQuery.Ready()) { 501 // Note that we only update the CD title for now. We still need a track number502 // in order to update the display for the selected track510 // Note that we only update the CD title for now. We still need a 511 // track number in order to update the display for the selected track 503 512 if (fCDQuery.GetData(&fCDData, 1000000)) { 504 513 BString display(fCDData.Artist()); … … 522 531 523 532 if (!internalTrackChange) { 524 // The main thing is that we need to make sure that the playlist and the drive's track 525 // stay in sync. The CD's track may have been changed by an outside source, so if 533 // The main thing is that we need to make sure that the 534 // playlist and the drive's track stay in sync. The CD's 535 // track may have been changed by an outside source, so if 526 536 // the drive is playing, check for playlist sync. 527 537 fPlayList.SetTrackCount(driveCount); … … 534 544 // This happens only when CDs are changed 535 545 if (driveCount < 0) { 536 // There is no CD in the drive. The playlist needs to have its track537 // count set to 0 and it also needs to be rewound.546 // There is no CD in the drive. The playlist needs to have its 547 // track count set to 0 and it also needs to be rewound. 538 548 fPlayList.SetStartingTrack(1); 539 549 fPlayList.SetTrackCount(0); … … 541 551 playlistCount = 0; 542 552 } else { 543 // Two possible cases here: playlist is empty or playlist has a different544 // number of tracks. In either case, the playlist needs to be reinitialized545 // to the current track data553 // Two possible cases here: playlist is empty or playlist has a 554 // different number of tracks. In either case, the playlist 555 // needs to be reinitialized to the current track data 546 556 fPlayList.SetStartingTrack(1); 547 557 fPlayList.SetTrackCount(driveCount); … … 565 575 whichTrack++; 566 576 567 currentTrackName << "Track " << whichTrack << ": " << fCDData.TrackAt(whichTrack - 1); 577 currentTrackName << "Track " << whichTrack << ": " 578 << fCDData.TrackAt(whichTrack - 1); 568 579 569 580 SetLabel(fCurrentTrack, currentTrackName.String()); … … 582 593 if (fCDDrive.GetTime(trackTime, discTime)) { 583 594 fCDDrive.GetTimeForDisc(discTotal); 584 sprintf(timeString, "Disc: %ld:%.2ld / %ld:%.2ld", discTime.GetMinutes(), 585 discTime.GetSeconds(), discTotal.GetMinutes(), discTotal.GetSeconds()); 595 sprintf(timeString, "Disc: %ld:%.2ld / %ld:%.2ld", 596 discTime.GetMinutes(), discTime.GetSeconds(), 597 discTotal.GetMinutes(), discTotal.GetSeconds()); 586 598 SetLabel(fDiscTime, timeString); 587 599 588 600 fCDDrive.GetTimeForTrack(playlistTrack, trackTotal); 589 sprintf(timeString, "Track: %ld:%.2ld / %ld:%.2ld", trackTime.GetMinutes(), 590 trackTime.GetSeconds(), trackTotal.GetMinutes(), trackTotal.GetSeconds()); 601 sprintf(timeString, "Track: %ld:%.2ld / %ld:%.2ld", 602 trackTime.GetMinutes(), trackTime.GetSeconds(), 603 trackTotal.GetMinutes(), trackTotal.GetSeconds()); 591 604 SetLabel(fTrackTime, timeString); 592 605 } else { … … 601 614 602 615 CDPlayerWindow::CDPlayerWindow() 603 : BWindow(BRect (100, 100, 405, 280), "CDPlayer", B_TITLED_WINDOW, B_NOT_RESIZABLE |604 B_NOT_ ZOOMABLE | B_ASYNCHRONOUS_CONTROLS)616 : BWindow(BRect (100, 100, 405, 280), "CDPlayer", B_TITLED_WINDOW, 617 B_NOT_RESIZABLE | B_NOT_ZOOMABLE | B_ASYNCHRONOUS_CONTROLS) 605 618 { 606 619 }
