22 #include <tdeio/kmimetype.h>
24 #include "kplayobjectcreator.h"
25 #include "kplayobjectcreator.moc"
26 #include "kioinputstream_impl.h"
32 KDE::PlayObjectCreator::PlayObjectCreator(Arts::SoundServerV2 server)
37 KDE::PlayObjectCreator::~PlayObjectCreator()
41 bool KDE::PlayObjectCreator::create(
const KURL& url,
bool createBUS,
const TQObject* receiver,
const char* slot)
44 if (m_server.isNull() || url.
isEmpty() )
47 connect(
this, TQ_SIGNAL( playObjectCreated( Arts::PlayObject ) ),
53 m_createBUS = createBUS;
56 Arts::TDEIOInputStream_impl* instream_impl =
new Arts::TDEIOInputStream_impl();
57 m_instream = Arts::TDEIOInputStream::_from_base(instream_impl);
60 connect(instream_impl, TQ_SIGNAL(mimeTypeFound(
const TQString &)),
61 this, TQ_SLOT(slotMimeType(
const TQString &)));
64 m_instream.openURL(url.
url().latin1());
65 m_instream.streamStart();
72 KMimeType::Ptr mimetype = KMimeType::findByURL(url);
73 emit playObjectCreated (
74 m_server.createPlayObjectForURL(std::string(TQFile::encodeName(url.
path())),
75 std::string(mimetype->name().latin1()),
81 void KDE::PlayObjectCreator::slotMimeType(
const TQString& mimetype)
84 kdDebug( 400 ) <<
"slotMimeType called: " << mimetype <<
endl;
86 TQString mimetype_copy = mimetype;
88 if ( mimetype_copy ==
"application/octet-stream" )
89 mimetype_copy = TQString(
"audio/x-mp3");
91 if (mimetype_copy ==
"application/x-zerosize")
92 emit playObjectCreated(Arts::PlayObject::null());
94 playObject = m_server.createPlayObjectForStream(
96 std::string( mimetype_copy.latin1() ),
98 if ( playObject.isNull() ) {
99 m_instream.streamEnd();
100 emit playObjectCreated( Arts::PlayObject::null() );
103 emit playObjectCreated( playObject );
TQString url(int _trailing=0, int encoding_hint=0) const
kndbgstream & endl(kndbgstream &s)
kdbgstream kdDebug(int area=0)