2021-02-26 22:07:18 +01:00
|
|
|
import '../entities/song.dart';
|
|
|
|
import '../repositories/audio_player_repository.dart';
|
2021-04-18 13:46:16 +02:00
|
|
|
import '../repositories/music_data_repository.dart';
|
2021-02-26 22:07:18 +01:00
|
|
|
import '../usecases/handle_playback_state.dart';
|
|
|
|
import '../usecases/set_current_song.dart';
|
|
|
|
|
|
|
|
class AudioPlayerActor {
|
2021-04-18 13:46:16 +02:00
|
|
|
AudioPlayerActor(this._audioPlayerRepository, this._musicDataInfoRepository, this._handlePlaybackEvent, this._setCurrentSong) {
|
|
|
|
_audioPlayerRepository.currentSongStream.listen(_handleCurrentSong);
|
|
|
|
_audioPlayerRepository.playbackEventStream.listen(_handlePlaybackEvent);
|
|
|
|
|
|
|
|
_musicDataInfoRepository.songUpdateStream.listen(_handleSongUpdate);
|
2021-02-26 22:07:18 +01:00
|
|
|
}
|
|
|
|
|
2021-04-18 13:46:16 +02:00
|
|
|
// TODO: is this against a previous design choice? only direct "read" access to repos?
|
|
|
|
final AudioPlayerRepository _audioPlayerRepository;
|
|
|
|
final MusicDataInfoRepository _musicDataInfoRepository;
|
2021-02-26 22:07:18 +01:00
|
|
|
|
|
|
|
final HandlePlaybackEvent _handlePlaybackEvent;
|
|
|
|
final SetCurrentSong _setCurrentSong;
|
|
|
|
|
|
|
|
void _handleCurrentSong(Song song) => _setCurrentSong(song);
|
2021-04-18 13:46:16 +02:00
|
|
|
|
|
|
|
void _handleSongUpdate(Map<String, Song> songs) {
|
|
|
|
_audioPlayerRepository.updateSongs(songs);
|
|
|
|
}
|
2021-02-26 22:07:18 +01:00
|
|
|
}
|