play method

Future<bool?> play(
  1. String url
)

播放远端视频

Implementation

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