Esempio n. 1
0
void DecoderIOFactoryShoutCast::shoutcastChangedState(ShoutCastIODevice::State state)
{
    LOG(VB_PLAYBACK, LOG_INFO, QString("ShoutCast changed state to %1")
        .arg(ShoutCastIODevice::stateString(state)));

    if (state == ShoutCastIODevice::RESOLVING)
        doOperationStart(tr("Finding radio stream"));

    if (state == ShoutCastIODevice::CANT_RESOLVE)
        doFailed(tr("Cannot find radio.\nCheck the URL is correct."));

    if (state == ShoutCastIODevice::CONNECTING)
        doOperationStart(tr("Connecting to radio stream"));

    if (state == ShoutCastIODevice::CANT_CONNECT)
        doFailed(tr("Cannot connect to radio.\nCheck the URL is correct."));

    if (state == ShoutCastIODevice::CONNECTED)
    {
        doOperationStart(tr("Connected to radio stream"));
        m_timer->stop();
        m_timer->disconnect();
        connect(m_timer, SIGNAL(timeout()),
                this, SLOT(periodicallyCheckResponse()));
        m_timer->start(300);
    }

    if (state == ShoutCastIODevice::PLAYING)
    {
        doOperationStart(tr("Buffering"));
    }

    if (state == ShoutCastIODevice::STOPPED)
        stop();
}
Esempio n. 2
0
void DecoderHandler::createPlaylistFromRemoteUrl(const QUrl &url) 
{
    LOG(VB_NETWORK, LOG_INFO,
        QString("Retrieving playlist from '%1'").arg(url.toString()));

    doOperationStart(tr("Retrieving playlist"));

    QString extension = QFileInfo(url.path()).suffix().toLower();
    QString saveFilename = GetConfDir() + "/MythMusic/playlist." + extension;
    GetMythDownloadManager()->queueDownload(url.toString(), saveFilename, this);

    //TODO should find a better way to do this
    QTime time;
    time.start();
    while (m_state == LOADING)
    {
        if (time.elapsed() > 30000)
        {
            doOperationStop();
            GetMythDownloadManager()->cancelDownload(url.toString());
            LOG(VB_GENERAL, LOG_ERR, QString("DecoderHandler:: Timed out trying to download playlist from: %1")
                .arg(url.toString()));
            m_state = STOPPED;
        }

        qApp->processEvents();
        usleep(500);
    }
}
Esempio n. 3
0
void DecoderIOFactoryShoutCast::start(void)
{
    LOG(VB_PLAYBACK, LOG_INFO,
        QString("DecoderIOFactoryShoutCast %1").arg(getUrl().toString()));
    doOperationStart(tr("Connecting"));

    makeIODevice();
    m_input->connectToUrl(getUrl());
}
Esempio n. 4
0
void DecoderIOFactoryUrl::start(void)
{
    VERBOSE(VB_PLAYBACK, QString("DecoderIOFactory: Url %1").arg(getUrl().toString()));

    m_started = false;

    doOperationStart("Fetching remote file");

    m_reply = m_accessManager->get(QNetworkRequest(getUrl()));

    connect(m_reply, SIGNAL(readyRead()), this, SLOT(readyRead()));
    connect(m_accessManager, SIGNAL(finished(QNetworkReply*)),
            this, SLOT(replyFinished(QNetworkReply*)));
}
Esempio n. 5
0
bool DecoderHandler::createPlaylistFromRemoteUrl(const QUrl &url) 
{
    VERBOSE(VB_NETWORK, QString("Retrieving playlist from '%1'").arg(url.toString()));

    doOperationStart("Retrieving playlist");

    QByteArray data;

    if (!GetMythDownloadManager()->download(url, &data))
        return false;

    doOperationStop();

    QTextStream stream(&data, QIODevice::ReadOnly);

    bool result = PlayListFile::parse(&m_playlist, &stream) > 0;

    return result;
}