feat(player): add sleep timer

This commit is contained in:
zarzet
2026-08-30 17:23:16 +07:00
parent a926a2825b
commit 29a86b0dc3
5 changed files with 164 additions and 0 deletions
+6
View File
@@ -69,6 +69,8 @@ class MusicPlayerController {
bool get isAvailable => _handler != null;
DateTime? get sleepTimerEndsAt => _handler?.sleepTimerEndsAt;
Future<MusicPlayerHandler?> ensureInitialized() async {
try {
return await initMusicPlayer();
@@ -118,6 +120,10 @@ class MusicPlayerController {
Future<void> next() async => _handler?.skipToNext();
Future<void> previous() async => _handler?.skipToPrevious();
void setSleepTimer(Duration duration) => _handler?.setSleepTimer(duration);
void cancelSleepTimer() => _handler?.cancelSleepTimer();
Future<void> togglePlayPause(bool isPlaying) async {
final handler = _handler;
if (handler == null) return;