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(); }
KSB_MediaWidget::KSB_MediaWidget(QWidget *parent):KSB_MediaWidget_skel(parent) { player = new Player(this); empty(); QFont labelFont = time->font(); labelFont.setPointSize(18); labelFont.setBold(true); time->setFont(labelFont); connect(Play, SIGNAL(clicked()), player, SLOT(play())); connect(Pause, SIGNAL(clicked()), player, SLOT(pause())); connect(Stop, SIGNAL(clicked()), player, SLOT(stop())); connect(player, SIGNAL(timeout()), this, SLOT(playerTimeout())); connect(player, SIGNAL(finished()), this, SLOT(playerFinished())); connect(player, SIGNAL(playing()), this, SLOT(playing())); connect(player, SIGNAL(paused()), this, SLOT(paused())); connect(player, SIGNAL(stopped()), this, SLOT(stopped())); connect(player, SIGNAL(empty()), this, SLOT(empty())); connect(Position, SIGNAL(userChanged(int)), this, SLOT(skipToWrapper(int))); connect(this, SIGNAL(skipTo(unsigned long)), player, SLOT(skipTo(unsigned long))); setAcceptDrops(true); pretty=""; needLengthUpdate=false; QToolTip::add(Play,i18n("Play")); QToolTip::add(Pause,i18n("Pause")); QToolTip::add(Stop,i18n("Stop")); }
void KSB_MediaWidget::dropEvent ( QDropEvent * e) { m_kuri_list.clear(); if (KURLDrag::decode(e, m_kuri_list)) { playerFinished(); } }
void KSB_MediaWidget::playerFinished() { if( m_kuri_list.count() > 0 ) { KURL kurl = m_kuri_list.first(); m_kuri_list.remove( kurl ); bool validFile = player->openFile( kurl ); if (validFile) { currentFile->setText( kurl.fileName() ); player->play(); needLengthUpdate=true; pretty=kurl.prettyURL(); } else { currentFile->setText( i18n("Not a sound file") ); playerFinished(); } } }
/* ///////////////////////////////////////////////////////////////////////////// * TTCutPreview constructor */ TTCutPreview::TTCutPreview(QWidget* parent, int prevW, int prevH) : QDialog(parent) { setupUi(this); videoPlayer = new TTPhononWidget(videoFrame); setObjectName("TTCutPreview"); // set desired video width x height previewWidth = prevW; previewHeight = prevH; cbCutPreview->setEditable( false ); cbCutPreview->setMinimumSize( 160, 20 ); cbCutPreview->setInsertPolicy( QComboBox::InsertAfterCurrent ); connect(videoPlayer, SIGNAL(optimalSizeChanged()), SLOT(onOptimalSizeChanged())); connect(videoPlayer, SIGNAL(playerPlaying()), SLOT(onPlayerPlaying())); connect(videoPlayer, SIGNAL(playerFinished()), SLOT(onPlayerFinished())); connect(cbCutPreview, SIGNAL(currentIndexChanged(int)), SLOT(onCutSelectionChanged(int))); connect(pbPlay, SIGNAL(clicked()), SLOT(onPlayPreview())); connect(pbExit, SIGNAL(clicked()), SLOT(onExitPreview())); }
PlayerWidget::PlayerWidget(QWidget* parent) : QWidget(parent) , ui(new Ui::PlayerWidget) , songTime(0) , mTrackFinishEmitTime(12000) , m_CurrentTrack(nullptr) , remainCueTime(0) , m_isStarted(false) , m_isHanging(false) , p(new PlayerWidgetPrivate) { ui->setupUi(this); p->isEndAnnounced = false; //create the player player = new Player(this); player->prepare(); ui->butFwd->setIcon(QIcon(":forward.png")); ui->butRew->setIcon(QIcon(":backward.png")); ui->butPlay->setIcon(QIcon(":play.png")); ui->butPlay->setChecked(false); ui->butFwd->setIconSize(QSize(26, 26)); ui->butRew->setIconSize(QSize(26, 26)); ui->butPlay->setIconSize(QSize(26, 26)); ui->butCue->setChecked(false); vuMeter = ui->vuMeter; vuMeter->setOrientation(Qt::Horizontal); vuMeter->LevelColorNormal.setRgb(112, 146, 190); vuMeter->LevelColorHigh.setRgb(218, 59, 9); vuMeter->LevelColorOff.setRgb(31, 45, 65); vuMeter->setLinesPerSegment(2); vuMeter->setSpacesBetweenSegments(1); vuMeter->setSegmentsPerPeak(2); timerLevel = new QTimer(this); connect(timerLevel, SIGNAL(timeout()), SLOT(timerLevel_timeOut())); timerPosition = new QTimer(this); connect(timerPosition, SIGNAL(timeout()), SLOT(timerPosition_timeOut())); connect(player, SIGNAL(finish()), this, SLOT(playerFinished())); connect(player, SIGNAL(error()), this, SLOT(playerError())); connect(player, SIGNAL(loadFinished()), this, SLOT(playerLoaded())); ui->lblTitle->setText(""); ui->lblInfo->setText(""); QFont font = ui->lblInfo->font(); QFont fonttime = ui->lblTime->font(); #if defined(Q_OS_DARWIN) int newSize = font.pointSize() - 4; fonttime.setPointSize(fonttime.pointSize() + 2); #else int newSize = font.pointSize() - 1; #endif font.setPointSize(newSize); ui->lblInfo->setFont(font); ui->lblTime->setFont(fonttime); ui->lblTimeRemain->setFont(fonttime); m_isStarted = false; setAcceptDrops(true); this->stop(); trackanalyser = new TrackAnalyser(this); connect(trackanalyser, SIGNAL(finishGain()), this, SLOT(analyseGainFinished())); }
// ================= // PRIVATE SLOTS // ================= void MultimediaWidget::playerStatusChanged(QMediaPlayer::MediaStatus stat){ //Only use this for end-of-file detection - use the state detection otherwise if(stat == QMediaPlayer::EndOfMedia){ if(!mediaObj->isMuted()){ playerFinished(); } //make sure it is not being seeked right now } }