blob: be896daf76906ad04af843f1b2d01fcadf8f2c86 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
import 'dart:async';
import 'package:flutter_ics_homescreen/export.dart';
class MediaPlayerPositionNotifier extends Notifier<Duration> {
Timer? positionTimer;
@override
Duration build() {
return Duration.zero;
}
void set(Duration position) {
state = position;
}
void play() {
positionTimer ??=
Timer.periodic(const Duration(milliseconds: 250), (timer) {
state = state + const Duration(milliseconds: 250);
});
}
void pause() {
if (positionTimer != null) {
positionTimer!.cancel();
positionTimer = null;
}
}
}
|