bool DecoderHandler::next(void) { if (done()) return false; if (m_meta.Format() == "cast") { m_playlist_pos = random() % m_playlist.size(); } else { m_playlist_pos++; } PlayListFileEntry *entry = m_playlist.get(m_playlist_pos); if (QFileInfo(entry->File()).isAbsolute()) m_url = QUrl::fromLocalFile(entry->File()); else m_url.setUrl(entry->File()); LOG(VB_PLAYBACK, LOG_INFO, QString("Now playing '%1'").arg(m_url.toString())); deleteIOFactory(); createIOFactory(m_url); if (! haveIOFactory()) return false; getIOFactory()->addListener(this); getIOFactory()->start(); m_state = ACTIVE; return true; }
void DecoderHandler::doConnectDecoder(const QUrl &url, const QString &format) { if (m_decoder && !m_decoder->factory()->supports(format)) { delete m_decoder; m_decoder = NULL; } if (!m_decoder) { if ((m_decoder = Decoder::create(format, NULL, NULL, true)) == NULL) { doFailed(url, QString("No decoder for this format '%1'").arg(format)); return; } } m_decoder->setInput(getIOFactory()->takeInput()); m_decoder->setFilename(url.toString()); DecoderHandlerEvent ev(DecoderHandlerEvent::Ready); dispatch(ev); }