play method

Future play()

Implementation

Future play() async {
  try {
    playStatus = PlayStatus.downloading;
    _updateUi();
    if (isFile) {
      final path = await _getFileFromCache();
      await startPlaying(path);
      onPlaying();
    } else {
      downloadStreamSubscription = _getFileFromCacheWithProgress()
          .listen((FileResponse fileResponse) async {
        if (fileResponse is FileInfo) {
          await startPlaying(fileResponse.file.path);
          onPlaying();
        } else if (fileResponse is DownloadProgress) {
          _updateUi();
          // print(downloadProgress);
          downloadProgress = fileResponse.progress;
        }
      });
    }
  } catch (err) {
    playStatus = PlayStatus.downloadError;
    _updateUi();
    if (onError != null) {
      onError!(err);
    } else {
      rethrow;
    }
  }
}