mucke/lib/domain/actors/platform_integration_actor.dart

38 lines
1.1 KiB
Dart
Raw Normal View History

2021-02-26 22:07:18 +01:00
import '../repositories/platform_integration_repository.dart';
import '../usecases/pause.dart';
import '../usecases/play.dart';
2021-04-11 15:44:10 +02:00
import '../usecases/seek_to_next.dart';
import '../usecases/seek_to_previous.dart';
2021-02-26 22:07:18 +01:00
class PlatformIntegrationActor {
2021-04-11 15:44:10 +02:00
PlatformIntegrationActor(this._platformIntegrationInfoRepository, this._pause, this._play, this._seekToNext, this._seekToPrevious) {
2021-02-26 22:07:18 +01:00
_platformIntegrationInfoRepository.eventStream
.listen((event) => _handlePlatformIntegrationEvent(event));
}
final PlatformIntegrationInfoRepository _platformIntegrationInfoRepository;
final Pause _pause;
final Play _play;
2021-04-11 15:44:10 +02:00
final SeekToNext _seekToNext;
final SeekToPrevious _seekToPrevious;
2021-02-26 22:07:18 +01:00
void _handlePlatformIntegrationEvent(PlatformIntegrationEvent event) {
switch (event.type) {
case PlatformIntegrationEventType.play:
_play();
break;
case PlatformIntegrationEventType.pause:
_pause();
break;
2021-04-11 15:44:10 +02:00
case PlatformIntegrationEventType.skipNext:
_seekToNext();
break;
case PlatformIntegrationEventType.skipPrevious:
_seekToPrevious();
break;
2021-02-26 22:07:18 +01:00
default:
}
}
}