예제 #1
0
void AudioPlayer::audioStateChanged(const QVariantMap &data)
{
    QVariantList players = data["audio_players"].toList();
    QVariantList::iterator it = players.begin();
    for (;it != players.end();it++)
    {
        QVariantMap r = it->toMap();
        if (r["player_id"].toString() == playerData["id"].toString())
        {
            load(r);
            break;
        }
    }
}
QVariantMap
YTVideoUrlFetcher::parseResponse(QJsonDocument doc)
{
    Q_ASSERT(doc.isObject());
    QVariantMap map = doc.object().toVariantMap();

    if (!map.contains("formats")) {
        qCritical() << "Output JSON does not contain formats array";
        return QVariantMap();
    }

    QVariant formats = map["formats"];
    if (formats.type() != QVariant::List) {
        qCritical() << "Formats is not an array!" << formats.type();
        return QVariantMap();
    }

    QVariantMap response;
    QVariantList lst = formats.toList();
    QVariantList::iterator it = lst.begin();
    for (;it != lst.end(); ++it) {
        QVariantMap entry = it->toMap();
        if (entry.isEmpty())
            continue;
        if (!entry.contains("format_id") || !entry.contains("url"))
            continue;

        QVariantMap details;
        details["url"] = entry["url"];

        int itag = entry["format_id"].toInt();
        switch (itag) {
        case 18:
            response.insert("360p", details);
            break;
        case 22:
            response.insert("720p", details);
            break;
        case 37:
            response.insert(("1080p"), details);
            break;
        }
    }

    return response;
}
예제 #3
0
void CameraModel::load(const QVariantMap &homeData)
{
    clear();

    if (!homeData.contains("cameras"))
    {
        qDebug() << "no camera entry";
        return;
    }

    QVariantList cameras = homeData["cameras"].toList();
    QVariantList::iterator it = cameras.begin();
    for (int i = 0;it != cameras.end();it++, i++)
    {
        QVariantMap r = it->toMap();
        CameraItem *p = new CameraItem(connection);
        p->load(r, i);
        appendRow(p);
    }
}
예제 #4
0
void AudioModel::load(const QVariantMap &homeData)
{
    clear();

    if (!homeData.contains("audio"))
    {
        qDebug() << "no audio entry";
        return;
    }

    QVariantList players = homeData["audio"].toList();
    QVariantList::iterator it = players.begin();
    for (;it != players.end();it++)
    {
        QVariantMap r = it->toMap();
        AudioPlayer *p = new AudioPlayer(connection);
        p->load(r);
        appendRow(p);
    }
}