KABC::Sound Class Reference
Class that holds a Sound clip for a contact. More...
#include <sound.h>
Public Member Functions | |
Sound () | |
Sound (const QString &url) | |
Sound (const QByteArray &data) | |
~Sound () | |
bool | operator== (const Sound &) const |
bool | operator!= (const Sound &) const |
void | setUrl (const QString &url) |
bool | isEmpty () const |
void | setData (const QByteArray &data) |
bool | isIntern () const |
QString | url () const |
QByteArray | data () const |
QString | asString () const |
Friends | |
KABC_EXPORT QDataStream & | operator<< (QDataStream &, const Sound &) |
KABC_EXPORT QDataStream & | operator>> (QDataStream &, 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()->writeBlock( sound.data() ); tmp.close(); KAudioPlayer::play( tmp.name() ); } else if(!sound.url().isEmpty()) { QString tmpFile; if(!KIO::NetAccess::download(KURL(themeURL.url()), tmpFile, NULL)) { KMessageBox::error(0L, KIO::NetAccess::lastErrorString(), i18n("Failed to download sound file"), KMessageBox::Notify ); 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.
Definition at line 59 of file sound.h.
Constructor & Destructor Documentation
Sound::Sound | ( | const QString & | url | ) |
Sound::Sound | ( | const QByteArray & | data | ) |
Member Function Documentation
QString Sound::asString | ( | ) | const |
QByteArray Sound::data | ( | ) | const |
bool Sound::isEmpty | ( | ) | const |
bool Sound::isIntern | ( | ) | const |
void Sound::setData | ( | const QByteArray & | 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 QString & | 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.
QString Sound::url | ( | ) | const |
The documentation for this class was generated from the following files: