-
-
Notifications
You must be signed in to change notification settings - Fork 2
ink sound
Pixi’VN allows you to use in the ink syntax the possibility to use the Sounds and Music.
The syntax is as follows:
#
+ [operation]
+ sound
+ [alias]
+ [parameters]
Where:
-
#
: It is a special character used by ink syntax for use a special script. -
[operation]
It is the operation that you want to do with the sound element. The available operations areadd
,play
,pause
,resume
,remove
andvolume
. -
[alias]
It is the alias of the sound element. The alias is a string that identifies the sound element.- If the alias includes spaces, you must use double quotes.
-
[parameters]
It is the parameters of the operation. The parameters depend on the operation.- If the parameters include spaces, you must use double quotes.
- If the parameters is a object, you must use the JSON format and the first character must be
\{
and the last character must be\}
. Example:\{ "volume": 100, name: "Music" \}
( This method is not recommended is recommended, to initialize the asset matrix at project start. )
To add a sound in ink, you can use the add
operation.
This operation requires one parameter, the URL or path of the sound.
After the alias of the the URL or path of the sound, you can add the SoundOptions
parameters. These parameters do not have a precise order and must be set as follows: parameterName
+ SPACE
+ value
. If the value
is a string you must use double quotes.
# sound add bird /bird.mp3
# sound add "bird 2" /bird2.mp3 volume 100
To play a sound in ink, you can use the play
operation.
After the alias of the sound element, you can add the SoundPlayOptions
parameters. These parameters do not have a precise order and must be set as follows: parameterName
+ SPACE
+ value
. If the value
is a string you must use double quotes.
:::tabs == start.ink
# play sound bird
Now the bird is singing.
# play sound bird volume 100
Now the bird is singing louder.
== assets-utility.ts
import { sound } from "@drincs/pixi-vn";
export async function defineAssets() {
sound.add('bird', 'https://pixijs.io/sound/examples/resources/bird.mp3');
}
:::
To pause a sound in ink, you can use the pause
operation.
# pause sound bird
To resume a sound in ink, you can use the resume
operation.
# resume sound bird
To remove a sound in ink, you can use the remove
operation.
# remove sound bird
To change the volume of a sound in ink, you can use the volume
operation.
This operation requires one parameter, the volume of the sound.
# volume sound bird 100