]> git.sur5r.net Git - minitube/blob - src/video.h
New upstream version 3.1
[minitube] / src / video.h
1 /* $BEGIN_LICENSE
2
3 This file is part of Minitube.
4 Copyright 2009, Flavio Tordini <flavio.tordini@gmail.com>
5
6 Minitube is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
10
11 Minitube is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with Minitube.  If not, see <http://www.gnu.org/licenses/>.
18
19 $END_LICENSE */
20
21 #ifndef VIDEO_H
22 #define VIDEO_H
23
24 #include <QtCore>
25 #include <QtGui>
26
27 class YTVideo;
28
29 class Video : public QObject {
30     Q_OBJECT
31
32 public:
33     Video();
34     ~Video();
35     Video *clone();
36
37     enum License { LicenseYouTube = 1, LicenseCC };
38     Q_ENUM(License)
39
40     const QString &getTitle() const { return title; }
41     void setTitle(const QString &value) { title = value; }
42
43     const QString &getDescription() const { return description; }
44     void setDescription(const QString &value) { description = value; }
45
46     const QString &getChannelTitle() const { return channelTitle; }
47     void setChannelTitle(const QString &value) { channelTitle = value; }
48
49     const QString &getChannelId() const { return channelId; }
50     void setChannelId(const QString &value) { channelId = value; }
51
52     const QString &getWebpage();
53     void setWebpage(const QString &value);
54
55     void loadThumbnail();
56     const QPixmap &getThumbnail() const { return thumbnail; }
57
58     const QString &getThumbnailUrl() const { return thumbnailUrl; }
59     void setThumbnailUrl(const QString &value) { thumbnailUrl = value; }
60
61     const QString &getMediumThumbnailUrl() const { return mediumThumbnailUrl; }
62     void setMediumThumbnailUrl(const QString &value) { mediumThumbnailUrl = value; }
63
64     const QString &getLargeThumbnailUrl() const { return largeThumbnailUrl; }
65     void setLargeThumbnailUrl(const QString &value) { largeThumbnailUrl = value; }
66
67     int getDuration() const { return duration; }
68     void setDuration(int value);
69     const QString &getFormattedDuration() const { return formattedDuration; }
70
71     int getViewCount() const { return viewCount; }
72     void setViewCount(int value);
73     const QString &getFormattedViewCount() const { return formattedViewCount; }
74
75     const QDateTime &getPublished() const { return published; }
76     void setPublished(const QDateTime &value);
77     const QString &getFormattedPublished() const { return formattedPublished; }
78
79     int getDefinitionCode() const { return definitionCode; }
80
81     void loadStreamUrl();
82     const QString &getStreamUrl() { return streamUrl; }
83     bool isLoadingStreamUrl() const { return ytVideo != nullptr; }
84     void abortLoadStreamUrl();
85
86     const QString &getId() const { return id; }
87     void setId(const QString &value) { id = value; }
88
89     License getLicense() const { return license; }
90     void setLicense(License value) { license = value; }
91
92 signals:
93     void gotThumbnail();
94     void gotMediumThumbnail(const QByteArray &bytes);
95     void gotLargeThumbnail(const QByteArray &bytes);
96     void gotStreamUrl(const QString &videoUrl, const QString &audioUrl);
97     void errorStreamUrl(const QString &message);
98
99 private slots:
100     void setThumbnail(const QByteArray &bytes);
101     void streamUrlLoaded(const QString &streamUrl, const QString &audioUrl);
102
103 private:
104     QString title;
105     QString description;
106     QString channelTitle;
107     QString channelId;
108     QString webpage;
109     QString streamUrl;
110     QPixmap thumbnail;
111     QString thumbnailUrl;
112     QString mediumThumbnailUrl;
113     QString largeThumbnailUrl;
114     int duration;
115     QString formattedDuration;
116
117     QDateTime published;
118     QString formattedPublished;
119     int viewCount;
120     QString formattedViewCount;
121     License license;
122     QString id;
123     int definitionCode;
124
125     bool loadingThumbnail;
126
127     YTVideo *ytVideo;
128 };
129
130 // This is required in order to use QPointer<Video> as a QVariant
131 // as used by the Model/View playlist
132 typedef QPointer<Video> VideoPointer;
133 Q_DECLARE_METATYPE(VideoPointer)
134
135 #endif // VIDEO_H