Back

Player

Player is an audio file player with start, loop, and stop functions.

You can an instance of the music object when you need it like this:

 player = music.CreatePlayer(path, options)


Example


function OnStart()
{
  music = app.CreateMusic()
  music.CreatePlayer( "/Docs/Music/Snd/gong.mp3", "AutoPlay")
}

  Copy   Copy All    Run   


Methods:

 player.Play(time, offset, duration)

Play the buffer at the given startTime. Optionally add an offset and/or duration which will play the buffer from a position within the buffer for the given duration.


 player.Stop(time)

Stop the source at the specified time. If no time is given, stop the source now.


 player.Restart(time, offset, duration)

Stop the source at the specified time. If no time is given, stop the source now.


 player.Seek(offset, when)

Seek to a specific time in the player's buffer. If the source is no longer playing at that time, it will stop.


 player.Connect(...nodes)

Connect the output of this node to the rest of the nodes in series.


 player.GetName()

Return player name.


 player.Dispose()

Clean up.


 player._player

Return Tone.Player class from Tonejs


File path can be /sdcard/folder/song.mp3 or can be Snd/song.mp3
AutoPlay, Loop
Time can be described in a number of ways. Read more true or false
music.Gain, music.Phaser or other Tonejs effects.