|
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 #include "abstractplayer.h" |
|
20 #include "defs.h" |
|
21 #include "utils.h" |
|
22 |
|
23 QT_BEGIN_NAMESPACE |
|
24 |
|
25 using namespace Phonon; |
|
26 using namespace Phonon::MMF; |
|
27 |
|
28 /*! \class MMF::AbstractPlayer |
|
29 \internal |
|
30 */ |
|
31 |
|
32 //----------------------------------------------------------------------------- |
|
33 // Constructor / destructor |
|
34 //----------------------------------------------------------------------------- |
|
35 |
|
36 MMF::AbstractPlayer::AbstractPlayer() |
|
37 : m_videoOutput(0) |
|
38 , m_volume(InitialVolume) |
|
39 , m_state(GroundState) |
|
40 , m_error(NoError) |
|
41 , m_tickInterval(DefaultTickInterval) |
|
42 , m_transitionTime(0) |
|
43 , m_prefinishMark(0) |
|
44 { |
|
45 |
|
46 } |
|
47 |
|
48 MMF::AbstractPlayer::AbstractPlayer(const AbstractPlayer& player) |
|
49 : m_videoOutput(player.m_videoOutput) |
|
50 , m_volume(player.m_volume) |
|
51 , m_state(GroundState) |
|
52 , m_error(NoError) |
|
53 , m_tickInterval(player.tickInterval()) |
|
54 , m_transitionTime(player.transitionTime()) |
|
55 , m_prefinishMark(player.prefinishMark()) |
|
56 { |
|
57 |
|
58 } |
|
59 |
|
60 //----------------------------------------------------------------------------- |
|
61 // MediaObjectInterface |
|
62 //----------------------------------------------------------------------------- |
|
63 |
|
64 qint32 MMF::AbstractPlayer::tickInterval() const |
|
65 { |
|
66 return m_tickInterval; |
|
67 } |
|
68 |
|
69 void MMF::AbstractPlayer::setTickInterval(qint32 interval) |
|
70 { |
|
71 m_tickInterval = interval; |
|
72 doSetTickInterval(interval); |
|
73 } |
|
74 |
|
75 qint32 MMF::AbstractPlayer::prefinishMark() const |
|
76 { |
|
77 return m_prefinishMark; |
|
78 } |
|
79 |
|
80 void MMF::AbstractPlayer::setPrefinishMark(qint32 mark) |
|
81 { |
|
82 m_prefinishMark = mark; |
|
83 } |
|
84 |
|
85 qint32 MMF::AbstractPlayer::transitionTime() const |
|
86 { |
|
87 return m_transitionTime; |
|
88 } |
|
89 |
|
90 void MMF::AbstractPlayer::setTransitionTime(qint32 time) |
|
91 { |
|
92 m_transitionTime = time; |
|
93 } |
|
94 |
|
95 |
|
96 //----------------------------------------------------------------------------- |
|
97 // VolumeObserver |
|
98 //----------------------------------------------------------------------------- |
|
99 |
|
100 void MMF::AbstractPlayer::volumeChanged(qreal volume) |
|
101 { |
|
102 m_volume = volume; |
|
103 } |
|
104 |
|
105 |
|
106 //----------------------------------------------------------------------------- |
|
107 // Video output |
|
108 //----------------------------------------------------------------------------- |
|
109 |
|
110 void MMF::AbstractPlayer::setVideoOutput(VideoOutput* videoOutput) |
|
111 { |
|
112 m_videoOutput = videoOutput; |
|
113 videoOutputChanged(); |
|
114 } |
|
115 |
|
116 void MMF::AbstractPlayer::videoOutputChanged() |
|
117 { |
|
118 // Default behaviour is empty - overridden by VideoPlayer |
|
119 } |
|
120 |
|
121 void MMF::AbstractPlayer::setError(Phonon::ErrorType error) |
|
122 { |
|
123 TRACE_CONTEXT(AbstractPlayer::setError, EAudioInternal); |
|
124 TRACE_ENTRY("state %d error %d", m_state, error); |
|
125 |
|
126 m_error = error; |
|
127 changeState(ErrorState); |
|
128 |
|
129 TRACE_EXIT_0(); |
|
130 } |
|
131 |
|
132 Phonon::ErrorType MMF::AbstractPlayer::errorType() const |
|
133 { |
|
134 const Phonon::ErrorType result = (ErrorState == m_state) |
|
135 ? errorType() : NoError; |
|
136 return result; |
|
137 } |
|
138 |
|
139 QString MMF::AbstractPlayer::errorString() const |
|
140 { |
|
141 // TODO: put in proper error strings |
|
142 QString result; |
|
143 return result; |
|
144 } |
|
145 |
|
146 Phonon::State MMF::AbstractPlayer::phononState() const |
|
147 { |
|
148 return phononState(m_state); |
|
149 } |
|
150 |
|
151 Phonon::State MMF::AbstractPlayer::phononState(PrivateState state) |
|
152 { |
|
153 const Phonon::State phononState = |
|
154 GroundState == state |
|
155 ? Phonon::LoadingState |
|
156 : static_cast<Phonon::State>(state); |
|
157 |
|
158 return phononState; |
|
159 } |
|
160 |
|
161 AbstractPlayer::PrivateState AbstractPlayer::privateState() const |
|
162 { |
|
163 return m_state; |
|
164 } |
|
165 |
|
166 Phonon::State MMF::AbstractPlayer::state() const |
|
167 { |
|
168 return phononState(m_state); |
|
169 } |
|
170 |
|
171 void MMF::AbstractPlayer::setState(PrivateState newState) |
|
172 { |
|
173 m_state = newState; |
|
174 } |
|
175 |
|
176 QT_END_NAMESPACE |
|
177 |