Active Topics

 


Reply
Thread Tools
marxian's Avatar
Posts: 2,448 | Thanked: 9,523 times | Joined on Aug 2010 @ Wigan, UK
#1
QYouTube is a Qt/C++ library and QML module for accessing the YouTube Data API (version 3). The library provides a number of classes providing read/write access to the YouTube Data API, categorized by resource type (activities, channels, videos etc). There are also accompanying data models for convenient display of data in item views. There are additional classes for obtaining a list of video streams and subtitles, which do not require access to the YouTube Data API.

Packages available for Maemo5 are:
  • qyoutube - C++ library.
  • qyoutube-qml - QML module exposing the classes to QML (depends on qyoutube).
  • qyoutube-dev - Development headers for qyoutube.

QYouTube has also been tested against Qt5, so it should 'just work' on any platform supporting Qt4.7+.

Some links:

Quick video search example in QML:

Code:
import QtQuick 1.0
import QYouTube 1.0

Rectangle {
    width: 800
    height: 480
    color: "#000"

    Rectangle {
        id: searchBox

        height: 50
        anchors {
            left: parent.left
            right: parent.right
            top: parent.top
            margins: 10
        }
        color: "#fff"
        border {
            width: 2
            color: "green"
        }

        TextInput {
            id: searchField

            anchors.fill: parent
            onAccepted: searchModel.list(["snippet"], {}, {type: "video", maxResults: 20, q: text})
        }
    }

    ListView {
        id: view

        anchors {
            left: parent.left
            right: parent.right
            top: searchBox.bottom
            topMargin: 10
            bottom: parent.bottom
        }
        clip: true
        model: SearchModel {
            id: searchModel

            apiKey: MY_API_KEY
            onStatusChanged: if (status == SearchRequest.Failed) console.log("SearchModel error: " + errorString);
        }
        delegate: Item {
            width: view.width
            height: 100

            Image {
                id: image

                width: 120
                height: 90
                anchors {
                    left: parent.left
                    leftMargin: 10
                    verticalCenter: parent.verticalCenter
                }
                source: snippet.thumbnails["default"].url
            }

            Column {
                anchors {
                    left: image.right
                    leftMargin: 10
                    right: parent.right
                    rightMargin: 10
                    verticalCenter: parent.verticalCenter
                }
                spacing: 10

                Text {
                    width: parent.width
                    elide: Text.ElideRight
                    color: "#fff"
                    text: snippet.title
                }

                Text {
                    width: parent.width
                    elide: Text.ElideRight
                    color: "#999"
                    text: "By " + snippet.channelTitle
                }
            }

            MouseArea {
                anchors.fill: parent
                onClicked: streams.list(id.videoId)
            }
        }
    }

    StreamsRequest {
        id: streams

        onFinished: {
            if (status == StreamsRequest.Ready) {
                for (var i = 0; i < result.length; i++) {
                    var stream = result[i];
                    console.log(stream.description + " - " + stream.width + "x" + stream.height + ": " + stream.url);
                }
            }
            else {
                console.log("StreamsRequest error: " + errorString);
            }
        }
    }
}
__________________
'Men of high position are allowed, by a special act of grace, to accomodate their reasoning to the answer they need. Logic is only required in those of lesser rank.' - J K Galbraith

My website

GitHub

Last edited by marxian; 2015-03-05 at 21:39.
 

The Following 17 Users Say Thank You to marxian For This Useful Post:
n900user259's Avatar
Posts: 155 | Thanked: 309 times | Joined on Apr 2010 @ The Netherlands
#2
As always, awesome stuff!
 

The Following 3 Users Say Thank You to n900user259 For This Useful Post:
Reply

Tags
library, youtube


 
Forum Jump


All times are GMT. The time now is 08:53.