startOrStopPlayer method
dynamic
startOrStopPlayer({})
start of stop player
Implementation
startOrStopPlayer(
{required String filePath,
required String fileName,
required Codec codec}) async {
_currentPlayingPath = filePath;
Directory tempDir = await getTemporaryDirectory();
String localPath = '${tempDir.path}/$fileName';
File localFile = File(localPath);
debugPrint(
'startOrStopPlayer $_currentPlayingPath local_exists ${localFile.existsSync()}');
if (!localFile.existsSync()) {
_isDownloading = true;
notifyListeners();
await dio.download(_currentPlayingPath!, localPath);
_isDownloading = false;
notifyListeners();
}
if (localFile.existsSync()) {
debugPrint(
'startOrStopPlayer $_currentPlayingPath download to $localPath');
if (_player.isStopped) {
startPlayer(path: localPath, codec: codec);
} else {
stopPlayer();
}
}
}