Sound::Sound(QObject* parent) : QObject(parent) { #ifndef NO_SOUND qDebug() << BackendCapabilities::availableMimeTypes(); media_ = new MediaObject(this); output_ = new AudioOutput(MusicCategory, this); createPath(media_, output_); #ifndef Q_OS_LINUX media_->setCurrentSource(MediaSource(QString(":/sounds/shortwhoosh.mp3"))); #else media_->setCurrentSource(MediaSource(QString(":/sounds/shortwhoosh.ogg"))); #endif #endif }
void KNMusicBackendPhononThread::clear() { //Remove the media sources. m_mediaObject->clear(); //Clear the media source. m_mediaSource=MediaSource(); //Reset the state. resetState(); }
void PlayerVideo::load(Nameable *_tag, bool _isVideo, const QString &filename) { tag = _tag; isVideo = _isVideo; if(!isVideo) { QIcon icon; icon.addFile(QString::fromUtf8(":/icons/res_icon_audio_off.png"), QSize(), QIcon::Normal, QIcon::Off); icon.addFile(QString::fromUtf8(":/icons/res_icon_audio_on.png"), QSize(), QIcon::Normal, QIcon::On); ui->showVideo->setIcon(icon); } ui->playerVideo->load(MediaSource(filename)); refreshControls(); }
void MediaObject::emitTick() { if (m_resumeState) { return; } if(m_tickInterval > 0) currentPos += m_tickInterval; else currentPos += 100; qint64 currentTime = currentPos; qint64 totalTime = m_totalTime; if (m_tickInterval > 0 && currentTime != m_previousTickTime) { emit tick(currentTime); m_previousTickTime = currentTime; } if (m_state == Phonon::PlayingState) { if (currentTime >= totalTime - m_prefinishMark) { if (m_prefinishMarkReachedNotEmitted) { m_prefinishMarkReachedNotEmitted = false; emit prefinishMarkReached(totalTime - currentTime); } } // Prepare load of next source if (currentTime >= totalTime - 500) { if (!m_aboutToFinishEmitted) { m_aboutToFinishEmitted = true; // track is about to finish emit aboutToFinish(); } } if(currentTime >= totalTime) { m_tickTimer->stop(); if(m_nextSource.type() != MediaSource::Invalid && m_nextSource.type() != MediaSource::Empty) { setSource(m_nextSource); m_nextSource = MediaSource(); m_pendingState = Phonon::PlayingState; } else { setState(Phonon::PausedState); currentPos = 0; emit finished(); } } } }
bool KNMusicBackendPhononThread::loadFromFile(const QString &filePath) { //Stop playing. stop(); //Check if the media source is just the current file, then ignore the loading. QUrl currentUrl=QUrl::fromLocalFile(filePath); if(m_mediaSource==currentUrl) { resetState(); //Emit load succeed signal. emit loaded(); return true; } //Reset the total duration and state. m_totalDuration=-1; resetState(); //Generate the media source. m_mediaSource=MediaSource(currentUrl); //Load the file to media source. m_mediaObject->setCurrentSource(m_mediaSource); //Set the load flag. m_loadFlag=true; return (m_mediaObject->errorType()==NoError); }
Phonon::MediaSource MediaObject::source() const { return d->sources.empty() ? MediaSource() : d->sources.head(); }
void ZSound::parse(const ZConfig &el){ if(el.hasAttribute("src")){ _mediaObject->setCurrentSource(MediaSource(el.attribute("src"))); } }
void MediaObject::clear() { K_D(MediaObject); d->sourceQueue.clear(); setCurrentSource(MediaSource()); }