|
Wt
3.3.8
|
A value class to play a sound effect. More...
#include <Wt/WSound>

Public Member Functions | |
| WSound (WObject *parent=0) | |
| Constructs a sound object. More... | |
| WSound (const std::string &url, WObject *parent=0) | |
| Constructs a sound object for an MP3 media source. More... | |
| WSound (WMediaPlayer::Encoding encoding, const WLink &link, WObject *parent=0) | |
| Constructs a sound object. More... | |
| ~WSound () | |
| Destructor. More... | |
| void | addSource (WMediaPlayer::Encoding encoding, const WLink &link) |
| Adds a media source. More... | |
| std::string | url () const |
| Returns the media source (deprecated). More... | |
| WLink | getSource (WMediaPlayer::Encoding encoding) const |
| Returns the media source. More... | |
| void | setLoops (int number) |
| Sets the amount of times the sound has to be repeated. More... | |
| int | loops () const |
| Returns the configured number of repeats. More... | |
| void | play () |
| Start asynchronous playback of the sound. More... | |
| void | stop () |
| Stops playback of the sound. More... | |
Public Member Functions inherited from Wt::WObject | |
| WObject (WObject *parent=0) | |
| Create a WObject with a given parent object. More... | |
| virtual | ~WObject () |
| Destructor. More... | |
| virtual const std::string | id () const |
| Returns the (unique) identifier for this object. More... | |
| virtual void | setObjectName (const std::string &name) |
| Sets an object name. More... | |
| virtual std::string | objectName () const |
| Returns the object name. More... | |
| void | resetLearnedSlots () |
| Resets learned stateless slot implementations. More... | |
| template<class T > | |
| void | resetLearnedSlot (void(T::*method)()) |
| Resets a learned stateless slot implementation. More... | |
| template<class T > | |
| WStatelessSlot * | implementStateless (void(T::*method)()) |
| Declares a slot to be stateless and learn client-side behaviour on first invocation. More... | |
| template<class T > | |
| WStatelessSlot * | implementStateless (void(T::*method)(), void(T::*undoMethod)()) |
| Declares a slot to be stateless and learn client-side behaviour in advance. More... | |
| void | isNotStateless () |
| Marks the current function as not stateless. More... | |
| template<class T > | |
| WStatelessSlot * | implementJavaScript (void(T::*method)(), const std::string &jsCode) |
| Provides a JavaScript implementation for a method. More... | |
| void | addChild (WObject *child) |
| Adds a child object. More... | |
| virtual void | removeChild (WObject *child) |
| Removes a child object. More... | |
| const std::vector< WObject * > & | children () const |
| Returns the children. | |
| WObject * | parent () const |
| Returns the parent object. | |
Additional Inherited Members | |
Public Types inherited from Wt::WObject | |
| typedef void(WObject::* | Method) () |
| Typedef for a WObject method without arguments. | |
Protected Member Functions inherited from Wt::WObject | |
| virtual WStatelessSlot * | getStateless (Method method) |
| On-demand stateless slot implementation. More... | |
Static Protected Member Functions inherited from Wt::WObject | |
| static WObject * | sender () |
| Returns the sender of the current slot call. More... | |
A value class to play a sound effect.
This class provides a way to play an MP3 sound asynchonously (if the browser supports this). It is intended as a simple way to play event sounds (not quite for a media center).
This class uses a WMediaPlayer to play the sound (using HTML <audio> or a flash player).
Usage example:
| Wt::WSound::WSound | ( | WObject * | parent = 0 | ) |
Constructs a sound object.
| Wt::WSound::WSound | ( | const std::string & | url, |
| WObject * | parent = 0 |
||
| ) |
Constructs a sound object for an MP3 media source.
The url will be assumed to be an MP3 file.
| Wt::WSound::WSound | ( | WMediaPlayer::Encoding | encoding, |
| const WLink & | link, | ||
| WObject * | parent = 0 |
||
| ) |
Constructs a sound object.
| Wt::WSound::~WSound | ( | ) |
Destructor.
Deleting a sound also stops it (if it was playing).
| void Wt::WSound::addSource | ( | WMediaPlayer::Encoding | encoding, |
| const WLink & | link | ||
| ) |
Adds a media source.
You may add multiple media sources (with different encodings) to allow the file to be played in more browsers without needing Flash plugins.
| WLink Wt::WSound::getSource | ( | WMediaPlayer::Encoding | encoding | ) | const |
Returns the media source.
This returns the link set for a specific encoding, or an empty link if no URL was set for that encoding.
| int Wt::WSound::loops | ( | ) | const |
Returns the configured number of repeats.
| void Wt::WSound::play | ( | ) |
Start asynchronous playback of the sound.
This method returns immediately. It will cause the sound to be played for the configured amount of loops().
The behavior of play() when a sound is already playing is undefind: it may be intermixed, sequentially queued, or a current playing sound may be stopped. It is recommended to call stop() before play() if you want to avoid mixing multiple instances of a single WSound object.
| void Wt::WSound::setLoops | ( | int | number | ) |
Sets the amount of times the sound has to be repeated.
A call to play() will play the sound number of times. The default value is 1 (no repeats).
| void Wt::WSound::stop | ( | ) |
Stops playback of the sound.
This method returns immediately. It causes the current playback (if any) of the sound to be stopped.
| std::string Wt::WSound::url | ( | ) | const |
Returns the media source (deprecated).
1.8.11