initAndPlay method

Future initAndPlay()

Implementation

Future initAndPlay() async {
  _playStatus = PlayStatus.downloading;
  _updateUi();
  try {
    if (kIsWeb) {
      await _setMaxDurationForJs();
      await startPlayingForJs();
    } else {
      final path = await _getFileFromCache();
      await _setMaxDurationForIo(path);
      await _startPlayingForIo(path);
    }
    if (onPlaying != null) {
      onPlaying!(id);
    }
  } catch (err) {
    _playStatus = PlayStatus.downloadError;
    _updateUi();
    rethrow;
  }
  _updateUi();
}