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::createIOFactory(const QUrl &url) { if (haveIOFactory()) deleteIOFactory(); if (url.scheme() == "file" || QFileInfo(url.toString()).isAbsolute() || url.toString().endsWith(".cda")) m_io_factory = new DecoderIOFactoryFile(this); else if (m_meta && m_meta->Format() == "cast") m_io_factory = new DecoderIOFactoryShoutCast(this); else m_io_factory = new DecoderIOFactoryUrl(this); }
void DecoderHandler::deleteIOFactory(void) { if (!haveIOFactory()) return; if (m_state == ACTIVE) m_io_factory->stop(); m_io_factory->removeListener(this); m_io_factory->disconnect(); m_io_factory->deleteLater(); m_io_factory = NULL; }
void DecoderHandler::createIOFactory(const QUrl &url) { if (haveIOFactory()) deleteIOFactory(); if (url.scheme() == "myth") m_io_factory = new DecoderIOFactorySG(this); else if (m_meta && m_meta->Format() == "cast") m_io_factory = new DecoderIOFactoryShoutCast(this); else if (url.scheme() == "http") m_io_factory = new DecoderIOFactoryUrl(this); else m_io_factory = new DecoderIOFactoryFile(this); }