source: trunk/src/3rdparty/phonon/mmf/abstractplayer.h@ 651

Last change on this file since 651 was 651, checked in by Dmitry A. Kuminov, 16 years ago

trunk: Merged in qt 4.6.2 sources.

  • Property svn:eol-style set to native
File size: 4.8 KB
Line 
1/* This file is part of the KDE project.
2
3Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
4
5This library is free software: you can redistribute it and/or modify
6it under the terms of the GNU Lesser General Public License as published by
7the Free Software Foundation, either version 2.1 or 3 of the License.
8
9This library is distributed in the hope that it will be useful,
10but WITHOUT ANY WARRANTY; without even the implied warranty of
11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12GNU Lesser General Public License for more details.
13
14You should have received a copy of the GNU Lesser General Public License
15along with this library. If not, see <http://www.gnu.org/licenses/>.
16
17*/
18
19#ifndef PHONON_MMF_ABSTRACTPLAYER_H
20#define PHONON_MMF_ABSTRACTPLAYER_H
21
22#include <phonon/phononnamespace.h>
23#include <phonon/mediasource.h>
24
25#include <QObject>
26
27#include "videooutput.h"
28
29class RFile;
30
31QT_BEGIN_NAMESPACE
32
33namespace Phonon
34{
35namespace MMF
36{
37class VideoOutput;
38
39/**
40 * @short Interface which abstracts from MediaObject the current
41 * media type
42 *
43 * This may be:
44 * - Nothing, in which case this interface is implemented by
45 * DummyPlayer
46 * - Audio, in which case the implementation is AudioPlayer
47 * - Video, in which case the implementation is VideoPlayer
48 */
49class AbstractPlayer : public QObject
50{
51 // Required although this class has no signals or slots
52 // Without this, qobject_cast will fail
53 Q_OBJECT
54
55public:
56 AbstractPlayer(const AbstractPlayer *player);
57
58 virtual void open(const Phonon::MediaSource&, RFile&) = 0;
59
60 // MediaObjectInterface (implemented)
61 qint32 tickInterval() const;
62 void setTickInterval(qint32);
63 void setTransitionTime(qint32);
64 qint32 transitionTime() const;
65 void setPrefinishMark(qint32);
66 qint32 prefinishMark() const;
67
68 // MediaObjectInterface (abstract)
69 virtual void play() = 0;
70 virtual void pause() = 0;
71 virtual void stop() = 0;
72 virtual void seek(qint64 milliseconds) = 0;
73 virtual bool hasVideo() const = 0;
74 virtual bool isSeekable() const = 0;
75 virtual qint64 currentTime() const = 0;
76 virtual Phonon::ErrorType errorType() const;
77 virtual QString errorString() const;
78 virtual qint64 totalTime() const = 0;
79
80 virtual void volumeChanged(qreal volume);
81
82 void setVideoOutput(VideoOutput* videoOutput);
83
84 /**
85 * Records error message and changes state to ErrorState
86 */
87 void setError(const QString &errorMessage);
88
89 /**
90 * Records error message and changes state to ErrorState
91 *
92 * Appends a human-readable version of symbianErrorCode to the error message,
93 * e.g.
94 * @code
95 * setError("Opening file failed", KErrPermissionDenied)
96 * @endcode
97 * results in the following error message:
98 * "Opening file failed: permission denied"
99 */
100 void setError(const QString &errorMessage, int symbianErrorCode);
101
102 Phonon::State state() const;
103
104Q_SIGNALS:
105 void totalTimeChanged(qint64 length);
106 void finished();
107 void tick(qint64 time);
108 void bufferStatus(int percentFilled);
109 void stateChanged(Phonon::State newState,
110 Phonon::State oldState);
111 void metaDataChanged(const QMultiMap<QString, QString>& metaData);
112 void aboutToFinish();
113 void prefinishMarkReached(qint32 remaining);
114
115protected:
116 /**
117 * Defined private state enumeration in order to add GroundState
118 */
119 enum PrivateState {
120 LoadingState = Phonon::LoadingState,
121 StoppedState = Phonon::StoppedState,
122 PlayingState = Phonon::PlayingState,
123 BufferingState = Phonon::BufferingState,
124 PausedState = Phonon::PausedState,
125 ErrorState = Phonon::ErrorState,
126 GroundState
127 };
128
129 /**
130 * Converts PrivateState into the corresponding Phonon::State
131 */
132 Phonon::State phononState() const;
133
134 /**
135 * Converts PrivateState into the corresponding Phonon::State
136 */
137 static Phonon::State phononState(PrivateState state);
138
139 virtual void videoOutputChanged();
140
141 PrivateState privateState() const;
142
143 /**
144 * Changes state and emits stateChanged()
145 */
146 virtual void changeState(PrivateState newState);
147
148 /**
149 * Modifies m_state directly. Typically you want to call changeState(),
150 * which performs the business logic.
151 */
152 void setState(PrivateState newState);
153
154private:
155 virtual void doSetTickInterval(qint32 interval) = 0;
156
157protected:
158 // Not owned
159 VideoOutput* m_videoOutput;
160
161 qreal m_volume;
162
163private:
164 PrivateState m_state;
165 Phonon::ErrorType m_error;
166 QString m_errorString;
167 qint32 m_tickInterval;
168 qint32 m_transitionTime;
169 qint32 m_prefinishMark;
170
171};
172}
173}
174
175QT_END_NAMESPACE
176
177#endif
178
Note: See TracBrowser for help on using the repository browser.