TDEABC::Sound Class Reference
#include <sound.h>
Public Member Functions | |
Sound () | |
Sound (const TQString &url) | |
Sound (const TQByteArray &data) | |
~Sound () | |
bool | operator== (const Sound &) const |
bool | operator!= (const Sound &) const |
void | setUrl (const TQString &url) |
bool | isEmpty () const |
void | setData (const TQByteArray &data) |
bool | isIntern () const |
TQString | url () const |
TQByteArray | data () const |
TQString | asString () const |
Friends | |
KABC_EXPORT TQDataStream & | operator<< (TQDataStream &, const Sound &) |
KABC_EXPORT TQDataStream & | operator>> (TQDataStream &, Sound &) |
Detailed Description
Class that holds a Sound clip for a contact.
The sound can be played doing something like this:
KTempFile tmp;
if(sound.isIntern()) {
tmp.file()->tqwriteBlock( sound.data() );
tmp.close();
KAudioPlayer::play( tmp.name() );
} else if(!sound.url().isEmpty()) {
TQString tmpFile;
if(!TDEIO::NetAccess::download(KURL(themeURL.url()), tmpFile, NULL))
{
TDEIO::NetAccess::lastErrorString(),
i18n("Failed to download sound file"),
);
return;
}
KAudioPlayer::play( tmpFile );
}
Unfortunetly KAudioPlayer::play is ASync, so to delete the temporary file, the best you can really do is set a timer.
Constructor & Destructor Documentation
Sound::Sound | ( | const TQString & | url | ) |
Sound::Sound | ( | const TQByteArray & | data | ) |
Member Function Documentation
TQString Sound::asString | ( | ) | const |
TQByteArray Sound::data | ( | ) | const |
bool Sound::isEmpty | ( | ) | const |
bool Sound::isIntern | ( | ) | const |
void Sound::setData | ( | const TQByteArray & | data | ) |
Sets the raw data of the sound.
When using this function, isIntern() will return 'true' until you use setUrl().
- Parameters
-
data The raw data of the sound.
void Sound::setUrl | ( | const TQString & | url | ) |
Sets a URL for the location of the sound file.
When using this function, isIntern() will return 'false' until you use setData().
- Parameters
-
url The location URL of the sound file.
TQString Sound::url | ( | ) | const |
The documentation for this class was generated from the following files: