Beispiel #1
0
void
MainWin::PlayBuffer(void *cookie, void *buffer, size_t size, const media_raw_audio_format &format) {
    int64 frames = 0;

    playTrack->ReadFrames(buffer, &frames);

    MainWin *window = (MainWin *)cookie;

    bigtime_t now;

    if (sp->CurrentTime() < time)
        now = time + sp->CurrentTime();
    else
        now = time = sp->CurrentTime();

    char timestamp[64];

    MainWin::Timestamp(timestamp, time);

    BMessage *update = new BMessage(MSG_UPDATE_PROGRESS);
    update->AddFloat("current", (float) now);
    update->AddString("time", timestamp);

    window->PostMessage(update);

    if (frames <= 0) {
        sp->SetHasData(false);
        window->PostMessage(MSG_NEXT);
    }
}
Beispiel #2
0
void
MainApp::ReadyToRun()
{
	// make sure we have at least one window open
	if (fPlayerCount == 0) {
		MainWin* window = NewWindow();
		if (window == NULL) {
			PostMessage(B_QUIT_REQUESTED);
			return;
		}
		BMessage lastPlaylistArchive;
		if (_RestoreCurrentPlaylist(&lastPlaylistArchive) == B_OK) {
			lastPlaylistArchive.what = M_OPEN_PREVIOUS_PLAYLIST;
			window->PostMessage(&lastPlaylistArchive);
		} else
			window->Show();
	}

	// setup the settings window now, we need to have it
	fSettingsWindow = new SettingsWindow(BRect(150, 150, 450, 520));
	fSettingsWindow->Hide();
	fSettingsWindow->Show();

	_InstallPlaylistMimeType();
}
Beispiel #3
0
void
MainApp::RefsReceived(BMessage* message)
{
	// The user dropped a file (or files) on this app's icon,
	// or double clicked a file that's handled by this app.
	// Command line arguments are also redirected to here by
	// ArgvReceived() but without MIME type check.

	// If multiple refs are received in short succession we
	// combine them into a single window/playlist. Tracker
	// will send multiple messages when opening a multi-
	// selection for example and we don't want to spawn large
	// numbers of windows when someone just tries to open an
	// album. We use half a second time and prolong it for
	// each new ref received.
	static bigtime_t sLastRefsReceived = 0;
	static MainWin* sLastRefsWindow = NULL;

	if (system_time() - sLastRefsReceived < 500000) {
		// Find the last opened window
		for (int32 i = CountWindows() - 1; i >= 0; i--) {
			MainWin* playerWindow = dynamic_cast<MainWin*>(WindowAt(i));
			if (playerWindow == NULL)
				continue;

			if (playerWindow != sLastRefsWindow) {
				// The window has changed since the last refs
				sLastRefsReceived = 0;
				sLastRefsWindow = NULL;
				break;
			}

			message->AddBool("append to playlist", true);
			playerWindow->PostMessage(message);
			sLastRefsReceived = system_time();
			return;
		}
	}

	sLastRefsWindow = NewWindow(message);
	sLastRefsReceived = system_time();
}