startNextVideoTimer method
void
startNextVideoTimer()
Start timer which will trigger next video. Used in playlist. Do not use manually.
Implementation
void startNextVideoTimer() {
if (_nextVideoTimer == null) {
if (betterPlayerPlaylistConfiguration == null) {
BetterPlayerUtils.log(
"BettterPlayerPlaylistConifugration has not been set!");
throw StateError(
"BettterPlayerPlaylistConifugration has not been set!");
}
_nextVideoTime =
betterPlayerPlaylistConfiguration!.nextVideoDelay.inSeconds;
_nextVideoTimeStreamController.add(_nextVideoTime);
if (_nextVideoTime == 0) {
return;
}
_nextVideoTimer =
Timer.periodic(const Duration(milliseconds: 1000), (_timer) async {
if (_nextVideoTime == 1) {
_timer.cancel();
_nextVideoTimer = null;
}
if (_nextVideoTime != null) {
_nextVideoTime = _nextVideoTime! - 1;
}
_nextVideoTimeStreamController.add(_nextVideoTime);
});
}
}