GSound.Context¶
- Subclasses:
None
Methods¶
- Inherited:
- Structs:
class |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Virtual Methods¶
- Inherited:
Properties¶
None
Signals¶
- Inherited:
Fields¶
- Inherited:
Class Details¶
- class GSound.Context(**kwargs)¶
- Bases:
- Abstract:
No
- Structure:
ca: the wrapped context Wrapper for ca_context.
- classmethod new(cancellable)¶
- Parameters:
cancellable (
Gio.Cancellable
orNone
) – AGio.Cancellable
, orNone
- Raises:
- Returns:
A new
GSound.Context
- Return type:
Creates and initializes a new
GSound.Context
. If the an error occured during initialization,None
is returned and error will be set appropriately.
- cache(attrs)¶
- Parameters:
- Raises:
- Return type:
Requests that a sound be cached on the server. See ‘#caching [gsound-GSound-Context#caching]’.
This function is intented to be used by language bindings.
- open()¶
- Raises:
- Returns:
True
if the output device was opened successfully, orFalse
(populating error)- Return type:
Attempts to open a connection to the backend sound driver. It is recommended that you set context attributes with
GSound.Context.set_attributes
() before calling this function.A connection is automatically opened before playing or caching sounds, so you rarely need to call this yourself.
- play_full(attrs, cancellable, callback, *user_data)¶
- Parameters:
cancellable (
Gio.Cancellable
orNone
) – AGio.Cancellable
, orNone
callback (
Gio.AsyncReadyCallback
orNone
) – callback
Asynchronously request a sound to be played. When playback is finished (or if an error occurs) then callback will be called, following the normal GIO async pattern.
If playback is cancelled via cancellable, then callback will be called with
Gio.IOErrorEnum.CANCELLED
.If you do not need notification of when playback is complete, you should use
GSound.Context.play_simple
().This function is intented to be used by language bindings.
- play_full_finish(result)¶
- Parameters:
result (
Gio.AsyncResult
) – Result object passed to the callback ofGSound.Context.play_full
()- Raises:
- Returns:
True
if playing finished successfully- Return type:
Finish an async operation started by
GSound.Context.play_full
(). You must call this function in the callback to free memory and receive any errors which occurred.
- play_simple(attrs, cancellable)¶
- Parameters:
cancellable (
Gio.Cancellable
orNone
) – AGio.Cancellable
- Raises:
- Returns:
- Return type:
The basic “fire-and-forget” play command. This function will not block, and just sends a request to the sound server before immediately returning.
If you need to know when a sound finishes playing then you should call
GSound.Context.play_full
() instead.You can cancel playback at any time by calling
Gio.Cancellable.cancel
() on cancellable, if supplied.This function is intented to be used by language bindings.
- set_attributes(attrs)¶
- Parameters:
- Raises:
- Returns:
True
if attributes were updated successfully- Return type:
Set attributes or change attributes on self. Subsequent calls to this function calling the same attributes will override the earlier values.
Note that GSound will set the
GSound.ATTR_APPLICATION_NAME
andGSound.ATTR_APPLICATION_ID
for you if usingGio.Application
, so you do not normally need to set these yourself.This function is intented to be used by language bindings.
- set_driver(driver)¶
- Parameters:
driver (
str
) – libcanberra driver to use- Raises:
- Returns:
True
if the libcanberra driver was set successfully- Return type:
Sets the libcanberra driver to driver, for example “pulse”, “alsa” or “null”. You normally do not need to set this yourself.
Note that this function may return
True
even if the specified driver is not available: see the libcanberra documentation for details.