void MediaObject::setSource(const Phonon::MediaSource &source) { if (m_state == Phonon::PlayingState) { setError(Phonon::NormalError, QLatin1String("source changed while playing")); stop(); } m_source = source; m_hasSource = true; m_sourceIsValid = false; emit currentSourceChanged(source); if (source.type() == Phonon::MediaSource::LocalFile) { if (!openWaveFile(source.fileName())) { setError(Phonon::FatalError, QLatin1String("cannot open media file")); return ; } } else if (source.type() == Phonon::MediaSource::Stream) { if (m_stream) delete m_stream; m_stream = new IOWrapper(this, source); m_mediaSize = m_stream->size(); } else if (source.type() == Phonon::MediaSource::Url) { if (!openWaveFile(source.url().toLocalFile())) { setError(Phonon::FatalError, QLatin1String("cannot open media file")); return ; } } else { setError(Phonon::FatalError, QLatin1String("type of source not supported")); return ; } setState(Phonon::LoadingState); if (!readHeader()) setError(Phonon::FatalError, QLatin1String("invalid header")); else if (!getWaveOutDevice()) setError(Phonon::FatalError, QLatin1String("No waveOut device available")); else if (!fillBuffers()) setError(Phonon::FatalError, QLatin1String("no data for buffering")); else if (!prepareBuffers()) setError(Phonon::FatalError, QLatin1String("cannot prepare buffers")); else m_sourceIsValid = true; if (m_sourceIsValid) setState(Phonon::StoppedState); }
void Playlist::currentSourceChanged(const Phonon::MediaSource & newSource) //connected to MediaObject::currentSourceChanged { //Update currentUrl and check next mediaItem to decide how to setAutoplayTitles if (newSource.type() == Phonon::MediaSource::Disc) { if (m_queue->rowCount() > 0) { if (Utilities::isDisc(m_queue->mediaItemAt(0).url)) { m_currentUrl = m_queue->mediaItemAt(0).url; if (m_queue->rowCount() >1) { m_mediaController->setAutoplayTitles((m_queue->mediaItemAt(1).fields["trackNumber"].toInt() == m_mediaController->currentTitle() + 1)); } } } } else { m_currentUrl = newSource.url().toString(); } updateNowPlaying(); }
void MainWindow::currentSourceChanged(Phonon::MediaSource const& mediaSource) { qDebug() << "MainWindow::currentSourceChanged()" << mediaSource.url(); }