0
|
1 |
/* This file is part of the KDE project.
|
|
2 |
|
|
3 |
Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
4 |
|
|
5 |
This library is free software: you can redistribute it and/or modify
|
|
6 |
it under the terms of the GNU Lesser General Public License as published by
|
|
7 |
the Free Software Foundation, either version 2.1 or 3 of the License.
|
|
8 |
|
|
9 |
This library is distributed in the hope that it will be useful,
|
|
10 |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12 |
GNU Lesser General Public License for more details.
|
|
13 |
|
|
14 |
You should have received a copy of the GNU Lesser General Public License
|
|
15 |
along 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 "volumeobserver.h"
|
|
28 |
|
|
29 |
#include "videooutput.h"
|
|
30 |
|
|
31 |
class RFile;
|
|
32 |
|
|
33 |
QT_BEGIN_NAMESPACE
|
|
34 |
|
|
35 |
namespace Phonon
|
|
36 |
{
|
|
37 |
namespace MMF
|
|
38 |
{
|
|
39 |
class VideoOutput;
|
|
40 |
|
|
41 |
/**
|
|
42 |
* @short Interface which abstracts from MediaObject the current
|
|
43 |
* media type
|
|
44 |
*
|
|
45 |
* This may be:
|
|
46 |
* - Nothing, in which case this interface is implemented by
|
|
47 |
* DummyPlayer
|
|
48 |
* - Audio, in which case the implementation is AudioPlayer
|
|
49 |
* - Video, in which case the implementation is VideoPlayer
|
|
50 |
*/
|
|
51 |
class AbstractPlayer : public QObject
|
|
52 |
, public VolumeObserver
|
|
53 |
{
|
|
54 |
// Required although this class has no signals or slots
|
|
55 |
// Without this, qobject_cast will fail
|
|
56 |
Q_OBJECT
|
|
57 |
|
|
58 |
public:
|
|
59 |
AbstractPlayer();
|
|
60 |
explicit AbstractPlayer(const AbstractPlayer& player);
|
|
61 |
|
|
62 |
// MediaObjectInterface (implemented)
|
|
63 |
qint32 tickInterval() const;
|
|
64 |
void setTickInterval(qint32);
|
|
65 |
void setTransitionTime(qint32);
|
|
66 |
qint32 transitionTime() const;
|
|
67 |
void setPrefinishMark(qint32);
|
|
68 |
qint32 prefinishMark() const;
|
|
69 |
|
|
70 |
// MediaObjectInterface (abstract)
|
|
71 |
virtual void play() = 0;
|
|
72 |
virtual void pause() = 0;
|
|
73 |
virtual void stop() = 0;
|
|
74 |
virtual void seek(qint64 milliseconds) = 0;
|
|
75 |
virtual bool hasVideo() const = 0;
|
|
76 |
virtual bool isSeekable() const = 0;
|
|
77 |
virtual qint64 currentTime() const = 0;
|
|
78 |
virtual Phonon::ErrorType errorType() const;
|
|
79 |
virtual QString errorString() const;
|
|
80 |
virtual qint64 totalTime() const = 0;
|
|
81 |
virtual Phonon::MediaSource source() const = 0;
|
|
82 |
// This is a temporary hack to work around KErrInUse from MMF
|
|
83 |
// client utility OpenFileL calls
|
|
84 |
//virtual void setSource(const Phonon::MediaSource &) = 0;
|
|
85 |
virtual void setFileSource(const Phonon::MediaSource&, RFile&) = 0;
|
|
86 |
virtual void setNextSource(const Phonon::MediaSource &) = 0;
|
|
87 |
|
|
88 |
// VolumeObserver
|
|
89 |
virtual void volumeChanged(qreal volume);
|
|
90 |
|
|
91 |
void setVideoOutput(VideoOutput* videoOutput);
|
|
92 |
|
|
93 |
/**
|
|
94 |
* Records error and changes state to ErrorState
|
|
95 |
*/
|
|
96 |
void setError(Phonon::ErrorType error);
|
|
97 |
|
|
98 |
Phonon::State state() const;
|
|
99 |
Q_SIGNALS:
|
|
100 |
void totalTimeChanged(qint64 length);
|
|
101 |
void finished();
|
|
102 |
void tick(qint64 time);
|
|
103 |
void stateChanged(Phonon::State oldState,
|
|
104 |
Phonon::State newState);
|
|
105 |
|
|
106 |
|
|
107 |
protected:
|
|
108 |
/**
|
|
109 |
* Defined private state enumeration in order to add GroundState
|
|
110 |
*/
|
|
111 |
enum PrivateState {
|
|
112 |
LoadingState = Phonon::LoadingState,
|
|
113 |
StoppedState = Phonon::StoppedState,
|
|
114 |
PlayingState = Phonon::PlayingState,
|
|
115 |
BufferingState = Phonon::BufferingState,
|
|
116 |
PausedState = Phonon::PausedState,
|
|
117 |
ErrorState = Phonon::ErrorState,
|
|
118 |
GroundState
|
|
119 |
};
|
|
120 |
|
|
121 |
/**
|
|
122 |
* Converts PrivateState into the corresponding Phonon::State
|
|
123 |
*/
|
|
124 |
Phonon::State phononState() const;
|
|
125 |
|
|
126 |
/**
|
|
127 |
* Converts PrivateState into the corresponding Phonon::State
|
|
128 |
*/
|
|
129 |
static Phonon::State phononState(PrivateState state);
|
|
130 |
|
|
131 |
virtual void videoOutputChanged();
|
|
132 |
|
|
133 |
PrivateState privateState() const;
|
|
134 |
|
|
135 |
virtual void changeState(PrivateState newState) = 0;
|
|
136 |
|
|
137 |
/**
|
|
138 |
* Modifies m_state directly. Typically you want to call changeState(),
|
|
139 |
* which performs the business logic.
|
|
140 |
*/
|
|
141 |
void setState(PrivateState newState);
|
|
142 |
|
|
143 |
private:
|
|
144 |
virtual void doSetTickInterval(qint32 interval) = 0;
|
|
145 |
|
|
146 |
protected:
|
|
147 |
// Not owned
|
|
148 |
VideoOutput* m_videoOutput;
|
|
149 |
|
|
150 |
qreal m_volume;
|
|
151 |
|
|
152 |
private:
|
|
153 |
PrivateState m_state;
|
|
154 |
Phonon::ErrorType m_error;
|
|
155 |
qint32 m_tickInterval;
|
|
156 |
qint32 m_transitionTime;
|
|
157 |
qint32 m_prefinishMark;
|
|
158 |
|
|
159 |
};
|
|
160 |
}
|
|
161 |
}
|
|
162 |
|
|
163 |
QT_END_NAMESPACE
|
|
164 |
|
|
165 |
#endif
|
|
166 |
|