1 /**************************************************************************** |
|
2 ** |
|
3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
4 ** All rights reserved. |
|
5 ** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 ** |
|
7 ** This file is part of the Qt Mobility Components. |
|
8 ** |
|
9 ** $QT_BEGIN_LICENSE:LGPL$ |
|
10 ** No Commercial Usage |
|
11 ** This file contains pre-release code and may not be distributed. |
|
12 ** You may use this file in accordance with the terms and conditions |
|
13 ** contained in the Technology Preview License Agreement accompanying |
|
14 ** this package. |
|
15 ** |
|
16 ** GNU Lesser General Public License Usage |
|
17 ** Alternatively, this file may be used under the terms of the GNU Lesser |
|
18 ** General Public License version 2.1 as published by the Free Software |
|
19 ** Foundation and appearing in the file LICENSE.LGPL included in the |
|
20 ** packaging of this file. Please review the following information to |
|
21 ** ensure the GNU Lesser General Public License version 2.1 requirements |
|
22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
23 ** |
|
24 ** In addition, as a special exception, Nokia gives you certain additional |
|
25 ** rights. These rights are described in the Nokia Qt LGPL Exception |
|
26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
27 ** |
|
28 ** If you have questions regarding the use of this file, please contact |
|
29 ** Nokia at qt-info@nokia.com. |
|
30 ** |
|
31 ** |
|
32 ** |
|
33 ** |
|
34 ** |
|
35 ** |
|
36 ** |
|
37 ** |
|
38 ** $QT_END_LICENSE$ |
|
39 ** |
|
40 ****************************************************************************/ |
|
41 |
|
42 #ifndef S60MEDIAPLAYERSESSION_H |
|
43 #define S60MEDIAPLAYERSESSION_H |
|
44 |
|
45 #include <QtCore/qobject.h> |
|
46 #include <QtCore/qurl.h> |
|
47 #include <QtCore/qpair.h> |
|
48 #include <QMediaPlayer> |
|
49 #include <e32cmn.h> // for TDesC |
|
50 #include "s60mediaplayerservice.h" |
|
51 |
|
52 QTM_BEGIN_NAMESPACE |
|
53 class QMediaTimeRange; |
|
54 QTM_END_NAMESPACE |
|
55 |
|
56 QTM_USE_NAMESPACE |
|
57 |
|
58 class QTimer; |
|
59 |
|
60 class S60MediaPlayerSession : public QObject |
|
61 { |
|
62 Q_OBJECT |
|
63 |
|
64 public: |
|
65 S60MediaPlayerSession(QObject *parent); |
|
66 virtual ~S60MediaPlayerSession(); |
|
67 |
|
68 // for player control interface to use |
|
69 QMediaPlayer::State state() const; |
|
70 QMediaPlayer::MediaStatus mediaStatus() const; |
|
71 qint64 duration() const; |
|
72 qint64 position() const; |
|
73 void setPosition(qint64 pos); |
|
74 int volume() const; |
|
75 void setVolume(int volume); |
|
76 bool isMuted() const; |
|
77 void setMuted(bool muted); |
|
78 virtual bool isVideoAvailable() const = 0; |
|
79 virtual bool isAudioAvailable() const = 0; |
|
80 bool isSeekable() const; |
|
81 void play(); |
|
82 void pause(); |
|
83 void stop(); |
|
84 |
|
85 bool isMetadataAvailable() const; |
|
86 QVariant metaData(const QString &key) const; |
|
87 QMap<QString, QVariant> availableMetaData() const; |
|
88 |
|
89 void load(const QUrl &url); |
|
90 void loadUrl(const QUrl &url); |
|
91 |
|
92 int mediaLoadingProgress(); |
|
93 |
|
94 bool mediaFileLocal() const; |
|
95 void setMediaFileLocal(bool localMediaFile); |
|
96 |
|
97 virtual void setVideoRenderer(QObject *renderer); |
|
98 |
|
99 void setMediaStatus(QMediaPlayer::MediaStatus); |
|
100 void setState(QMediaPlayer::State state); |
|
101 |
|
102 protected: |
|
103 virtual void doLoadL(const TDesC &path) = 0; |
|
104 virtual void doLoadUrlL(const TDesC &path) = 0; |
|
105 virtual void doPlay() = 0; |
|
106 virtual void doStop() = 0; |
|
107 virtual void doPauseL() = 0; |
|
108 virtual void doSetVolumeL(int volume) = 0; |
|
109 virtual void doSetPositionL(qint64 microSeconds) = 0; |
|
110 virtual qint64 doGetPositionL() const = 0; |
|
111 virtual void updateMetaDataEntriesL() = 0; |
|
112 virtual int doGetMediaLoadingProgressL() const = 0; |
|
113 virtual int doGetDurationL() const = 0; |
|
114 |
|
115 protected: |
|
116 |
|
117 void setError(int error, const QString &errorString = QString()); |
|
118 void initComplete(); |
|
119 void playComplete(); |
|
120 QMap<QString, QVariant>& metaDataEntries(); |
|
121 QMediaPlayer::Error fromSymbianErrorToMultimediaError(int error); |
|
122 |
|
123 protected slots: |
|
124 void tick(); |
|
125 |
|
126 signals: |
|
127 void durationChanged(qint64 duration); |
|
128 void positionChanged(qint64 position); |
|
129 void stateChanged(QMediaPlayer::State state); |
|
130 void mediaStatusChanged(QMediaPlayer::MediaStatus mediaStatus); |
|
131 void videoAvailableChanged(bool videoAvailable); |
|
132 void bufferStatusChanged(int percentFilled); |
|
133 void seekableChanged(bool); |
|
134 void availablePlaybackRangesChanged(const QMediaTimeRange&); |
|
135 void metaDataChanged(); |
|
136 void error(int error, const QString &errorString); |
|
137 |
|
138 private: |
|
139 qreal m_playbackRate; |
|
140 QMap<QString, QVariant> m_metaDataMap; |
|
141 bool m_muted; |
|
142 int m_volume; |
|
143 QMediaPlayer::State m_state; |
|
144 QMediaPlayer::MediaStatus m_mediaStatus; |
|
145 QTimer *m_timer; |
|
146 int m_error; |
|
147 bool m_localMediaFile; |
|
148 bool m_play_requested; |
|
149 }; |
|
150 |
|
151 #endif |
|