• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdepimlibs API Reference
  • KDE Home
  • Contact Us
 

kabc

  • KABC
  • Sound
Public Member Functions | Friends | List of all members
KABC::Sound Class Reference

#include <sound.h>

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.

Definition at line 58 of file sound.h.

Constructor & Destructor Documentation

Sound::Sound ( )

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
urlA 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
dataThe 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.

Sound::~Sound ( )

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
otherThe object to compare with
Returns
true if the two objects are not equal, otherwise false

Definition at line 105 of file sound.cpp.

Sound & Sound::operator= ( const Sound &  other)

Assignment operator.

Parameters
otherThe sound object to assign to this

Definition at line 77 of file sound.cpp.

bool Sound::operator== ( const Sound &  other) const

Equality operator.

Parameters
otherThe 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
dataThe 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
urlThe 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:
  • sound.h
  • sound.cpp
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 23:01:06 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kabc

Skip menu "kabc"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • Related Pages

kdepimlibs API Reference

Skip menu "kdepimlibs API Reference"
  • akonadi
  •   contact
  •   kmime
  •   socialutils
  • kabc
  • kalarmcal
  • kblog
  • kcal
  • kcalcore
  • kcalutils
  • kholidays
  • kimap
  • kldap
  • kmbox
  • kmime
  • kpimidentities
  • kpimtextedit
  • kresources
  • ktnef
  • kxmlrpcclient
  • microblog

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal