play method

Future play()

Implementation

Future play() async {
  if (_current!.type == MediaType.video) {
    return _videoPlayerController!.position.then((value) {
      if (value! >= _videoPlayerController!.value.duration) {
        _videoPlayerController!.seekTo(const Duration(milliseconds: 0));
      }
      _videoPlayerController!.play().then((value) => notifyListeners());
    });
  } else if (_current!.type == MediaType.audio) {
    if (_audioPlayer!.state == audio_player.PlayerState.paused) {
      return _audioPlayer!.resume();
    }
    return _audioPlayer!
        .play(audio_player.UrlSource(_current!.url!))
        .then((value) => notifyListeners());
  }
  return Future.value(_media);
}