MultimediaWidget::MultimediaWidget(QWidget *parent) : QWidget(parent), ui(new Ui::MultimediaWidget){ ui->setupUi(this); //load the designer file //Add in the special QMultimediaWidgets mediaObj = new QMediaPlayer(this); mediaObj->setVolume(100); mediaObj->setNotifyInterval(500); //only every 1/2 second update videoDisplay = new QVideoWidget(this); videoDisplay->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); ui->videoLayout->addWidget(videoDisplay); mediaObj->setVideoOutput(videoDisplay); videoDisplay->setVisible(false); UpdateIcons(); UpdateText(); //Connect the special signals/slots for the media object connect(mediaObj, SIGNAL(durationChanged(qint64)), this, SLOT(playerDurationChanged(qint64)) ); connect(mediaObj, SIGNAL(seekableChanged(bool)), ui->playerSlider, SLOT(setEnabled(bool)) ); connect(mediaObj, SIGNAL(mediaStatusChanged(QMediaPlayer::MediaStatus)), this, SLOT(playerStatusChanged(QMediaPlayer::MediaStatus)) ); connect(mediaObj, SIGNAL(positionChanged(qint64)), this, SLOT(playerTimeChanged(qint64)) ); connect(mediaObj, SIGNAL(stateChanged(QMediaPlayer::State)), this, SLOT(playerStateChanged(QMediaPlayer::State)) ); connect(mediaObj, SIGNAL(videoAvailableChanged(bool)), this, SLOT(playerVideoAvailable(bool)) ); connect(mediaObj, SIGNAL(error(QMediaPlayer::Error)), this, SLOT(playerError()) ); //Disable some of the initial states ui->tool_player_stop->setEnabled(false); //nothing to stop yet ui->tool_player_pause->setVisible(false); //nothing to pause yet ui->playerSlider->setEnabled(false); //nothing to seek yet }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) , _ui(new Ui::MainWindow) , _midiOutput(new CxxMidi::Output::Default(0)) , _midiPlayer(new CxxMidi::Player::Asynchronous(_midiOutput)) , _midiFile(0) , _sliderLocked(false) { _ui->setupUi(this); this->createMenuBar(); this->centralWidget()->setDisabled(true); this->resize(this->minimumSizeHint()); _midiPlayer->setCallbackHeartbeat(&_playerHeartbeatCallback); connect(&_playerHeartbeatCallback,SIGNAL(playerTimeChanged(CxxMidi::Time::Point)), this,SLOT(updateTimeCode(CxxMidi::Time::Point)),Qt::QueuedConnection); _midiPlayer->setCallbackFinished(&_playerFinishedCallback); connect(&_playerFinishedCallback,SIGNAL(playerFinished()), this,SLOT(playerFinished()),Qt::QueuedConnection); connect(_ui->doubleSpinBoxSpeed,SIGNAL(valueChanged(double)), this,SLOT(onSpeedChange(double))); connect(_ui->pushButtonPlay,SIGNAL(clicked()), this,SLOT(onPlayClicked())); connect(_ui->pushButtonPause,SIGNAL(clicked()), this,SLOT(onPauseClicked())); connect(_ui->sliderTimeline,SIGNAL(sliderPressed()), this,SLOT(onTimeSliderPressed())); connect(_ui->sliderTimeline,SIGNAL(sliderReleased()), this,SLOT(onTimeSliderReleased())); // first argument is file name if(QApplication::arguments().size() >=2 ) { QString fileName = QApplication::arguments().at(1); this->openFile(fileName); } // second argument is output num if(QApplication::arguments().size() >=3) { int num = QApplication::arguments().at(2).toInt(); this->setOutput(num); _outputsActionGroup->actions()[num]->setChecked(true); } // auto play if( QApplication::arguments().size() >= 2) _midiPlayer->play(); }