|
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_ABSTRACTMEDIAPLAYER_H |
|
20 #define PHONON_MMF_ABSTRACTMEDIAPLAYER_H |
|
21 |
|
22 #include <QTimer> |
|
23 #include <QScopedPointer> |
|
24 #include <e32std.h> |
|
25 #include "abstractplayer.h" |
|
26 |
|
27 class RFile; |
|
28 |
|
29 QT_BEGIN_NAMESPACE |
|
30 |
|
31 namespace Phonon |
|
32 { |
|
33 namespace MMF |
|
34 { |
|
35 class AudioOutput; |
|
36 |
|
37 /** |
|
38 * Interface via which MMF client APIs for both audio and video can be |
|
39 * accessed. |
|
40 */ |
|
41 class AbstractMediaPlayer : public AbstractPlayer |
|
42 { |
|
43 Q_OBJECT |
|
44 |
|
45 protected: |
|
46 AbstractMediaPlayer(); |
|
47 explicit AbstractMediaPlayer(const AbstractPlayer& player); |
|
48 |
|
49 public: |
|
50 // MediaObjectInterface |
|
51 virtual void play(); |
|
52 virtual void pause(); |
|
53 virtual void stop(); |
|
54 virtual void seek(qint64 milliseconds); |
|
55 virtual bool isSeekable() const; |
|
56 virtual MediaSource source() const; |
|
57 virtual void setFileSource(const Phonon::MediaSource&, RFile&); |
|
58 virtual void setNextSource(const MediaSource &source); |
|
59 |
|
60 // VolumeObserver |
|
61 virtual void volumeChanged(qreal volume); |
|
62 |
|
63 protected: |
|
64 // AbstractPlayer |
|
65 virtual void doSetTickInterval(qint32 interval); |
|
66 |
|
67 virtual void doPlay() = 0; |
|
68 virtual void doPause() = 0; |
|
69 virtual void doStop() = 0; |
|
70 virtual void doSeek(qint64 pos) = 0; |
|
71 virtual int setDeviceVolume(int mmfVolume) = 0; |
|
72 virtual int openFile(RFile& file) = 0; |
|
73 virtual void close() = 0; |
|
74 |
|
75 /** |
|
76 * Changes state and emits stateChanged() |
|
77 */ |
|
78 virtual void changeState(PrivateState newState); |
|
79 |
|
80 protected: |
|
81 bool tickTimerRunning() const; |
|
82 void startTickTimer(); |
|
83 void stopTickTimer(); |
|
84 void maxVolumeChanged(int maxVolume); |
|
85 |
|
86 static qint64 toMilliSeconds(const TTimeIntervalMicroSeconds &); |
|
87 |
|
88 private: |
|
89 void doVolumeChanged(); |
|
90 |
|
91 private Q_SLOTS: |
|
92 /** |
|
93 * Receives signal from m_tickTimer |
|
94 */ |
|
95 void tick(); |
|
96 |
|
97 private: |
|
98 /** |
|
99 * This flag is set to true if play is called when the object is |
|
100 * in a Loading state. Once loading is complete, playback will |
|
101 * be started. |
|
102 */ |
|
103 bool m_playPending; |
|
104 |
|
105 QScopedPointer<QTimer> m_tickTimer; |
|
106 |
|
107 int m_mmfMaxVolume; |
|
108 |
|
109 MediaSource m_source; |
|
110 MediaSource m_nextSource; |
|
111 |
|
112 }; |
|
113 } |
|
114 } |
|
115 |
|
116 QT_END_NAMESPACE |
|
117 |
|
118 #endif |
|
119 |