1
/*  This file is part of the KDE project
2
    Copyright (C) 2007 Matthias Kretz <kretz@kde.org>
3
4
    This library is free software; you can redistribute it and/or
5
    modify it under the terms of the GNU Lesser General Public
6
    License as published by the Free Software Foundation; either
7
    version 2.1 of the License, or (at your option) version 3, or any
8
    later version accepted by the membership of KDE e.V. (or its
9
    successor approved by the membership of KDE e.V.), Nokia Corporation 
10
    (or its successors, if any) and the KDE Free Qt Foundation, which shall
11
    act as a proxy defined in Section 6 of version 3 of the license.
12
13
    This library is distributed in the hope that it will be useful,
14
    but WITHOUT ANY WARRANTY; without even the implied warranty of
15
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16
    Lesser General Public License for more details.
17
18
    You should have received a copy of the GNU Lesser General Public 
19
    License along with this library.  If not, see <http://www.gnu.org/licenses/>.
20
21
*/
22
23
#ifndef PHONON_MEDIACONTROLLER_H
24
#define PHONON_MEDIACONTROLLER_H
25
26
#include "phonon_export.h"
27
#include "objectdescription.h"
28
29
#include <QtCore/QObject>
30
#include <QtCore/QtGlobal>
31
32
QT_BEGIN_HEADER
33
QT_BEGIN_NAMESPACE
34
35
#ifndef QT_NO_PHONON_MEDIACONTROLLER
36
37
namespace Phonon
38
{
39
class MediaControllerPrivate;
40
class MediaObject;
41
42
/** \class MediaController mediacontroller.h Phonon/MediaController
43
 * \brief Controls optional features of a media file/device like title, chapter, angle.
44
 *
45
 * \ingroup Playback
46
 * \author Matthias Kretz <kretz@kde.org>
47
 */
48
class PHONON_EXPORT MediaController : public QObject
49
{
50
    Q_OBJECT
51
    Q_FLAGS(Features)
52
    public:
53
        enum Feature {
54
            Angles = 1,
55
            Chapters = 2,
56
            Titles = 4
57
        };
58
        Q_DECLARE_FLAGS(Features, Feature)
59
60
        MediaController(MediaObject *parent);
61
        ~MediaController();
62
63
        Features supportedFeatures() const;
64
65
        int availableAngles() const;
66
        int currentAngle() const;
67
68
        int availableChapters() const;
69
        int currentChapter() const;
70
71
        int availableTitles() const;
72
        int currentTitle() const;
73
74
        bool autoplayTitles() const;
75
76
        /**
77
         * Returns the selected audio stream.
78
         *
79
         * \see availableAudioChannels
80
         * \see setCurrentAudioChannel
81
         */
82
        AudioChannelDescription currentAudioChannel() const;
83
84
        /**
85
         * Returns the selected subtitle stream.
86
         *
87
         * \see availableSubtitles
88
         * \see setCurrentSubtitle
89
         */
90
        SubtitleDescription currentSubtitle() const;
91
92
        /**
93
         * Returns the audio streams that can be selected by the user. The
94
         * strings can directly be used in the user interface.
95
         *
96
         * \see selectedAudioChannel
97
         * \see setCurrentAudioChannel
98
         */
99
        QList<AudioChannelDescription> availableAudioChannels() const;
100
101
        /**
102
         * Returns the subtitle streams that can be selected by the user. The
103
         * strings can directly be used in the user interface.
104
         *
105
         * \see selectedSubtitle
106
         * \see setCurrentSubtitle
107
         */
108
        QList<SubtitleDescription> availableSubtitles() const;
109
110
        /**
111
         * Selects an audio stream from the media.
112
         *
113
         * Some media formats allow multiple audio streams to be stored in
114
         * the same file. Normally only one should be played back.
115
         *
116
         * \param stream Description of an audio stream
117
         *
118
         * \see availableAudioChannels()
119
         * \see currentAudioChannel()
120
         */
121
        void setCurrentAudioChannel(const Phonon::AudioChannelDescription &stream);
122
123
        /**
124
         * Selects a subtitle stream from the media.
125
         *
126
         * Some media formats allow multiple subtitle streams to be stored in
127
         * the same file. Normally only one should be displayed.
128
         *
129
         * \param stream description of a subtitle stream
130
         *
131
         * \see availableSubtitles()
132
         * \see currentSubtitle()
133
         */
134
        void setCurrentSubtitle(const Phonon::SubtitleDescription &stream);
135
136
    public Q_SLOTS:
137
        void setCurrentAngle(int angleNumber);
138
        void setCurrentChapter(int chapterNumber);
139
140
        /**
141
         * Skips to the given title \p titleNumber.
142
         *
143
         * If it was playing before the title change it will start playback on the new title if
144
         * autoplayTitles is enabled.
145
         */
146
        void setCurrentTitle(int titleNumber);
147
        void setAutoplayTitles(bool);
148
149
        /**
150
         * Skips to the next title.
151
         *
152
         * If it was playing before the title change it will start playback on the next title if
153
         * autoplayTitles is enabled.
154
         */
155
        void nextTitle();
156
157
        /**
158
         * Skips to the previous title.
159
         *
160
         * If it was playing before the title change it will start playback on the previous title if
161
         * autoplayTitles is enabled.
162
         */
163
        void previousTitle();
164
165
    Q_SIGNALS:
166
        void availableSubtitlesChanged();
167
        void availableAudioChannelsChanged();
168
        void availableAnglesChanged(int availableAngles);
169
        void angleChanged(int angleNumber);
170
        void availableChaptersChanged(int availableChapters);
171
        void chapterChanged(int chapterNumber);
172
        void availableTitlesChanged(int availableTitles);
173
        void titleChanged(int titleNumber);
174
175
    protected:
176
        MediaControllerPrivate *const d;
177
};
178
179
} // namespace Phonon
180
181
Q_DECLARE_OPERATORS_FOR_FLAGS(Phonon::MediaController::Features)
182
183
#endif //QT_NO_PHONON_MEDIACONTROLLER
184
185
QT_END_NAMESPACE
186
QT_END_HEADER
187
188
#endif // PHONON_MEDIACONTROLLER_H