kabc
KABC::Sound Class Reference
#include <sound.h>
Public Types | |
typedef QList< Sound > | List |
Public Member Functions | |
Sound () | |
Sound (const QString &url) | |
Sound (const QByteArray &data) | |
Sound (const Sound &other) | |
~Sound () | |
QByteArray | data () const |
bool | isEmpty () const |
bool | isIntern () const |
bool | operator!= (const Sound &other) const |
Sound & | operator= (const Sound &other) |
bool | operator== (const Sound &other) const |
void | setData (const QByteArray &data) |
void | setUrl (const QString &url) |
QString | toString () const |
QString | url () const |
Friends | |
QDataStream & | operator<< (QDataStream &, const Sound &) |
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()->write( sound.data() );
tmp.close();
KAudioPlayer::play( tmp.name() );
} else if( !sound.url().isEmpty() ) {
QString tmpFile;
if ( !KIO::NetAccess::download( KUrl( themeURL.url() ), tmpFile, 0 ) ) {
KMessageBox::error( 0,
KIO::NetAccess::lastErrorString(),
i18n( "Failed to download sound file" ),
KMessageBox::Notify
);
return;
}
KAudioPlayer::play( tmpFile );
}
Unfortunately, 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 QString & | url | ) |
Sound::Sound | ( | const QByteArray & | data | ) |
Member Function Documentation
QByteArray Sound::data | ( | ) | const |
bool Sound::isEmpty | ( | ) | const |
bool Sound::isIntern | ( | ) | const |
bool Sound::operator!= | ( | const Sound & | other | ) | const |
bool Sound::operator== | ( | const Sound & | other | ) | 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::toString | ( | ) | const |
QString Sound::url | ( | ) | const |
Friends And Related Function Documentation
|
friend |
Serializes the sound
object into the stream
.
|
friend |
Initializes the sound
object from the stream
.
The documentation for this class was generated from the following files:
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:38:39 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:38:39 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.