Ejemplo n.º 1
0
//! [6]
void MusicPlayer::createThumbnailToolBar()
{
    thumbnailToolBar = new QWinThumbnailToolBar(this);
    thumbnailToolBar->setWindow(windowHandle());

    playToolButton = new QWinThumbnailToolButton(thumbnailToolBar);
    playToolButton->setEnabled(false);
    playToolButton->setToolTip(tr("Play"));
    playToolButton->setIcon(style()->standardIcon(QStyle::SP_MediaPlay));
    connect(playToolButton, SIGNAL(clicked()), this, SLOT(togglePlayback()));

    forwardToolButton = new QWinThumbnailToolButton(thumbnailToolBar);
    forwardToolButton->setEnabled(false);
    forwardToolButton->setToolTip(tr("Fast forward"));
    forwardToolButton->setIcon(style()->standardIcon(QStyle::SP_MediaSeekForward));
    connect(forwardToolButton, SIGNAL(clicked()), this, SLOT(seekForward()));

    backwardToolButton = new QWinThumbnailToolButton(thumbnailToolBar);
    backwardToolButton->setEnabled(false);
    backwardToolButton->setToolTip(tr("Rewind"));
    backwardToolButton->setIcon(style()->standardIcon(QStyle::SP_MediaSeekBackward));
    connect(backwardToolButton, SIGNAL(clicked()), this, SLOT(seekBackward()));
    thumbnailToolBar->addButton(backwardToolButton);
    thumbnailToolBar->addButton(playToolButton);
    thumbnailToolBar->addButton(forwardToolButton);

    connect(&mediaPlayer, SIGNAL(positionChanged(qint64)), this, SLOT(updateThumbnailToolBar()));
    connect(&mediaPlayer, SIGNAL(durationChanged(qint64)), this, SLOT(updateThumbnailToolBar()));
    connect(&mediaPlayer, SIGNAL(stateChanged(QMediaPlayer::State)), this, SLOT(updateThumbnailToolBar()));
}
Ejemplo n.º 2
0
void MusicPlayer::createShortcuts()
{
    QShortcut *quitShortcut = new QShortcut(QKeySequence::Quit, this);
    connect(quitShortcut, SIGNAL(activated()), qApp, SLOT(quit()));

    /*
    QShortcut *openShortcut = new QShortcut(QKeySequence::Open, this);
    connect(openShortcut, SIGNAL(activated()), this, SLOT(openFile()));
    */

    QShortcut *toggleShortcut = new QShortcut(Qt::Key_Space, this);
    connect(toggleShortcut, SIGNAL(activated()), this, SLOT(togglePlayback()));

    QShortcut *forwardShortcut = new QShortcut(Qt::Key_Right, this);
    connect(forwardShortcut, SIGNAL(activated()), this, SLOT(seekForward()));

    QShortcut *backwardShortcut = new QShortcut(Qt::Key_Left, this);
    connect(backwardShortcut, SIGNAL(activated()), this, SLOT(seekBackward()));

    QShortcut *increaseShortcut = new QShortcut(Qt::Key_Up, this);
    connect(increaseShortcut, SIGNAL(activated()), volumeButton, SLOT(increaseVolume()));

    QShortcut *decreaseShortcut = new QShortcut(Qt::Key_Down, this);
    connect(decreaseShortcut, SIGNAL(activated()), volumeButton, SLOT(descreaseVolume()));
}
Ejemplo n.º 3
0
void MissionControl::handlePhoneButton()
{
    QString action = QSettings().value("main/headsetButtonAction", "next").toString();
    if (action == "next") {
        if (mafwState == Playing) {
            mafwRenderer->next();
        } else {
            togglePlayback();
        }
    } else if (action == "previous") {
        mafwRenderer->previous();
    } else if (action == "playpause") {
        togglePlayback();
    } else if (action == "stop") {
        mafwRenderer->stop();
    }
}
Ejemplo n.º 4
0
void Demo::load(const std::string &name)
{
	togglePlayback(false);
	toggleRecord(false);

	// UNFINISHED
	std::string filename = "" + name + ".demo";

	TiXmlDocument doc;
	doc.LoadFile(filename);

	//doc.FirstChildElement("");
}
Ejemplo n.º 5
0
void Demo::toggleRecord(bool on)
{
	if (on)
	{
		togglePlayback(false);
		frames.clear();
		mode = DEMOMODE_RECORD;
		time = 0;
		timeDiff = 0;
		frame = 0;	
	}
	else
	{
		mode = DEMOMODE_NONE;		
	}
}
Ejemplo n.º 6
0
void MusicPlayer::createWidgets()
{
    playButton = new QToolButton(this);
    playButton->setEnabled(false);
    playButton->setToolTip(tr("Play"));
    playButton->setIcon(style()->standardIcon(QStyle::SP_MediaPlay));
    connect(playButton, SIGNAL(clicked()), this, SLOT(togglePlayback()));
    connect(playButton, SIGNAL(clicked()), this->parent(), SLOT(updateBuffer()));

    /*
    QAbstractButton *openButton = new QToolButton(this);
    openButton->setText(tr("..."));
    openButton->setToolTip(tr("Open a file..."));
    openButton->setFixedSize(playButton->sizeHint());
    connect(openButton, SIGNAL(clicked()), this, SLOT(openFile()));
    */

    volumeButton = new VolumeButton(this);
    volumeButton->setToolTip(tr("Adjust volume"));
    volumeButton->setVolume(mediaPlayer.volume());
    connect(volumeButton, SIGNAL(volumeChanged(int)), &mediaPlayer, SLOT(setVolume(int)));

    positionSlider = new QSlider(Qt::Horizontal, this);
    positionSlider->setEnabled(false);
    positionSlider->setToolTip(tr("Seek"));
    connect(positionSlider, SIGNAL(valueChanged(int)), this, SLOT(setPosition(int)));

    infoLabel = new QLabel(this);
    positionLabel = new QLabel(tr("00:00"), this);
    positionLabel->setMinimumWidth(positionLabel->sizeHint().width());

    QBoxLayout *controlLayout = new QHBoxLayout;
    controlLayout->setMargin(0);
    //controlLayout->addWidget(openButton);
    controlLayout->addWidget(playButton);
    controlLayout->addWidget(positionSlider);
    controlLayout->addWidget(positionLabel);
    controlLayout->addWidget(volumeButton);

    QBoxLayout *mainLayout = new QVBoxLayout(this);
    mainLayout->addWidget(infoLabel);
    mainLayout->addLayout(controlLayout);
}
Ejemplo n.º 7
0
void MissionControl::onHeadsetButtonPressed(QDBusMessage msg)
{
    if (msg.arguments()[0] == "ButtonPressed") {
        if (msg.arguments()[1] == "play-cd" || msg.arguments()[1] == "pause-cd")
            togglePlayback();
        else if (msg.arguments()[1] == "stop-cd")
            mafwRenderer->stop();
        else if (msg.arguments()[1] == "next-song")
            mafwRenderer->next();
        else if (msg.arguments()[1] == "previous-song")
            mafwRenderer->previous();
        else if (msg.arguments()[1] == "fast-forward")
            mafwRenderer->setPosition(SeekRelative, 3);
        else if (msg.arguments()[1] == "rewind")
            mafwRenderer->setPosition(SeekRelative, -3);
        else if (msg.arguments()[1] == "phone")
            handlePhoneButton();
        else if (msg.arguments()[1] == "jack_insert" && msg.path() == HAL_PATH_RX51_JACK) // wired headset was connected or disconnected
            updateWiredHeadset();
    }
}
Ejemplo n.º 8
0
void Demo::save(const std::string &name)
{
	togglePlayback(false);
	toggleRecord(false);
	
	std::string filename = "" + name + ".demo";

	TiXmlDocument doc;

	// UNFINISHED
	for (int i = 0; i < frames.size(); i++)
	{
		//DemoFrame *frame = &frames[i];
		TiXmlElement xmlDemoFrame("DemoFrame");
		std::ostringstream os;
		//os << frame->avatarPos.x << " " << frame->avatarPos.y << " " << frame->mouse;
		//xmlDemoFrame.SetAttribute("a", os.str());
		doc.InsertEndChild(xmlDemoFrame);
	}

	doc.SaveFile(filename);
}
Ejemplo n.º 9
0
void Demo::renderFramesToDisk()
{
	core->frameOutputMode = true;
	togglePlayback(true);
}
Ejemplo n.º 10
0
void Demo::update(float dt)
{
	if (core->getNestedMains() > 1) return;

	if (mode == DEMOMODE_RECORD)
	{		
		DemoFrame f;
		f.avatarPos = dsq->game->avatar->position;
		f.vel = dsq->game->avatar->vel;
		f.vel2 = dsq->game->avatar->vel2;
		f.rot = dsq->game->avatar->rotation.z;

		f.mouse = core->mouse;
		f.t = time;

		frames.push_back(f);

		/*
		timeDiff += dt;
		if (timeDiff > key)
		{
			timeDiff -= key;
		}
		*/
		time += dt;

		if (getQuitKey())
		{
			toggleRecord(false);
			dsq->centerMessage("Stopped Recording");
		}
	}
	else if (mode == DEMOMODE_PLAYBACK)
	{
		//core->updateMouse = false;
		while (frame < frames.size())
		{
			DemoFrame *f = &frames[frame];
			if (f->t <= time) {
				// temporarily deactivate for seahorse footage
				
				dsq->game->avatar->vel = f->vel;
				dsq->game->avatar->vel2 = f->vel2;
				dsq->game->avatar->rotation.z = f->rot;
				dsq->game->avatar->position = f->avatarPos;
				

				core->mouse = f->mouse;

				frame++;
			}
			else
			{
				break;
			}
			
			//
		}
		time += dt;
		//core->updateMouse = true;

		if (getQuitKey() || (!frames.empty() && frame >= frames.size())) {	
			togglePlayback(false);
			dsq->centerMessage("Stopped Playback");
		}

		
	}
}