]> git.sur5r.net Git - minitube/blob - src/video.h
new error signal when stream url cannot be determined
[minitube] / src / video.h
1 #ifndef VIDEO_H
2 #define VIDEO_H
3
4 #include <QtGui>
5 #include <QtNetwork>
6
7 class Video : public QObject {
8
9     Q_OBJECT
10
11 public:
12     Video();
13
14     const QString title() const { return m_title; }
15     void setTitle( QString title ) { m_title = title; }
16
17     const QString description() const { return m_description; }
18     void setDescription( QString description ) { m_description = description; }
19
20     const QString author() const { return m_author; }
21     void setAuthor( QString author ) { m_author = author; }
22
23     const QUrl webpage() const { return m_webpage; }
24     void setWebpage( QUrl webpage ) { m_webpage = webpage; }
25
26     void loadStreamUrl() {
27         if (m_streamUrl.isEmpty())
28             this->scrapeStreamUrl();
29         else emit gotStreamUrl(m_streamUrl);
30     }
31
32     QList<QUrl> thumbnailUrls() const { return m_thumbnailUrls; }
33     void addThumbnailUrl(QUrl url) {
34         m_thumbnailUrls << url;
35     }
36
37     void preloadThumbnail();
38     const QImage thumbnail() const;
39
40     int duration() const { return m_duration; }
41     void setDuration( int duration ) { m_duration = duration; }
42
43     int viewCount() const { return m_viewCount; }
44     void setViewCount( int viewCount ) { m_viewCount = viewCount; }
45
46     const QDateTime published() const { return m_published; }
47     void setPublished( QDateTime published ) { m_published = published; }
48
49 public slots:
50     void setThumbnail(QByteArray bytes);
51
52 signals:
53     void gotThumbnail();
54     void gotStreamUrl(QUrl streamUrl);
55     void errorStreamUrl();
56
57 private slots:
58     void gotVideoInfo(QByteArray);
59
60 private:
61     void scrapeStreamUrl();
62
63     QString m_title;
64     QString m_description;
65     QString m_author;
66     // QUrl m_authorUrl;
67     QUrl m_webpage;
68     QUrl m_streamUrl;
69     QImage m_thumbnail;
70     QList<QUrl> m_thumbnailUrls;
71     // QList<QImage> m_thumbnails;
72     int m_duration;
73     QDateTime m_published;
74     int m_viewCount;
75
76     // The YouTube video id
77     // This is needed by the gotVideoInfo callback
78     QString videoId;
79 };
80
81 // This is required in order to use QPointer<Video> as a QVariant
82 // as used by the Model/View playlist
83 typedef QPointer<Video> VideoPointer;
84 Q_DECLARE_METATYPE(VideoPointer)
85
86 #endif // VIDEO_H