Interface: IMediaInstance

IMediaInstance

Interface for single instance return by a Sound play call. This can either be a WebAudio or HTMLAudio instance.

Properties:
Name Type Description
id number

Auto-incrementing ID for the instance.

loop boolean

If the current instance is set to loop

muted boolean

Set the muted state of the instance

paused boolean

If the instance is paused, if the sound or global context is paused, this could still be false.

progress number

Current progress of the sound from 0 to 1

speed number

Current speed of the instance. This is not the actual speed since it takes into account the global context and the sound volume.

volume number

Current volume of the instance. This is not the actual volume since it takes into account the global context and the sound volume.

Members

id number readonly

Auto-incrementing ID for the instance.

loop boolean

If the current instance is set to loop

muted boolean

Set the muted state of the instance

paused boolean

If the instance is paused, if the sound or global context is paused, this could still be false.

progress number readonly

Current progress of the sound from 0 to 1

speed number

Current speed of the instance. This is not the actual speed since it takes into account the global context and the sound volume.

volume number

Current volume of the instance. This is not the actual volume since it takes into account the global context and the sound volume.

Methods

set (name, value) this

Fired when the sound when progress updates.

Name Type Description
name "speed" | "volume" | "muted" | "loop" | "paused"

Name of property.

value number | boolean

The total number of seconds of audio

Returns:
Type Description
this
Example
import { sound } from '@pixi/sound';
sound.play('foo')
  .set('volume', 0.5)
  .set('speed', 0.8);

stop () void

Stop the current instance from playing.

Events

end

Fired when the sound finishes playing.

pause

Fired when paused state changes.

Name Type Description
paused boolean

If the current state is paused

paused

Fired when instance is paused.

progress

Fired when the sound when progress updates.

Name Type Description
progress number

Playback progress from 0 to 1

duration number

The total number of seconds of audio

resumed

Fired when instance is resumed.

start

Fired when the sound starts playing.

stop

The sound is stopped. Don't use after this is called.