22 #include "kplayobject.h"
23 #include "kplayobject.moc"
24 #include "kplayobjectcreator.h"
27 KPlayObject::KPlayObject() : TQObject()
29 m_playObject = Arts::PlayObject::null();
33 KPlayObject::KPlayObject(Arts::PlayObject playobject,
bool isStream) : TQObject()
35 m_playObject = playobject;
36 m_isStream = isStream;
39 KPlayObject::~KPlayObject()
43 void KPlayObject::play()
48 void KPlayObject::seek(Arts::poTime newTime)
51 object().seek(newTime);
53 kdDebug( 400 ) <<
"Seeking in a Stream? huh?" <<
endl;
56 void KPlayObject::pause()
61 void KPlayObject::halt()
66 TQString KPlayObject::description()
68 return TQString::fromLatin1(
object().
description().c_str());
71 Arts::poTime KPlayObject::currentTime()
73 return object().currentTime();
76 Arts::poTime KPlayObject::overallTime()
78 return object().overallTime();
81 Arts::poCapabilities KPlayObject::capabilities()
83 return object().capabilities();
86 TQString KPlayObject::mediaName()
88 return TQString::fromLatin1(
object().mediaName().c_str());
91 Arts::poState KPlayObject::state()
93 return object().state();
96 Arts::PlayObject KPlayObject::object()
101 bool KPlayObject::isNull()
105 return object().isNull();
108 void KPlayObject::setObject(Arts::PlayObject playObject)
110 m_playObject = playObject;
113 bool KPlayObject::stream()
118 struct KDE::PlayObject::PrivateData
120 PrivateData() : creator( 0 ),
122 internalState( Arts::posIdle ) {}
126 Arts::SoundServerV2 server;
127 KDE::PlayObjectCreator* creator;
130 Arts::poState internalState;
134 KDE::PlayObject::PlayObject() : TQObject()
136 m_playObject = Arts::PlayObject::null();
141 KDE::PlayObject::PlayObject(Arts::PlayObject playobject,
bool isStream) : TQObject()
143 m_playObject = playobject;
144 m_isStream = isStream;
153 KDE::PlayObject::PlayObject( Arts::SoundServerV2 server,
const KURL& url,
bool isStream,
bool createBUS ) : TQObject()
155 kdDebug( 400 ) <<
"KDE::PlayObject: created as proxy for URL " << url.
url()<<
endl;
157 m_playObject = Arts::PlayObject::null();
158 m_isStream = isStream;
162 d->createBUS = createBUS;
166 KDE::PlayObject::~PlayObject()
168 kdDebug( 400 ) <<
"KDE::PlayObject: destroyed" <<
endl;
175 kdDebug( 400 ) <<
"KDE::PlayObject::play()" <<
endl;
177 if (
object().isNull() ) {
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;
191 void KDE::PlayObject::attachPlayObject( Arts::PlayObject playObject )
193 kdDebug( 400 ) <<
"KDE::PlayObject::attachPlayObject()" <<
endl;
195 m_playObject = playObject;
196 emit playObjectCreated();
197 if (
object().isNull() )
199 switch ( d->internalState ) {
203 case Arts::posPaused:
206 case Arts::posPlaying:
214 if (
object().isNull() )
217 object().seek(newTime);
219 kdDebug( 400 ) <<
"Seeking in a Stream? huh?" <<
endl;
224 if ( !
object().isNull() )
226 d->internalState = Arts::posPaused;
231 kdDebug( 400 ) <<
"KDE::PlayObject::halt()" <<
endl;
232 if ( !
object().isNull() )
234 else if ( d->creator ) {
237 kdDebug( 400 ) <<
"KDE::PlayObject::halt(): creator destroyed" <<
endl;
239 d->internalState = Arts::posIdle;
244 if (
object().isNull() )
246 return TQString::fromLatin1(
object().description().c_str());
251 if (
object().isNull() )
252 return Arts::poTime( 0, 0, -1,
"" );
253 return object().currentTime();
258 if (
object().isNull() )
259 return Arts::poTime( 0, 0, -1,
"" );
260 return object().overallTime();
265 if (
object().isNull() )
266 return static_cast<Arts::poCapabilities
>( 0 );
267 return object().capabilities();
272 if (
object().isNull() )
274 return TQString::fromLatin1(
object().mediaName().c_str());
279 if (
object().isNull() )
280 return d->internalState;
281 return object().state();
295 return object().isNull();
void halt()
immediately stops the play back and resets the media to the start of the content.
TQString description()
Reimplemented (Arts::PlayObject Wrapper)
bool isNull()
return true if this != 0.
TQString mediaName()
Reimplemented (Arts::PlayObject Wrapper)
void pause()
causes the PlayObject to pause play back immediately.
Arts::PlayObject object()
Returns the internal Arts::PlayObject.
void play()
causes the PlayObject to start the play back.
Arts::poTime overallTime()
Reimplemented (Arts::PlayObject Wrapper)
bool stream()
returns "true" if the content to play is delivered as a stream.
void seek(Arts::poTime newTime)
causes the PlayObject to skip to the time newTime.
Arts::poState state()
returns the internal state of the PlayObject.
Arts::poTime currentTime()
Reimplemented (Arts::PlayObject Wrapper)
Arts::poCapabilities capabilities()
returns the capabilities of the PlayObject.
TQString url(int _trailing=0, int encoding_hint=0) const
kndbgstream & endl(kndbgstream &s)
kdbgstream kdDebug(int area=0)
TQString description(StdAccel id)