void UBGraphicsVideoItemDelegate::buildButtons() { mPlayPauseButton = new DelegateButton(":/images/play.svg", mDelegated, mFrame); mStopButton = new DelegateButton(":/images/stop.svg", mDelegated, mFrame); mStopButton->hide(); if (delegated()->isMuted()) mMuteButton = new DelegateButton(":/images/soundOff.svg", mDelegated, mFrame); else mMuteButton = new DelegateButton(":/images/soundOn.svg", mDelegated, mFrame); mMuteButton->hide(); mVideoControl = new DelegateVideoControl(delegated(), mFrame); mVideoControl->setZValue(UBGraphicsScene::toolLayerStart + 2); mVideoControl->setFlag(QGraphicsItem::ItemIsSelectable, true); connect(mPlayPauseButton, SIGNAL(clicked(bool)), this, SLOT(togglePlayPause())); connect(mStopButton, SIGNAL(clicked(bool)), mMedia, SLOT(stop())); connect(mMuteButton, SIGNAL(clicked(bool)), delegated(), SLOT(toggleMute())); connect(mMuteButton, SIGNAL(clicked(bool)), this, SLOT(toggleMute())); mButtons << mPlayPauseButton << mStopButton << mMuteButton; mMedia->setTickInterval(50); connect(mMedia, SIGNAL(stateChanged (Phonon::State, Phonon::State)), this, SLOT(mediaStateChanged (Phonon::State, Phonon::State))); connect(mMedia, SIGNAL(finished()), this, SLOT(updatePlayPauseState())); connect(mMedia, SIGNAL(tick(qint64)), this, SLOT(updateTicker(qint64))); connect(mMedia, SIGNAL(totalTimeChanged(qint64)), this, SLOT(totalTimeChanged(qint64))); }
Player::Player() { curIndex = -1; prevIndex = -1; listSync = false; setState(Player::STOPED); autoNext = false; obCreated = false; sMusic = false; queueSize = -1; shuffle = false; repeat = false; bufferOff = false; mediaObject = new Phonon::MediaObject(this); audioOutput = new Phonon::AudioOutput(Phonon::MusicCategory, this); Phonon::createPath(mediaObject, audioOutput); connect(mediaObject, SIGNAL(finished()), this, SLOT(playFinished())); connect(mediaObject, SIGNAL(tick(qint64)), this, SIGNAL(tick(qint64))); connect(mediaObject, SIGNAL(totalTimeChanged(qint64)), this, SIGNAL(totalTimeChanged(qint64))); ba = new QByteArray(); buffer = new QBuffer(); }
SeekSlider::SeekSlider (SourceObject *source, QWidget *parent) : QWidget (parent) , Source_ (source) , IgnoreNextValChange_ (false) , IsPressed_ (false) { Ui_.setupUi (this); connect (source, SIGNAL (currentSourceChanged (AudioSource)), this, SLOT (updateRanges ())); connect (source, SIGNAL (totalTimeChanged (qint64)), this, SLOT (updateRanges ())); connect (source, SIGNAL (tick (qint64)), this, SLOT (handleCurrentPlayTime (qint64))); connect (source, SIGNAL (stateChanged (SourceState, SourceState)), this, SLOT (handleStateChanged ())); connect (Ui_.Slider_, SIGNAL (sliderPressed ()), this, SLOT (handleSliderPressed ())); connect (Ui_.Slider_, SIGNAL (sliderReleased ()), this, SLOT (handleSliderReleased ())); }
VideoItem::VideoItem(Video *vid, ShowFunction *func) : ShowItem(func) , m_video(vid) , m_fullscreenAction(NULL) { Q_ASSERT(vid != NULL); if (func->color().isValid()) setColor(func->color()); else setColor(ShowFunction::defaultColor(Function::Video)); if (func->duration() == 0) func->setDuration(m_video->totalDuration()); calculateWidth(); connect(m_video, SIGNAL(changed(quint32)), this, SLOT(slotVideoChanged(quint32))); connect(m_video, SIGNAL(totalTimeChanged(qint64)), this, SLOT(slotVideoDurationChanged(qint64))); m_fullscreenAction = new QAction(tr("Fullscreen"), this); m_fullscreenAction->setCheckable(true); if (m_video->fullscreen() == true) m_fullscreenAction->setChecked(true); connect(m_fullscreenAction, SIGNAL(toggled(bool)), this, SLOT(slotFullscreenToggled(bool))); }
void VESPERSEXAFSScanConfiguration::computeTotalTimeImplementation() { double time = 0; if (exafsRegions()->hasKSpace() && !useFixedTime_){ for (int i = 0; i < regions_->count(); i++){ if (exafsRegions()->type(i) == AMEXAFSRegion::kSpace) time += VESPERSBeamline::vespers()->variableIntegrationTime()->totalTime(regions_->delta(i)) + ((regions_->end(i) - regions_->start(i))/regions_->delta(i))*timeOffset_; else time += ((regions_->end(i) - regions_->start(i))/regions_->delta(i))*(regions_->time(i) + timeOffset_); // Seems to take about 0.7 seconds for extra beamline stuff to happen. } } else{ for (int i = 0; i < regions_->count(); i++) time += ((regions_->end(i) - regions_->start(i))/regions_->delta(i))*(regions_->time(i) + timeOffset_); // Seems to take about 0.7 seconds for extra beamline stuff to happen. } totalTime_ = time + 9; // There is a 9 second miscellaneous startup delay. setExpectedDuration(totalTime_); emit totalTimeChanged(totalTime_); }
MainWindow::MainWindow(QWidget* parent, Qt::WindowFlags flags): QMainWindow(parent, flags), d(new MainWindowPrivate) { d->selector = new QDocumentSelector(this); d->selector->setFilter(QContentFilter(QContent::Document) & (QContentFilter::mimeType("video/*") | QContentFilter::mimeType("audio/*"))); connect(d->selector, SIGNAL(documentSelected(QContent)), SLOT(documentSelected(QContent))); setCentralWidget(d->selector); d->audioOutput = new Phonon::AudioOutput(Phonon::MusicCategory, this); d->videoWidget = new Phonon::VideoWidget(this); d->mediaObject = new Phonon::MediaObject(this); // metaInformationResolver = new Phonon::MediaObject(this); d->mediaObject->setTickInterval(1000); // MediaObject connect(d->mediaObject, SIGNAL(currentSourceChanged(const Phonon::MediaSource &)), SLOT(currentSourceChanged(const Phonon::MediaSource &))); connect(d->mediaObject, SIGNAL(stateChanged(Phonon::State, Phonon::State)), SLOT(stateChanged(Phonon::State, Phonon::State))); connect(d->mediaObject, SIGNAL(tick(qint64)), SLOT(tick(qint64))); /* connect(d->mediaObject, SIGNAL(metaDataChanged(QMultiMap<QString,QString>)), SLOT(metaDataChanged(QMultiMap<QString,QString>))); */ connect(d->mediaObject, SIGNAL(seekableChanged(bool)), SLOT(seekableChanged(bool))); connect(d->mediaObject, SIGNAL(hasVideoChanged(bool)), SLOT(hasVideoChanged(bool))); connect(d->mediaObject, SIGNAL(finished()), SLOT(finished())); connect(d->mediaObject, SIGNAL(prefinishMarkReached(qint32)), SLOT(prefinishMarkReached(qint32))); connect(d->mediaObject, SIGNAL(aboutToFinish()), SLOT(aboutToFinish())); connect(d->mediaObject, SIGNAL(totalTimeChanged(qint64)), SLOT(totalTimeChanged(qint64))); connect(d->mediaObject, SIGNAL(bufferStatus(int)), SLOT(bufferStatus(int))); // Meta info /* connect(metaInformationResolver, SIGNAL(stateChanged(Phonon::State,Phonon::State)), SLOT(metaStateChanged(Phonon::State, Phonon::State))); */ Phonon::createPath(d->mediaObject, d->audioOutput); Phonon::createPath(d->mediaObject, d->videoWidget); }
APlayer::APlayer() { old = 0; m_fsModel = new QFileSystemModel(this); m_fsModel->setRootPath("/"); m_fsModel->setFilter(QDir::Dirs | QDir::Drives | QDir::NoDotAndDotDot); w_fileSystemTree = new QTreeView(); w_fileSystemTree->setModel(m_fsModel); w_fileSystemTree->setSelectionMode(QAbstractItemView::SingleSelection); w_folderContents = new QTreeWidget(); w_folderContents->setHeaderLabels(QStringList() << "Artist" << "Title" << "Album" << "Year"); w_splitter = new QSplitter(); w_splitter->setOrientation(Qt::Horizontal); w_splitter->addWidget(w_fileSystemTree); w_splitter->addWidget(w_folderContents); w_splitter->setStretchFactor(0, 40); w_splitter->setStretchFactor(1, 60); w_playPause = new QPushButton(QIcon::fromTheme("media-playback-start"), tr("")); w_stop = new QPushButton(QIcon::fromTheme("media-playback-stop"), tr("")); w_sound = new QPushButton(QIcon::fromTheme("player-volume"), tr("")); w_progress = new QSlider(Qt::Horizontal); m_media = Phonon::createPlayer(Phonon::MusicCategory); m_media->setTickInterval(1000); la_playerButtons = new QHBoxLayout(); la_playerButtons->addWidget(w_playPause); la_playerButtons->addWidget(w_stop); la_playerButtons->addWidget(w_sound); la_playerButtons->addWidget(w_progress); la_mainWindow = new QVBoxLayout(); la_mainWindow->addWidget(w_splitter); la_mainWindow->addLayout(la_playerButtons); QWidget *w = new QWidget(); w->setLayout(la_mainWindow); setCentralWidget(w); connect(w_fileSystemTree, SIGNAL(clicked(QModelIndex)), this, SLOT(treeItemClicked(QModelIndex))); connect(w_playPause, SIGNAL(clicked()), this, SLOT(playPause())); connect(w_stop, SIGNAL(clicked()), this, SLOT(stop())); connect(w_fileSystemTree, SIGNAL(collapsed(QModelIndex)), this, SLOT(treeChanged())); connect(w_fileSystemTree, SIGNAL(expanded(QModelIndex)), this, SLOT(treeChanged())); connect(m_media, SIGNAL(tick(qint64)), this, SLOT(setPlaybackState(qint64))); connect(m_media, SIGNAL(totalTimeChanged(qint64)), this, SLOT(setPlaybackMax(qint64))); connect(w_folderContents, SIGNAL(itemDoubleClicked(QTreeWidgetItem*,int)), this, SLOT(fileDoubleClicked(QTreeWidgetItem*,int))); }
MediaPlayer2Player::MediaPlayer2Player(QObject* parent) : QDBusAbstractAdaptor(parent) { connect(Dragon::engine(), SIGNAL(tick(qint64)), this, SLOT(tick(qint64))); connect(Dragon::engine(), SIGNAL(currentSourceChanged(Phonon::MediaSource)), this, SLOT(currentSourceChanged())); connect(Dragon::engine(), SIGNAL(metaDataChanged()), this, SLOT(emitMetadataChange())); connect(Dragon::engine(), SIGNAL(stateUpdated(Phonon::State,Phonon::State)), this, SLOT(stateUpdated())); connect(Dragon::engine(), SIGNAL(totalTimeChanged(qint64)), this, SLOT(emitMetadataChange())); connect(Dragon::engine(), SIGNAL(seekableChanged(bool)), this, SLOT(seekableChanged(bool))); connect(Dragon::engine(), SIGNAL(volumeChanged(qreal)), this, SLOT(volumeChanged())); }
void setupHud(QGraphicsWidget* parent) { // Play/Pause GraphicsHudButton* playPauseButton = new GraphicsHudButton; playPauseButton->setDefaultAction(mPlayPauseAction); // Seek mSeekSlider = new GraphicsHudSlider; mSeekSlider->setPageStep(5000); mSeekSlider->setSingleStep(200); QObject::connect(mSeekSlider, SIGNAL(actionTriggered(int)), q, SLOT(slotSeekSliderActionTriggered(int))); QObject::connect(mMediaObject, SIGNAL(tick(qint64)), q, SLOT(slotTicked(qint64))); QObject::connect(mMediaObject, SIGNAL(totalTimeChanged(qint64)), q, SLOT(updatePlayUi())); QObject::connect(mMediaObject, SIGNAL(seekableChanged(bool)), q, SLOT(updatePlayUi())); // Mute GraphicsHudButton* muteButton = new GraphicsHudButton; muteButton->setDefaultAction(mMuteAction); // Volume mVolumeSlider = new GraphicsHudSlider; mVolumeSlider->setMinimumWidth(100); mVolumeSlider->setRange(0, 100); mVolumeSlider->setPageStep(5); mVolumeSlider->setSingleStep(1); QObject::connect(mVolumeSlider, SIGNAL(valueChanged(int)), q, SLOT(slotVolumeSliderChanged(int))); QObject::connect(mAudioOutput, SIGNAL(volumeChanged(qreal)), q, SLOT(slotOutputVolumeChanged(qreal))); // Layout QGraphicsWidget* hudContent = new QGraphicsWidget; QGraphicsLinearLayout* layout = new QGraphicsLinearLayout(hudContent); layout->addItem(playPauseButton); layout->addItem(mSeekSlider); layout->setStretchFactor(mSeekSlider, 5); layout->addItem(muteButton); layout->addItem(mVolumeSlider); layout->setStretchFactor(mVolumeSlider, 1); // Create hud mHud = new GraphicsHudWidget(parent); mHud->init(hudContent, GraphicsHudWidget::OptionNone); mHud->setZValue(1); // Init floater mFloater = new GraphicsWidgetFloater(parent); mFloater->setChildWidget(mHud); mFloater->setAlignment(Qt::AlignJustify | Qt::AlignBottom); }
/** * \brief Set the media file * @param filePath as the media file path */ void UBMediaWidget::setFile(const QString &filePath) { Q_ASSERT("" != filePath); mFilePath = filePath; mpMediaObject = new Phonon::MediaObject(this); mpMediaObject->setTickInterval(TICK_INTERVAL); connect(mpMediaObject, SIGNAL(stateChanged(Phonon::State,Phonon::State)), this, SLOT(onStateChanged(Phonon::State,Phonon::State))); connect(mpMediaObject, SIGNAL(totalTimeChanged(qint64)), this, SLOT(onTotalTimeChanged(qint64))); connect(mpMediaObject, SIGNAL(tick(qint64)), this, SLOT(onTick(qint64))); mpMediaObject->setCurrentSource(Phonon::MediaSource(filePath)); createMediaPlayer(); }
void EngineController::initializePhonon() { DEBUG_BLOCK delete m_media; delete m_audio; delete m_preamp; PERF_LOG( "EngineController: loading phonon objects" ) m_media = new Phonon::MediaObject( this ); m_audio = new Phonon::AudioOutput( Phonon::MusicCategory, this ); m_path = Phonon::createPath( m_media, m_audio ); // HACK we turn off replaygain manually on OSX, until the phonon coreaudio backend is fixed. // as the default is specified in the .cfg file, we can't just tell it to be a different default on OSX #ifdef Q_WS_MAC AmarokConfig::setReplayGainMode( AmarokConfig::EnumReplayGainMode::Off ); #endif // only create pre-amp if we have replaygain on, preamp can cause phonon issues if( AmarokConfig::replayGainMode() != AmarokConfig::EnumReplayGainMode::Off ) { m_preamp = new Phonon::VolumeFaderEffect( this ); m_path.insertEffect( m_preamp ); } m_media->setTickInterval( 100 ); debug() << "Tick Interval (actual): " << m_media->tickInterval(); PERF_LOG( "EngineController: loaded phonon objects" ) // Get the next track when there is 2 seconds left on the current one. m_media->setPrefinishMark( 2000 ); connect( m_media, SIGNAL( finished() ), SLOT( slotQueueEnded() ) ); connect( m_media, SIGNAL( aboutToFinish()), SLOT( slotAboutToFinish() ) ); connect( m_media, SIGNAL( metaDataChanged() ), SLOT( slotMetaDataChanged() ) ); connect( m_media, SIGNAL( stateChanged( Phonon::State, Phonon::State ) ), SLOT( slotStateChanged( Phonon::State, Phonon::State ) ) ); connect( m_media, SIGNAL( tick( qint64 ) ), SLOT( slotTick( qint64 ) ) ); connect( m_media, SIGNAL( totalTimeChanged( qint64 ) ), SLOT( slotTrackLengthChanged( qint64 ) ) ); connect( m_media, SIGNAL( currentSourceChanged( const Phonon::MediaSource & ) ), SLOT( slotNewTrackPlaying( const Phonon::MediaSource & ) ) ); //TODO: The xine engine does not support crossfading. Cannot get the gstreamer engine to work, will test this once I do. #if 0 if( AmarokConfig::trackDelayLength() > -1 ) m_media->setTransitionTime( AmarokConfig::trackDelayLength() ); // Also Handles gapless. else if( AmarokConfig::crossfadeLength() > 0 ) // TODO: Handle the possible options on when to crossfade.. the values are not documented anywhere however m_media->setTransitionTime( -AmarokConfig::crossfadeLength() ); #endif }
void SXRMB2DMapScanConfiguration::computeTotalTimeImplementation() { double time = 0; // Get the number of points. time = scanAxisAt(0)->numberOfPoints() + scanAxisAt(1)->numberOfPoints(); time *= double(scanAxisAt(0)->regionAt(0)->regionTime()) + timeOffset_; totalTime_ = time + 9; // initialization time is about 9s setExpectedDuration(totalTime_); emit totalTimeChanged(totalTime_); }
Audio::Audio(QDeclarativeItem* parent) : QDeclarativeItem(parent) , m_isPreview(false) , m_isReady(false) { m_mediaObject = Phonon::createPlayer(Phonon::MusicCategory); m_mediaObject->setTickInterval(1000); QObject::connect(m_mediaObject, SIGNAL(tick(qint64)), SLOT(onTicked(qint64))); QObject::connect(m_mediaObject, SIGNAL(totalTimeChanged(qint64)), SLOT(onTotalTimeChanged(qint64))); QObject::connect(m_mediaObject, SIGNAL(finished()), SLOT(onFinished())); QObject::connect(m_mediaObject, SIGNAL(stateChanged(Phonon::State, Phonon::State)), SLOT(stateChanged(Phonon::State, Phonon::State))); }
VideoEditor::VideoEditor(QWidget* parent, Video *video, Doc* doc) : QWidget(parent) , m_doc(doc) , m_video(video) { Q_ASSERT(doc != NULL); Q_ASSERT(video != NULL); setupUi(this); m_nameEdit->setText(m_video->name()); m_nameEdit->setSelection(0, m_nameEdit->text().length()); connect(m_video, SIGNAL(totalTimeChanged(qint64)), this, SLOT(slotDurationChanged(qint64))); connect(m_video, SIGNAL(metaDataChanged(QString,QVariant)), this, SLOT(slotMetaDataChanged(QString,QVariant))); connect(m_nameEdit, SIGNAL(textEdited(const QString&)), this, SLOT(slotNameEdited(const QString&))); connect(m_fileButton, SIGNAL(clicked()), this, SLOT(slotSourceFileClicked())); connect(m_previewButton, SIGNAL(toggled(bool)), this, SLOT(slotPreviewToggled(bool))); m_filenameLabel->setText(m_video->getSourceFileName()); m_durationLabel->setText(Function::speedToString(m_video->totalDuration())); for (int i = 0; i < m_video->getScreenCount(); i++) m_screenCombo->addItem(QString("Screen %1").arg(i + 1)); m_screenCombo->setCurrentIndex(m_video->screen()); if (m_video->fullscreen() == true) m_fullCheck->setChecked(true); else m_winCheck->setChecked(true); connect(m_screenCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(slotScreenIndexChanged(int))); connect(m_winCheck, SIGNAL(clicked()), this, SLOT(slotWindowedCheckClicked())); connect(m_fullCheck, SIGNAL(clicked()), this, SLOT(slotFullscreenCheckClicked())); // Set focus to the editor m_nameEdit->setFocus(); }
// actions void Player::setActions(){ connect(playButton, SIGNAL(clicked()), this, SLOT(play())); connect(nextButton, SIGNAL(clicked()), this, SLOT(next())); connect(prevButton, SIGNAL(clicked()), this, SLOT(prev())); connect(videoPlayer->mediaObject(), SIGNAL(finished()), this, SLOT(finished())); connect(videoPlayer->mediaObject(), SIGNAL(totalTimeChanged(qint64)), this, SLOT(updateTime())); connect(videoPlayer->mediaObject(), SIGNAL(tick(qint64)), this, SLOT(updateTime())); connect(videoPlayer->mediaObject(), SIGNAL(stateChanged(Phonon::State, Phonon::State)), this, SLOT(stateChanged(Phonon::State, Phonon::State))); connect(videoPlayer->mediaObject(), SIGNAL(metaDataChanged()), this, SLOT(updateInfo())); connect(timeSlider, SIGNAL(sliderReleased()),this, SLOT(seekFile())); connect(volumeSlider, SIGNAL(sliderReleased()),this, SLOT(saveVolume())); connect(volumeSlider, SIGNAL(valueChanged(int)),this, SLOT(changeVolume())); connect(this, SIGNAL(enterfullScreen()), this, SLOT(setFullScreen())); connect(this, SIGNAL(exitfullScreen()), this, SLOT(unsetFullScreen())); }
void VESPERSTimeScanConfiguration::computeTotalTimeImplementation() { double totalTime = 0; // Factor in the time per point. There is an extra 6 seconds for CCD images for the Roper and Mar. if (ccdDetector() == VESPERS::Roper) totalTime += timePerAcquisition() + timeOffset_ + 6.0; else if (ccdDetector() == VESPERS::Mar) totalTime += timePerAcquisition() + timeOffset_ + 3.0; else totalTime += timePerAcquisition() + timeOffset_; totalTime_ = iterations_*totalTime; setExpectedDuration(totalTime_); emit totalTimeChanged(totalTime_); }
void MediaObject::loadingFinished(MediaGraph *mg) { if (mg == currentGraph()) { #ifndef QT_NO_PHONON_MEDIACONTROLLER //Title interface m_currentTitle = 0; setTitles(currentGraph()->titles()); #endif //QT_NO_PHONON_MEDIACONTROLLER HRESULT hr = mg->renderResult(); if (catchComError(hr)) { return; } if (m_oldHasVideo != currentGraph()->hasVideo()) { emit hasVideoChanged(currentGraph()->hasVideo()); } #ifndef QT_NO_PHONON_VIDEO if (currentGraph()->hasVideo()) { updateVideoGeometry(); } #endif //QT_NO_PHONON_VIDEO emit metaDataChanged(currentGraph()->metadata()); emit totalTimeChanged(totalTime()); //let's put the next state switch(m_nextState) { case Phonon::PausedState: pause(); break; case Phonon::PlayingState: play(); break; case Phonon::ErrorState: setState(Phonon::ErrorState); break; case Phonon::StoppedState: default: stop(); break; } } }
void PlayerController::createPlayer() { m_mediaObject = new Phonon::MediaObject(this); m_audioOutput = new Phonon::AudioOutput(Phonon::MusicCategory, this); m_audioPath = Phonon::createPath(m_mediaObject, m_audioOutput); m_mediaObject->setTickInterval(1000); connect(m_mediaObject, SIGNAL(aboutToFinish()), SLOT(onAboutToFinish())); connect(m_mediaObject, SIGNAL(stateChanged(Phonon::State, Phonon::State)), SLOT(onStateChanged(Phonon::State))); connect(m_mediaObject, SIGNAL(tick(qint64)), SLOT(onTick(qint64))); connect(m_mediaObject, SIGNAL(totalTimeChanged(qint64)), SLOT(onTotalTimeChanged(qint64))); }
/* * !reimp */ void MediaObject::setSource(const MediaSource &source) { QMultiMap<QString, QString> ret; ret.insert(QLatin1String("ARTIST"), "Nokia Dude"); ret.insert(QLatin1String("ALBUM"), "Sound of silence"); ret.insert(QLatin1String("DATE"), "2009"); m_error = Phonon::NoError; setState(Phonon::LoadingState); m_source = source; currentPos = 0; if((source.fileName().contains(".avi")) || (source.fileName().contains(".mp4"))) { m_hasVideo = true; emit hasVideoChanged(m_hasVideo); } if(source.fileName().contains(".wav")) { QFile file(source.fileName()); if (file.open(QIODevice::ReadOnly)) { int len = file.read((char*)&header, sizeof(CombinedHeader)); if(len == sizeof(CombinedHeader)) { if(memcmp(&header.riff.descriptor.id, riffId, 4) != 0) { // Not a valid wav file, to satisfy unit test for mediaobject m_error = Phonon::FatalError; //m_state = Phonon::ErrorState; m_errorString = "Invalid wav file"; setState(Phonon::ErrorState); file.close(); return; } } file.close(); } } emit metaDataChanged(ret); emit currentSourceChanged(source); emit totalTimeChanged(m_totalTime); setState(Phonon::StoppedState); }
PhononEngine::PhononEngine(QObject * parent) : FooAudioEngine(parent) { d = new PhononEnginePrivate; d->audioOutput = new Phonon::AudioOutput(Phonon::MusicCategory, this); d->mediaObject = new Phonon::MediaObject(this); d->metaInformation = new Phonon::MediaObject(this); Phonon::createPath(d->mediaObject, d->audioOutput); d->mediaObject->setTickInterval(DEFAUL_INTERVAL); connect(d->mediaObject, SIGNAL(tick(qint64)), this, SIGNAL (progress(qint64))); connect(d->mediaObject, SIGNAL(aboutToFinish()), this, SIGNAL(aboutToFinish())); connect(d->mediaObject, SIGNAL(totalTimeChanged(qint64)), this, SIGNAL(changeTotalTime(qint64))); connect(d->metaInformation, SIGNAL(metaDataChanged()), this, SLOT(newMetaData())); connect(d->audioOutput, SIGNAL(mutedChanged(bool)), this, SIGNAL(muteChanged(bool))); connect(this, SIGNAL(seek(qint64)), d->mediaObject, SLOT(seek(qint64))); }
void MediaObject::switchToNextSource() { m_prefinishMarkSent = false; m_aboutToFinishSent = false; m_nextSourceReadyToStart = false; m_oldHasVideo = currentGraph()->hasVideo(); qSwap(m_graphs[0], m_graphs[1]); //swap the graphs if (m_transitionTime >= 0) m_graphs[1]->stop(); //make sure we stop the previous graph if (currentGraph()->mediaSource().type() != Phonon::MediaSource::Invalid && catchComError(currentGraph()->renderResult())) { setState(Phonon::ErrorState); return; } //we need to play the next media play(); //we tell the video widgets to switch now to the new source #ifndef QT_NO_PHONON_VIDEO for (int i = 0; i < m_videoWidgets.count(); ++i) { m_videoWidgets.at(i)->setCurrentGraph(currentGraph()->index()); } #endif //QT_NO_PHONON_VIDEO emit currentSourceChanged(currentGraph()->mediaSource()); emit metaDataChanged(currentGraph()->metadata()); if (nextGraph()->hasVideo() != currentGraph()->hasVideo()) { emit hasVideoChanged(currentGraph()->hasVideo()); } emit tick(0); emit totalTimeChanged(totalTime()); #ifndef QT_NO_PHONON_MEDIACONTROLLER setTitles(currentGraph()->titles()); #endif //QT_NO_PHONON_MEDIACONTROLLER }
void VESPERS2DScanConfiguration::computeTotalTimeImplementation() { double time = 0; // Get the number of points. time = scanAxisAt(0)->numberOfPoints() * scanAxisAt(1)->numberOfPoints(); // Factor in the time per point. There is an extra 6 seconds for CCD images for the Roper and Mar. if (ccdDetector() == VESPERS::Roper) time *= double(scanAxisAt(0)->regionAt(0)->regionTime()) + timeOffset_ + 6.0; else if (ccdDetector() == VESPERS::Mar) time *= double(scanAxisAt(0)->regionAt(0)->regionTime()) + timeOffset_ + 3.0; else time *= double(scanAxisAt(0)->regionAt(0)->regionTime()) + timeOffset_; totalTime_ = time + 9; setExpectedDuration(totalTime_); emit totalTimeChanged(totalTime_); }
void VESPERSSpatialLineScanConfiguration::computeTotalTimeImplementation() { double totalTime = 0; // Get the number of points. Using 0 for the index because this will only have one region per scan. totalTime = scanAxisAt(0)->regionAt(0)->numberOfPoints(); // Factor in the time per point. There is an extra 6 seconds for CCD images for the Roper and Mar. if (ccdDetector() == VESPERS::Roper) totalTime *= time() + timeOffset_ + 6.0; else if (ccdDetector() == VESPERS::Mar) totalTime *= time() + timeOffset_ + 3.0; else totalTime *= time() + timeOffset_; totalTime_ = totalTime + 9; setExpectedDuration(totalTime_); emit totalTimeChanged(totalTime_); }
void MediaObject::_iface_setCurrentTitle(int title, bool bseek) { #ifdef GRAPH_DEBUG qDebug() << "_iface_setCurrentTitle" << title; #endif const int oldTitle = m_currentTitle; m_currentTitle = title; updateStopPosition(); if (bseek) { //let's seek to the beginning of the song seek(0); } else { updateTargetTick(); } if (oldTitle != title) { emit titleChanged(title); emit totalTimeChanged(totalTime()); } }
//start id="get" void PhononItem::fetchMetaData() { delete m_metaMedia; m_mediaSource = Phonon::MediaSource(fileName()); if (m_mediaSource.type() == Phonon::MediaSource::Invalid) { qDebug() << "Invalid Media Source." << fileName(); emit fetched(false); } m_metaMedia = new Phonon::MediaObject(this); QObject::connect(m_metaMedia, SIGNAL(stateChanged(Phonon::State,Phonon::State)), this, SLOT(metaStateChanged(Phonon::State, Phonon::State)), Qt::QueuedConnection); QObject::connect(m_metaMedia, SIGNAL(totalTimeChanged(qint64)), this, SLOT(setTotalTime(qint64)), Qt::QueuedConnection); m_metaMedia->setCurrentSource(m_mediaSource); }
void SeekSlider::setMediaObject(MediaObject *media) { K_D(SeekSlider); if (d->media) { disconnect(d->media, 0, this, 0); } d->media = media; if (media) { connect(media, SIGNAL(stateChanged(Phonon::State, Phonon::State)), SLOT(_k_stateChanged(Phonon::State))); connect(media, SIGNAL(totalTimeChanged(qint64)), SLOT(_k_length(qint64))); connect(media, SIGNAL(tick(qint64)), SLOT(_k_tick(qint64))); connect(media, SIGNAL(seekableChanged(bool)), SLOT(_k_seekableChanged(bool))); connect(media, SIGNAL(currentSourceChanged(const Phonon::MediaSource&)), SLOT(_k_currentSourceChanged())); d->_k_stateChanged(media->state()); d->_k_seekableChanged(media->isSeekable()); d->_k_length(media->totalTime()); } else { d->_k_stateChanged(Phonon::StoppedState); d->_k_seekableChanged(false); } }
bool MediaObject::readHeader() { QByteArray header = m_stream->read(WAVEHEADER_SIZE); if (header.size() == WAVEHEADER_SIZE) { m_waveFormatEx.wFormatTag = *((WORD* )(header.data() + WAVEHEADER_OFFSET_FORMATTAG )); m_waveFormatEx.nChannels = *((WORD* )(header.data() + WAVEHEADER_OFFSET_CHANNELS )); m_waveFormatEx.nSamplesPerSec = *((DWORD*)(header.data() + WAVEHEADER_OFFSET_SAMPLESPERSEC )); m_waveFormatEx.nAvgBytesPerSec = *((DWORD*)(header.data() + WAVEHEADER_OFFSET_AVGBYTESPERSEC)); m_waveFormatEx.nBlockAlign = *((WORD* )(header.data() + WAVEHEADER_OFFSET_BLOCKALIGN )); m_waveFormatEx.wBitsPerSample = *((WORD* )(header.data() + WAVEHEADER_OFFSET_BITSPERSAMPLE )); m_tickIntervalResolution = (qint64(buffer_size) * 8 * 1000) / m_waveFormatEx.nSamplesPerSec / m_waveFormatEx.wBitsPerSample / m_waveFormatEx.nChannels; if (m_mediaSize > 0) m_totalTime = ((m_mediaSize - WAVEHEADER_SIZE) * 8 * 1000) / m_waveFormatEx.nSamplesPerSec / m_waveFormatEx.wBitsPerSample / m_waveFormatEx.nChannels; else m_totalTime = -1; emit totalTimeChanged(m_totalTime); return true; } else { return false; } }
void LayerSound::loadSoundAtFrame(QString filePathString, int frameNumber) { // if (getIndexAtFrame(frameNumber) == -1) addImageAtFrame(frameNumber); int index = getIndexAtFrame(frameNumber); if (index == -1) addImageAtFrame(frameNumber); index = getIndexAtFrame(frameNumber); QFileInfo fi(filePathString); if (fi.exists()) { // sound[index] = new QSound(filePathString, NULL); Phonon::MediaObject* media = new Phonon::MediaObject(); connect(media, SIGNAL(totalTimeChanged(qint64)), this, SLOT(addTimelineKey(qint64))); media->setCurrentSource(filePathString); // quick and dirty trick to calculate soundSize // totalTime() return a value only after a call to media.play() // ( and when signal totaltimechanged is emitted totalTime() returns the correct value ) Phonon::AudioOutput* audioOutput; audioOutput = new Phonon::AudioOutput(Phonon::MusicCategory, this); Phonon::createPath(media, audioOutput); media->play(); media->stop(); soundSize[index] = media->totalTime(); // totalTime() returns 0 now sound[index] = media; soundFilepath[index] = filePathString; framesFilename[index] = fi.fileName(); framesModified[index] = true; } else { sound[index] = NULL; soundFilepath[index] = "Wrong file"; framesFilename[index] = "Wrong file" + filePathString; } }
void MediaObject::handleEvents(Graph graph, long eventCode, long param1) { QString eventDescription; switch (eventCode) { case EC_BUFFERING_DATA: if (graph == currentGraph()->graph()) { m_buffering = param1; emit stateChanged(state(), m_state); } break; case EC_LENGTH_CHANGED: if (graph == currentGraph()->graph()) { emit totalTimeChanged( totalTime() ); } break; case EC_COMPLETE: handleComplete(graph); break; #ifndef QT_NO_PHONON_VIDEO case EC_VIDEO_SIZE_CHANGED: if (graph == currentGraph()->graph()) { updateVideoGeometry(); } break; #endif //QT_NO_PHONON_VIDEO #ifdef GRAPH_DEBUG case EC_ACTIVATE: qDebug() << "EC_ACTIVATE: A video window is being " << (param1 ? "ACTIVATED" : "DEACTIVATED"); break; case EC_BUILT: qDebug() << "EC_BUILT: Send by the Video Control when a graph has been built. Not forwarded to applications."; break; case EC_CLOCK_CHANGED: qDebug() << "EC_CLOCK_CHANGED"; break; case EC_CLOCK_UNSET: qDebug() << "EC_CLOCK_UNSET: The clock provider was disconnected."; break; case EC_CODECAPI_EVENT: qDebug() << "EC_CODECAPI_EVENT: Sent by an encoder to signal an encoding event."; break; case EC_DEVICE_LOST: qDebug() << "EC_DEVICE_LOST: A Plug and Play device was removed or has become available again."; break; case EC_DISPLAY_CHANGED: qDebug() << "EC_DISPLAY_CHANGED: The display mode has changed."; break; case EC_END_OF_SEGMENT: qDebug() << "EC_END_OF_SEGMENT: The end of a segment has been reached."; break; case EC_ERROR_STILLPLAYING: qDebug() << "EC_ERROR_STILLPLAYING: An asynchronous command to run the graph has failed."; break; case EC_ERRORABORT: qDebug() << "EC_ERRORABORT: An operation was aborted because of an error."; break; case EC_EXTDEVICE_MODE_CHANGE: qDebug() << "EC_EXTDEVICE_MODE_CHANGE: Not supported."; break; case EC_FULLSCREEN_LOST: qDebug() << "EC_FULLSCREEN_LOST: The video renderer is switching out of full-screen mode."; break; case EC_GRAPH_CHANGED: qDebug() << "EC_GRAPH_CHANGED: The filter graph has changed."; break; case EC_NEED_RESTART: qDebug() << "EC_NEED_RESTART: A filter is requesting that the graph be restarted."; break; case EC_NOTIFY_WINDOW: qDebug() << "EC_NOTIFY_WINDOW: Notifies a filter of the video renderer's window."; break; case EC_OLE_EVENT: qDebug() << "EC_OLE_EVENT: A filter is passing a text string to the application."; break; case EC_OPENING_FILE: qDebug() << "EC_OPENING_FILE: The graph is opening a file, or has finished opening a file."; break; case EC_PALETTE_CHANGED: qDebug() << "EC_PALETTE_CHANGED: The video palette has changed."; break; case EC_PAUSED: qDebug() << "EC_PAUSED: A pause request has completed."; break; case EC_PREPROCESS_COMPLETE: qDebug() << "EC_PREPROCESS_COMPLETE: Sent by the WM ASF Writer filter when it completes the pre-processing for multipass encoding."; break; case EC_QUALITY_CHANGE: qDebug() << "EC_QUALITY_CHANGE: The graph is dropping samples, for quality control."; break; case EC_REPAINT: qDebug() << "EC_REPAINT: A video renderer requires a repaint."; break; case EC_SEGMENT_STARTED: qDebug() << "EC_SEGMENT_STARTED: A new segment has started."; break; case EC_SHUTTING_DOWN: qDebug() << "EC_SHUTTING_DOWN: The filter graph is shutting down, prior to being destroyed."; break; case EC_SNDDEV_IN_ERROR: qDebug() << "EC_SNDDEV_IN_ERROR: A device error has occurred in an audio capture filter."; break; case EC_SNDDEV_OUT_ERROR: qDebug() << "EC_SNDDEV_OUT_ERROR: A device error has occurred in an audio renderer filter."; break; case EC_STARVATION: qDebug() << "EC_STARVATION: A filter is not receiving enough data."; break; case EC_STATE_CHANGE: qDebug() << "EC_STATE_CHANGE: The filter graph has changed state."; break; case EC_STEP_COMPLETE: qDebug() << "EC_STEP_COMPLETE: A filter performing frame stepping has stepped the specified number of frames."; break; case EC_STREAM_CONTROL_STARTED: qDebug() << "EC_STREAM_CONTROL_STARTED: A stream-control start command has taken effect."; break; case EC_STREAM_CONTROL_STOPPED: qDebug() << "EC_STREAM_CONTROL_STOPPED: A stream-control stop command has taken effect."; break; case EC_STREAM_ERROR_STILLPLAYING: qDebug() << "EC_STREAM_ERROR_STILLPLAYING: An error has occurred in a stream. The stream is still playing."; break; case EC_STREAM_ERROR_STOPPED: qDebug() << "EC_STREAM_ERROR_STOPPED: A stream has stopped because of an error."; break; case EC_TIMECODE_AVAILABLE: qDebug() << "EC_TIMECODE_AVAILABLE: Not supported."; break; case EC_UNBUILT: qDebug() << "Sent by the Video Control when a graph has been torn down. Not forwarded to applications."; break; case EC_USERABORT: qDebug() << "EC_USERABORT: Send by the Video Control when a graph has been torn down. Not forwarded to applications."; break; case EC_VMR_RECONNECTION_FAILED: qDebug() << "EC_VMR_RECONNECTION_FAILED: Sent by the VMR-7 and the VMR-9 when it was unable to accept a dynamic format change request from the upstream decoder."; break; case EC_VMR_RENDERDEVICE_SET: qDebug() << "EC_VMR_RENDERDEVICE_SET: Sent when the VMR has selected its rendering mechanism."; break; case EC_VMR_SURFACE_FLIPPED: qDebug() << "EC_VMR_SURFACE_FLIPPED: Sent when the VMR-7's allocator presenter has called the DirectDraw Flip method on the surface being presented."; break; case EC_WINDOW_DESTROYED: qDebug() << "EC_WINDOW_DESTROYED: The video renderer was destroyed or removed from the graph"; break; case EC_WMT_EVENT: qDebug() << "EC_WMT_EVENT: Sent by the Windows Media Format SDK when an application uses the ASF Reader filter to play ASF files protected by digital rights management (DRM)."; break; case EC_WMT_INDEX_EVENT: qDebug() << "EC_WMT_INDEX_EVENT: Sent by the Windows Media Format SDK when an application uses the ASF Writer to index Windows Media Video files."; break; //documented by Microsoft but not supported in the Platform SDK // case EC_BANDWIDTHCHANGE : qDebug() << "EC_BANDWIDTHCHANGE: not supported"; break; // case EC_CONTENTPROPERTY_CHANGED: qDebug() << "EC_CONTENTPROPERTY_CHANGED: not supported."; break; // case EC_EOS_SOON: qDebug() << "EC_EOS_SOON: not supported"; break; // case EC_ERRORABORTEX: qDebug() << "EC_ERRORABORTEX: An operation was aborted because of an error."; break; // case EC_FILE_CLOSED: qDebug() << "EC_FILE_CLOSED: The source file was closed because of an unexpected event."; break; // case EC_LOADSTATUS: qDebug() << "EC_LOADSTATUS: Notifies the application of progress when opening a network file."; break; // case EC_MARKER_HIT: qDebug() << "EC_MARKER_HIT: not supported."; break; // case EC_NEW_PIN: qDebug() << "EC_NEW_PIN: not supported."; break; // case EC_PLEASE_REOPEN: qDebug() << "EC_PLEASE_REOPEN: The source file has changed."; break; // case EC_PROCESSING_LATENCY: qDebug() << "EC_PROCESSING_LATENCY: Indicates the amount of time that a component is taking to process each sample."; break; // case EC_RENDER_FINISHED: qDebug() << "EC_RENDER_FINISHED: Not supported."; break; // case EC_SAMPLE_LATENCY: qDebug() << "EC_SAMPLE_LATENCY: Specifies how far behind schedule a component is for processing samples."; break; // case EC_SAMPLE_NEEDED: qDebug() << "EC_SAMPLE_NEEDED: Requests a new input sample from the Enhanced Video Renderer (EVR) filter."; break; // case EC_SCRUB_TIME: qDebug() << "EC_SCRUB_TIME: Specifies the time stamp for the most recent frame step."; break; // case EC_STATUS: qDebug() << "EC_STATUS: Contains two arbitrary status strings."; break; // case EC_VIDEOFRAMEREADY: qDebug() << "EC_VIDEOFRAMEREADY: A video frame is ready for display."; break; default: qDebug() << "Unknown event" << eventCode << "(" << param1 << ")"; break; #else default: break; #endif } }
VideoWindow::VideoWindow(QWidget * parent) : QMainWindow(parent) { setupUi(this); _mediaObject = new Phonon::MediaObject(this); _mediaObject->setTickInterval(1000); connect(_mediaObject, SIGNAL(tick(qint64)), SLOT(tick(qint64))); connect(_mediaObject, SIGNAL(totalTimeChanged(qint64)), SLOT(totalTimeChanged(qint64))); connect(_mediaObject, SIGNAL(stateChanged(Phonon::State, Phonon::State)), SLOT(stateChanged(Phonon::State, Phonon::State))); connect(_mediaObject, SIGNAL(metaDataChanged()), SLOT(metaDataChanged())); connect(_mediaObject, SIGNAL(currentSourceChanged(const Phonon::MediaSource &)), SLOT(sourceChanged(const Phonon::MediaSource &))); connect(_mediaObject, SIGNAL(aboutToFinish()), SLOT(aboutToFinish())); _mediaController = new Phonon::MediaController(_mediaObject); connect(_mediaController, SIGNAL(availableAudioChannelsChanged()), SLOT(availableAudioChannelsChanged())); connect(_mediaController, SIGNAL(availableSubtitlesChanged()), SLOT(availableSubtitlesChanged())); #ifdef NEW_TITLE_CHAPTER_HANDLING connect(_mediaController, SIGNAL(availableTitlesChanged()), SLOT(availableTitlesChanged())); connect(_mediaController, SIGNAL(availableChaptersChanged()), SLOT(availableChaptersChanged())); #else connect(_mediaController, SIGNAL(availableTitlesChanged(int)), SLOT(availableTitlesChanged())); connect(_mediaController, SIGNAL(availableChaptersChanged(int)), SLOT(availableChaptersChanged())); #endif //NEW_TITLE_CHAPTER_HANDLING connect(_mediaController, SIGNAL(availableAnglesChanged(int)), SLOT(availableAnglesChanged())); _videoWidget = new Phonon::VideoWidget(this); videoLayout->addWidget(_videoWidget); _videoWidget->setMinimumHeight(200); Phonon::createPath(_mediaObject, _videoWidget); _audioOutput = new Phonon::AudioOutput(Phonon::VideoCategory, this); Phonon::createPath(_mediaObject, _audioOutput); //actions connect connect(actionPlay, SIGNAL(triggered()), _mediaObject, SLOT(play())); connect(actionPause, SIGNAL(triggered()), _mediaObject, SLOT(pause())); connect(actionStop, SIGNAL(triggered()), _mediaObject, SLOT(stop())); connect(actionPlayDVD, SIGNAL(triggered()), SLOT(playDVD())); connect(actionOpenSubtitleFile, SIGNAL(triggered()), SLOT(openSubtitleFile())); connect(actionExit, SIGNAL(triggered()), _mediaObject, SLOT(stop())); connect(actionExit, SIGNAL(triggered()), SLOT(close())); //seekSlider _seekSlider = new Phonon::SeekSlider(); seekerLayout->insertWidget(0, _seekSlider); _seekSlider->setMediaObject(_mediaObject); //volumdeSlider _volumeSlider = new Phonon::VolumeSlider(); volumeLayout->insertWidget(0, _volumeSlider); _volumeSlider->setAudioOutput(_audioOutput); _volumeSlider->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum); //currentTimeLcdNumber currentTimeLcdNumber->display("00:00"); //totalTimeLcdNumber totalTimeLcdNumber->display("00:00"); }