class Player
Audio player now can support mp3,amr and wav, if more types are needed, please add the decoder in function audio_player_create.
class audio.Player
Constructors
- class audio.Player([state_callback])
Create a Player, state_callback is a monitor of player state, when state changed, this callback will be invoked.
UIFLOW2:

Methods
- Player.play(uri, pos=0, volume=-1, sync=True, verify=None)
Play the audio file.
- Parameters:
uri (str) – The uri of the audio file. e.g. “file:///flash/test.mp3”, “file:///sd/test.mp3”, “https://dl.espressif.com/dl/audio/ff-16b-2c-44100hz.mp3”
pos (int) – The position to start playing, in byte.
volume (int) – The volume of the player, 0-100. -1 means the default volume.
sync (bool) – Whether to play synchronously.
verify (str) – ssl verify, default is None.
UIFLOW2:




- Player.play_raw(data, sample=16000, stereo=False, bits=16, pos=0, volume=-1, sync=True)
Play the raw audio data.
- Parameters:
data (bytes) – The raw audio data.
sample (int) – The sample rate of the audio data.
stereo (bool) – Whether the audio data is stereo.
bits (int) – The bits of the audio data.
pos (int) – The position to start playing, in byte.
volume (int) – The volume of the player, 0-100. -1 means the default volume.
sync (bool) – Whether to play synchronously.
UIFLOW2:

- Player.play_tone(freq, time, volume=-1, sync=True)
Play a tone.
- Parameters:
UIFLOW2:

- Player.pause()
Pause the player.
UIFLOW2:

- Player.resume()
Resume the player.
UIFLOW2:

- Player.stop()
Stop the player.
UIFLOW2:

- Player.pos()
Get the position of the player.
- Returns:
The position of the player.
UIFLOW2:

- Player.set_vol(volume)
Set the volume of the player.
- Parameters:
volume (int) – The volume of the player, 0-100.
UIFLOW2:

- Player.get_vol()
Get the volume of the player.
- Returns:
The volume of the player.
UIFLOW2:
