31 namespace Phonon |
31 namespace Phonon |
32 { |
32 { |
33 namespace MMF |
33 namespace MMF |
34 { |
34 { |
35 class AudioOutput; |
35 class AudioOutput; |
|
36 class MediaObject; |
36 |
37 |
37 /** |
38 /** |
38 * Interface via which MMF client APIs for both audio and video can be |
39 * Interface via which MMF client APIs for both audio and video can be |
39 * accessed. |
40 * accessed. |
40 */ |
41 */ |
41 class AbstractMediaPlayer : public AbstractPlayer |
42 class AbstractMediaPlayer : public AbstractPlayer |
42 { |
43 { |
43 Q_OBJECT |
44 Q_OBJECT |
44 |
45 |
45 protected: |
46 protected: |
46 AbstractMediaPlayer(); |
47 AbstractMediaPlayer(MediaObject *parent, const AbstractPlayer *player); |
47 explicit AbstractMediaPlayer(const AbstractPlayer& player); |
|
48 |
48 |
49 public: |
49 public: |
|
50 virtual void open(const Phonon::MediaSource&, RFile&); |
|
51 |
50 // MediaObjectInterface |
52 // MediaObjectInterface |
51 virtual void play(); |
53 virtual void play(); |
52 virtual void pause(); |
54 virtual void pause(); |
53 virtual void stop(); |
55 virtual void stop(); |
54 virtual void seek(qint64 milliseconds); |
56 virtual void seek(qint64 milliseconds); |
55 virtual bool isSeekable() const; |
57 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 virtual void volumeChanged(qreal volume); |
58 virtual void volumeChanged(qreal volume); |
60 |
59 |
61 protected: |
60 protected: |
62 // AbstractPlayer |
61 // AbstractPlayer |
63 virtual void doSetTickInterval(qint32 interval); |
62 virtual void doSetTickInterval(qint32 interval); |
66 virtual void doPause() = 0; |
65 virtual void doPause() = 0; |
67 virtual void doStop() = 0; |
66 virtual void doStop() = 0; |
68 virtual void doSeek(qint64 pos) = 0; |
67 virtual void doSeek(qint64 pos) = 0; |
69 virtual int setDeviceVolume(int mmfVolume) = 0; |
68 virtual int setDeviceVolume(int mmfVolume) = 0; |
70 virtual int openFile(RFile& file) = 0; |
69 virtual int openFile(RFile& file) = 0; |
|
70 virtual int openUrl(const QString& url) = 0; |
|
71 virtual int bufferStatus() const = 0; |
71 virtual void close() = 0; |
72 virtual void close() = 0; |
72 virtual void changeState(PrivateState newState); |
73 virtual void changeState(PrivateState newState); |
73 |
74 |
74 void updateMetaData(); |
75 void updateMetaData(); |
75 virtual int numberOfMetaDataEntries() const = 0; |
76 virtual int numberOfMetaDataEntries() const = 0; |
76 virtual QPair<QString, QString> metaDataEntry(int index) const = 0; |
77 virtual QPair<QString, QString> metaDataEntry(int index) const = 0; |
77 |
78 |
78 protected: |
79 protected: |
79 bool tickTimerRunning() const; |
80 void bufferingStarted(); |
80 void startTickTimer(); |
81 void bufferingComplete(); |
81 void stopTickTimer(); |
|
82 void maxVolumeChanged(int maxVolume); |
82 void maxVolumeChanged(int maxVolume); |
|
83 void playbackComplete(int error); |
83 |
84 |
84 static qint64 toMilliSeconds(const TTimeIntervalMicroSeconds &); |
85 static qint64 toMilliSeconds(const TTimeIntervalMicroSeconds &); |
85 |
86 |
86 private: |
87 private: |
|
88 void startPositionTimer(); |
|
89 void stopPositionTimer(); |
|
90 void startBufferStatusTimer(); |
|
91 void stopBufferStatusTimer(); |
|
92 void stopTimers(); |
87 void doVolumeChanged(); |
93 void doVolumeChanged(); |
|
94 void emitMarksIfReached(); |
|
95 void resetMarksIfRewound(); |
88 |
96 |
89 private Q_SLOTS: |
97 private Q_SLOTS: |
90 /** |
98 void positionTick(); |
91 * Receives signal from m_tickTimer |
99 void bufferStatusTick(); |
92 */ |
|
93 void tick(); |
|
94 |
100 |
95 private: |
101 private: |
|
102 MediaObject *const m_parent; |
|
103 |
96 /** |
104 /** |
97 * This flag is set to true if play is called when the object is |
105 * This flag is set to true if play is called when the object is |
98 * in a Loading state. Once loading is complete, playback will |
106 * in a Loading state. Once loading is complete, playback will |
99 * be started. |
107 * be started. |
100 */ |
108 */ |
101 bool m_playPending; |
109 bool m_playPending; |
102 |
110 |
103 QScopedPointer<QTimer> m_tickTimer; |
111 QScopedPointer<QTimer> m_positionTimer; |
|
112 |
|
113 QScopedPointer<QTimer> m_bufferStatusTimer; |
|
114 PrivateState m_stateBeforeBuffering; |
104 |
115 |
105 int m_mmfMaxVolume; |
116 int m_mmfMaxVolume; |
106 |
117 |
107 MediaSource m_source; |
118 bool m_prefinishMarkSent; |
108 MediaSource m_nextSource; |
119 bool m_aboutToFinishSent; |
109 |
120 |
110 QMultiMap<QString, QString> m_metaData; |
121 QMultiMap<QString, QString> m_metaData; |
111 |
122 |
112 }; |
123 }; |
113 } |
124 } |