startPlayer method
A function to start the player to play/resume the audio.
When playing audio is finished, this player will be stopped
and disposed by default. To change this behavior use setFinishMode method.
Implementation
Future<void> startPlayer({
bool forceRefresh = true,
}) async {
if (_playerState == PlayerState.initialized ||
_playerState == PlayerState.paused) {
final isStarted =
await AudioWaveformsInterface.instance.startPlayer(playerKey);
if (isStarted) {
_setPlayerState(PlayerState.playing);
} else {
throw "Failed to start player";
}
}
_setRefresh(forceRefresh);
notifyListeners();
}