AudioPlayer constructor
AudioPlayer({
- String? playerId,
Creates a new instance and assigns an unique id to it.
Implementation
AudioPlayer({String? playerId}) : playerId = playerId ?? _uuid.v4() {
_onLogStreamSubscription = onLog.listen(
(log) => AudioLogger.log('$log\nSource: $_source'),
onError: (Object e, [StackTrace? stackTrace]) => AudioLogger.error(
AudioPlayerException(this, cause: e),
stackTrace,
),
);
_onPlayerCompleteStreamSubscription = onPlayerComplete.listen(
(_) {
state = PlayerState.completed;
if (releaseMode == ReleaseMode.release) {
_source = null;
}
},
onError: (Object _, [StackTrace? __]) {
/* Errors are already handled via log stream */
},
);
_create();
}