startPlayer method
Use this function to start the player to play/resume the audio.
When playing audio is finished player will be stopped and disposed
by default. To change this behavior use FinishMode enum.
See FinishMode documentation for more info.
Implementation
Future<void> startPlayer({FinishMode finishMode = FinishMode.stop}) async {
if (_playerState == PlayerState.initialized ||
_playerState == PlayerState.paused) {
final isStarted = await AudioWaveformsInterface.instance
.startPlayer(_playerKey.toString(), finishMode);
if (isStarted) {
setPlayerState(PlayerState.playing);
} else {
throw "Failed to start player";
}
}
notifyListeners();
}