KABC::Sound Class Reference
Class that holds a Sound clip for a contact.
More...
#include <sound.h>
List of all members.
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.
Definition at line 58 of file sound.h.
Constructor & Destructor Documentation
Creates an empty sound object.
Definition at line 50 of file sound.cpp.
Sound::Sound |
( |
const QString & |
url |
) |
|
Creates a sound object for the given url.
- Parameters:
-
| url | A url that describes the position of the sound file. |
Definition at line 55 of file sound.cpp.
Sound::Sound |
( |
const QByteArray & |
data |
) |
|
Creates a sound object for the given data.
- Parameters:
-
| data | The raw data of the sound. |
Definition at line 61 of file sound.cpp.
Sound::Sound |
( |
const Sound & |
other |
) |
|
Copy constructor.
Definition at line 68 of file sound.cpp.
Destroys the sound object.
Definition at line 73 of file sound.cpp.
Member Function Documentation
QByteArray Sound::data |
( |
|
) |
const |
Returns the raw data of this sound.
Definition at line 138 of file sound.cpp.
bool Sound::isEmpty |
( |
|
) |
const |
Returns true, if the sound object is empty.
Definition at line 127 of file sound.cpp.
bool Sound::isIntern |
( |
|
) |
const |
Returns whether the sound is described by a URL (extern) or by the raw data (intern).
When this method returns 'true' you can use data() to get the raw data. Otherwise you can request the URL of this sound by url() and load the raw data from that location.
Definition at line 122 of file sound.cpp.
bool Sound::operator!= |
( |
const Sound & |
other |
) |
const |
Not-Equal operator.
- Parameters:
-
| other | The object to compare with |
- Returns:
true
if the two objects are not equal, otherwise false
Definition at line 105 of file sound.cpp.
Assignment operator.
- Parameters:
-
| other | The sound object to assign to this |
Definition at line 77 of file sound.cpp.
bool Sound::operator== |
( |
const Sound & |
other |
) |
const |
Equality operator.
- Parameters:
-
| other | The object to compare with |
- Returns:
true
if the two objects are equal, otherwise false
Definition at line 86 of file sound.cpp.
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. |
Definition at line 116 of file sound.cpp.
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. |
Definition at line 110 of file sound.cpp.
QString Sound::toString |
( |
|
) |
const |
Returns string representation of the sound.
Definition at line 143 of file sound.cpp.
QString Sound::url |
( |
|
) |
const |
Returns the location URL of this sound.
Definition at line 133 of file sound.cpp.
Friends And Related Function Documentation
QDataStream& operator<< |
( |
QDataStream & |
, |
|
|
const Sound & |
| |
|
) |
| | [friend] |
Serializes the sound
object into the stream
.
QDataStream& operator>> |
( |
QDataStream & |
, |
|
|
Sound & |
| |
|
) |
| | [friend] |
Initializes the sound
object from the stream
.
The documentation for this class was generated from the following files: