• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • arts
 

arts

  • arts
  • kde
kplayobject.cpp
1 /*
2
3 Copyright (C) 2001 Nikolas Zimmermann <wildfox@kde.org>
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
14
15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
19
20 */
21
22#include "kplayobject.h"
23#include "kplayobject.moc"
24#include "kplayobjectcreator.h"
25#include <kdebug.h>
26
27KPlayObject::KPlayObject() : TQObject()
28{
29 m_playObject = Arts::PlayObject::null();
30 m_isStream = false;
31}
32
33KPlayObject::KPlayObject(Arts::PlayObject playobject, bool isStream) : TQObject()
34{
35 m_playObject = playobject;
36 m_isStream = isStream;
37}
38
39KPlayObject::~KPlayObject()
40{
41}
42
43void KPlayObject::play()
44{
45 object().play();
46}
47
48void KPlayObject::seek(Arts::poTime newTime)
49{
50 if(!m_isStream)
51 object().seek(newTime);
52 else
53 kdDebug( 400 ) << "Seeking in a Stream? huh?" << endl;
54}
55
56void KPlayObject::pause()
57{
58 object().pause();
59}
60
61void KPlayObject::halt()
62{
63 object().halt();
64}
65
66TQString KPlayObject::description()
67{
68 return TQString::fromLatin1(object().description().c_str());
69}
70
71Arts::poTime KPlayObject::currentTime()
72{
73 return object().currentTime();
74}
75
76Arts::poTime KPlayObject::overallTime()
77{
78 return object().overallTime();
79}
80
81Arts::poCapabilities KPlayObject::capabilities()
82{
83 return object().capabilities();
84}
85
86TQString KPlayObject::mediaName()
87{
88 return TQString::fromLatin1(object().mediaName().c_str());
89}
90
91Arts::poState KPlayObject::state()
92{
93 return object().state();
94}
95
96Arts::PlayObject KPlayObject::object()
97{
98 return m_playObject;
99}
100
101bool KPlayObject::isNull()
102{
103 if( !this )
104 return true;
105 return object().isNull();
106}
107
108void KPlayObject::setObject(Arts::PlayObject playObject)
109{
110 m_playObject = playObject;
111}
112
113bool KPlayObject::stream()
114{
115 return m_isStream;
116}
117
118struct KDE::PlayObject::PrivateData
119{
120 PrivateData() : creator( 0 ),
121 isProxy( false ),
122 internalState( Arts::posIdle ) {}
123 ~PrivateData() {
124 delete creator;
125 }
126 Arts::SoundServerV2 server;
127 KDE::PlayObjectCreator* creator;
128 bool createBUS;
129 bool isProxy;
130 Arts::poState internalState;
131 KURL url;
132};
133
134KDE::PlayObject::PlayObject() : TQObject()
135{
136 m_playObject = Arts::PlayObject::null();
137 m_isStream = false;
138 d = new PrivateData;
139}
140
141KDE::PlayObject::PlayObject(Arts::PlayObject playobject, bool isStream) : TQObject()
142{
143 m_playObject = playobject;
144 m_isStream = isStream;
145 d = new PrivateData;
146
147 //very funny! you can't connect to signals before creating
148 //the object - so nobody will ever receive this signal (mkretz)
149 //
150 //emit playObjectCreated();
151}
152
153KDE::PlayObject::PlayObject( Arts::SoundServerV2 server, const KURL& url, bool isStream, bool createBUS ) : TQObject()
154{
155 kdDebug( 400 ) << "KDE::PlayObject: created as proxy for URL " << url.url()<< endl;
156
157 m_playObject = Arts::PlayObject::null();
158 m_isStream = isStream;
159 d = new PrivateData;
160 d->server = server;
161 d->url = url;
162 d->createBUS = createBUS;
163 d->isProxy = true;
164}
165
166KDE::PlayObject::~PlayObject()
167{
168 kdDebug( 400 ) << "KDE::PlayObject: destroyed" << endl;
169
170 delete d;
171}
172
173void KDE::PlayObject::play()
174{
175 kdDebug( 400 ) << "KDE::PlayObject::play()" << endl;
176
177 if ( object().isNull() ) {
178 if ( m_isStream ) {
179 if ( d->creator )
180 delete d->creator;
181 d->creator = new KDE::PlayObjectCreator( d->server );
182 d->creator->create( d->url, d->createBUS, this, TQ_SLOT( attachPlayObject( Arts::PlayObject ) ) );
183 kdDebug( 400 ) << "KDE::PlayObject::play(): creator called" << endl;
184 d->internalState = Arts::posPlaying;
185 }
186 return;
187 }
188 object().play();
189}
190
191void KDE::PlayObject::attachPlayObject( Arts::PlayObject playObject )
192{
193 kdDebug( 400 ) << "KDE::PlayObject::attachPlayObject()" << endl;
194
195 m_playObject = playObject;
196 emit playObjectCreated();
197 if ( object().isNull() )
198 return;
199 switch ( d->internalState ) {
200 case Arts::posIdle:
201 object().halt();
202 break;
203 case Arts::posPaused:
204 object().pause();
205 break;
206 case Arts::posPlaying:
207 object().play ();
208 break;
209 }
210}
211
212void KDE::PlayObject::seek(Arts::poTime newTime)
213{
214 if ( object().isNull() )
215 return;
216 if(!m_isStream)
217 object().seek(newTime);
218 else
219 kdDebug( 400 ) << "Seeking in a Stream? huh?" << endl;
220}
221
222void KDE::PlayObject::pause()
223{
224 if ( !object().isNull() )
225 object().pause();
226 d->internalState = Arts::posPaused;
227}
228
229void KDE::PlayObject::halt()
230{
231 kdDebug( 400 ) << "KDE::PlayObject::halt()" << endl;
232 if ( !object().isNull() )
233 object().halt();
234 else if ( d->creator ) {
235 delete d->creator;
236 d->creator = 0;
237 kdDebug( 400 ) << "KDE::PlayObject::halt(): creator destroyed" << endl;
238 }
239 d->internalState = Arts::posIdle;
240}
241
242TQString KDE::PlayObject::description()
243{
244 if ( object().isNull() )
245 return TQString();
246 return TQString::fromLatin1(object().description().c_str());
247}
248
249Arts::poTime KDE::PlayObject::currentTime()
250{
251 if ( object().isNull() )
252 return Arts::poTime( 0, 0, -1, "" );
253 return object().currentTime();
254}
255
256Arts::poTime KDE::PlayObject::overallTime()
257{
258 if ( object().isNull() )
259 return Arts::poTime( 0, 0, -1, "" );
260 return object().overallTime();
261}
262
263Arts::poCapabilities KDE::PlayObject::capabilities()
264{
265 if ( object().isNull() )
266 return static_cast<Arts::poCapabilities>( 0 );
267 return object().capabilities();
268}
269
270TQString KDE::PlayObject::mediaName()
271{
272 if ( object().isNull() )
273 return TQString();
274 return TQString::fromLatin1(object().mediaName().c_str());
275}
276
277Arts::poState KDE::PlayObject::state()
278{
279 if ( object().isNull() )
280 return d->internalState;
281 return object().state();
282}
283
284Arts::PlayObject KDE::PlayObject::object()
285{
286 return m_playObject;
287}
288
289bool KDE::PlayObject::isNull()
290{
291 if ( !this )
292 return true;
293 if ( d->isProxy )
294 return false;
295 return object().isNull();
296}
297
298bool KDE::PlayObject::stream()
299{
300 return m_isStream;
301}
KDE::PlayObject::halt
void halt()
immediately stops the play back and resets the media to the start of the content.
Definition: kplayobject.cpp:229
KDE::PlayObject::description
TQString description()
Reimplemented (Arts::PlayObject Wrapper)
Definition: kplayobject.cpp:242
KDE::PlayObject::isNull
bool isNull()
return true if this != 0.
Definition: kplayobject.cpp:289
KDE::PlayObject::mediaName
TQString mediaName()
Reimplemented (Arts::PlayObject Wrapper)
Definition: kplayobject.cpp:270
KDE::PlayObject::pause
void pause()
causes the PlayObject to pause play back immediately.
Definition: kplayobject.cpp:222
KDE::PlayObject::object
Arts::PlayObject object()
Returns the internal Arts::PlayObject.
Definition: kplayobject.cpp:284
KDE::PlayObject::play
void play()
causes the PlayObject to start the play back.
Definition: kplayobject.cpp:173
KDE::PlayObject::overallTime
Arts::poTime overallTime()
Reimplemented (Arts::PlayObject Wrapper)
Definition: kplayobject.cpp:256
KDE::PlayObject::stream
bool stream()
returns "true" if the content to play is delivered as a stream.
Definition: kplayobject.cpp:298
KDE::PlayObject::seek
void seek(Arts::poTime newTime)
causes the PlayObject to skip to the time newTime.
Definition: kplayobject.cpp:212
KDE::PlayObject::state
Arts::poState state()
returns the internal state of the PlayObject.
Definition: kplayobject.cpp:277
KDE::PlayObject::currentTime
Arts::poTime currentTime()
Reimplemented (Arts::PlayObject Wrapper)
Definition: kplayobject.cpp:249
KDE::PlayObject::capabilities
Arts::poCapabilities capabilities()
returns the capabilities of the PlayObject.
Definition: kplayobject.cpp:263
KURL
KURL::url
TQString url(int _trailing=0, int encoding_hint=0) const
endl
kndbgstream & endl(kndbgstream &s)
kdDebug
kdbgstream kdDebug(int area=0)
TDEStdAccel::description
TQString description(StdAccel id)

arts

Skip menu "arts"
  • Main Page
  • Alphabetical List
  • Class List
  • File List
  • Class Members
  • Related Pages

arts

Skip menu "arts"
  • arts
  • dcop
  • dnssd
  • interfaces
  •   kspeech
  •     interface
  •     library
  •   tdetexteditor
  • kate
  • kded
  • kdoctools
  • kimgio
  • kjs
  • libtdemid
  • libtdescreensaver
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdeioslave
  •   http
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for arts by doxygen 1.9.4
This website is maintained by Timothy Pearson.