playAssetFile method

Future<bool?> playAssetFile(
  1. String path
)

播放Assets里的视频

Implementation

Future<bool?> playAssetFile(String path) async {
  try {
    final filePath = await VideoDownloadManager.getInstance().getAssetsPathAfterData(path);
    if (mode == VideoPlayMode.onQueue) {
      _queue.add(VideoModel(filePath, VideoSource.asset));
      if (isPlaying == false) {
        playNext();
      }
    } else {
      Duration time = Duration.zero;
      if (isPlaying) {
        stop();
        time = const Duration(milliseconds: 200);
      }
      Future.delayed(time, () {
        if (disposed) {return;}
        _queue.add(VideoModel(filePath, VideoSource.asset));
        playNext();
      });
    }
        return true;
  } on PlatformException catch (e) {
    debugPrint('Failed to play url: ${e.message}');
    return false;
  }
}