mirror of
https://github.com/stonega/tsacdop
synced 2025-02-13 10:00:49 +01:00
Minor change.
This commit is contained in:
parent
061fadbccc
commit
da684480b3
@ -547,6 +547,8 @@ class __PlaylistButtonState extends State<_PlaylistButton> {
|
|||||||
final s = context.s;
|
final s = context.s;
|
||||||
return Material(
|
return Material(
|
||||||
color: Colors.transparent,
|
color: Colors.transparent,
|
||||||
|
borderRadius: BorderRadius.circular(100),
|
||||||
|
clipBehavior: Clip.hardEdge,
|
||||||
child: MyPopupMenuButton<int>(
|
child: MyPopupMenuButton<int>(
|
||||||
shape: RoundedRectangleBorder(
|
shape: RoundedRectangleBorder(
|
||||||
borderRadius: BorderRadius.all(Radius.circular(10))),
|
borderRadius: BorderRadius.all(Radius.circular(10))),
|
||||||
|
@ -61,21 +61,22 @@ enum PlayerHeight { short, mid, tall }
|
|||||||
|
|
||||||
class AudioPlayerNotifier extends ChangeNotifier {
|
class AudioPlayerNotifier extends ChangeNotifier {
|
||||||
DBHelper dbHelper = DBHelper();
|
DBHelper dbHelper = DBHelper();
|
||||||
var positionStorage = KeyValueStorage(audioPositionKey);
|
final _positionStorage = KeyValueStorage(audioPositionKey);
|
||||||
var autoPlayStorage = KeyValueStorage(autoPlayKey);
|
final _autoPlayStorage = KeyValueStorage(autoPlayKey);
|
||||||
var autoSleepTimerStorage = KeyValueStorage(autoSleepTimerKey);
|
final _autoSleepTimerStorage = KeyValueStorage(autoSleepTimerKey);
|
||||||
var defaultSleepTimerStorage = KeyValueStorage(defaultSleepTimerKey);
|
final _defaultSleepTimerStorage = KeyValueStorage(defaultSleepTimerKey);
|
||||||
var autoSleepTimerModeStorage = KeyValueStorage(autoSleepTimerModeKey);
|
final _autoSleepTimerModeStorage = KeyValueStorage(autoSleepTimerModeKey);
|
||||||
var autoSleepTimerStartStorage = KeyValueStorage(autoSleepTimerStartKey);
|
final _autoSleepTimerStartStorage = KeyValueStorage(autoSleepTimerStartKey);
|
||||||
var autoSleepTimerEndStorage = KeyValueStorage(autoSleepTimerEndKey);
|
final _autoSleepTimerEndStorage = KeyValueStorage(autoSleepTimerEndKey);
|
||||||
var fastForwardSecondsStorage = KeyValueStorage(fastForwardSecondsKey);
|
final _fastForwardSecondsStorage = KeyValueStorage(fastForwardSecondsKey);
|
||||||
var rewindSecondsStorage = KeyValueStorage(rewindSecondsKey);
|
final _rewindSecondsStorage = KeyValueStorage(rewindSecondsKey);
|
||||||
var playerHeightStorage = KeyValueStorage(playerHeightKey);
|
final _playerHeightStorage = KeyValueStorage(playerHeightKey);
|
||||||
var speedStorage = KeyValueStorage(speedKey);
|
final _speedStorage = KeyValueStorage(speedKey);
|
||||||
var skipSilenceStorage = KeyValueStorage(skipSilenceKey);
|
final _skipSilenceStorage = KeyValueStorage(skipSilenceKey);
|
||||||
var boostVolumeStorage = KeyValueStorage(boostVolumeKey);
|
final _boostVolumeStorage = KeyValueStorage(boostVolumeKey);
|
||||||
var volumeGainStorage = KeyValueStorage(volumeGainKey);
|
final _volumeGainStorage = KeyValueStorage(volumeGainKey);
|
||||||
var markListenedAfterSkipStorage = KeyValueStorage(markListenedAfterSkipKey);
|
final _markListenedAfterSkipStorage =
|
||||||
|
KeyValueStorage(markListenedAfterSkipKey);
|
||||||
|
|
||||||
/// Current playing episdoe.
|
/// Current playing episdoe.
|
||||||
EpisodeBrief _episode;
|
EpisodeBrief _episode;
|
||||||
@ -218,29 +219,29 @@ class AudioPlayerNotifier extends ChangeNotifier {
|
|||||||
setBoostVolume(boostVolume: _boostVolume, gain: _volumeGain);
|
setBoostVolume(boostVolume: _boostVolume, gain: _volumeGain);
|
||||||
}
|
}
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
volumeGainStorage.saveInt(volumeGain);
|
_volumeGainStorage.saveInt(volumeGain);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _initAudioData() async {
|
Future<void> _initAudioData() async {
|
||||||
var index = await playerHeightStorage.getInt(defaultValue: 0);
|
var index = await _playerHeightStorage.getInt(defaultValue: 0);
|
||||||
_playerHeight = PlayerHeight.values[index];
|
_playerHeight = PlayerHeight.values[index];
|
||||||
_currentSpeed = await speedStorage.getDoubel(defaultValue: 1.0);
|
_currentSpeed = await _speedStorage.getDoubel(defaultValue: 1.0);
|
||||||
_skipSilence = await skipSilenceStorage.getBool(defaultValue: false);
|
_skipSilence = await _skipSilenceStorage.getBool(defaultValue: false);
|
||||||
_boostVolume = await boostVolumeStorage.getBool(defaultValue: false);
|
_boostVolume = await _boostVolumeStorage.getBool(defaultValue: false);
|
||||||
_volumeGain = await volumeGainStorage.getInt(defaultValue: 3000);
|
_volumeGain = await _volumeGainStorage.getInt(defaultValue: 3000);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future _savePlayerHeight() async {
|
Future _savePlayerHeight() async {
|
||||||
await playerHeightStorage.saveInt(_playerHeight.index);
|
await _playerHeightStorage.saveInt(_playerHeight.index);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future _getAutoPlay() async {
|
Future _getAutoPlay() async {
|
||||||
var i = await autoPlayStorage.getInt();
|
var i = await _autoPlayStorage.getInt();
|
||||||
_autoPlay = i == 0;
|
_autoPlay = i == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future _getAutoSleepTimer() async {
|
Future _getAutoSleepTimer() async {
|
||||||
var i = await autoSleepTimerStorage.getInt();
|
var i = await _autoSleepTimerStorage.getInt();
|
||||||
_autoSleepTimer = i == 1;
|
_autoSleepTimer = i == 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -262,7 +263,7 @@ class AudioPlayerNotifier extends ChangeNotifier {
|
|||||||
_queue = Playlist();
|
_queue = Playlist();
|
||||||
await _queue.getPlaylist();
|
await _queue.getPlaylist();
|
||||||
await _getAutoPlay();
|
await _getAutoPlay();
|
||||||
_lastPostion = await positionStorage.getInt();
|
_lastPostion = await _positionStorage.getInt();
|
||||||
if (_lastPostion > 0 && _queue.playlist.length > 0) {
|
if (_lastPostion > 0 && _queue.playlist.length > 0) {
|
||||||
final episode = _queue.playlist.first;
|
final episode = _queue.playlist.first;
|
||||||
final duration = episode.duration * 1000;
|
final duration = episode.duration * 1000;
|
||||||
@ -332,11 +333,12 @@ class AudioPlayerNotifier extends ChangeNotifier {
|
|||||||
|
|
||||||
/// Get fastword and rewind seconds.
|
/// Get fastword and rewind seconds.
|
||||||
_fastForwardSeconds =
|
_fastForwardSeconds =
|
||||||
await fastForwardSecondsStorage.getInt(defaultValue: 30);
|
await _fastForwardSecondsStorage.getInt(defaultValue: 30);
|
||||||
_rewindSeconds = await rewindSecondsStorage.getInt(defaultValue: 10);
|
_rewindSeconds = await _rewindSecondsStorage.getInt(defaultValue: 10);
|
||||||
|
|
||||||
/// Get if auto mark listened after skip
|
/// Get if auto mark listened after skip
|
||||||
_markListened = await skipSilenceStorage.getBool(defaultValue: false);
|
_markListened =
|
||||||
|
await _markListenedAfterSkipStorage.getBool(defaultValue: false);
|
||||||
|
|
||||||
/// Start audio service.
|
/// Start audio service.
|
||||||
await AudioService.start(
|
await AudioService.start(
|
||||||
@ -362,17 +364,17 @@ class AudioPlayerNotifier extends ChangeNotifier {
|
|||||||
await _getAutoSleepTimer();
|
await _getAutoSleepTimer();
|
||||||
if (_autoSleepTimer) {
|
if (_autoSleepTimer) {
|
||||||
var startTime =
|
var startTime =
|
||||||
await autoSleepTimerStartStorage.getInt(defaultValue: 1380);
|
await _autoSleepTimerStartStorage.getInt(defaultValue: 1380);
|
||||||
var endTime = await autoSleepTimerEndStorage.getInt(defaultValue: 360);
|
var endTime = await _autoSleepTimerEndStorage.getInt(defaultValue: 360);
|
||||||
var currentTime = DateTime.now().hour * 60 + DateTime.now().minute;
|
var currentTime = DateTime.now().hour * 60 + DateTime.now().minute;
|
||||||
if ((startTime > endTime &&
|
if ((startTime > endTime &&
|
||||||
(currentTime > startTime || currentTime < endTime)) ||
|
(currentTime > startTime || currentTime < endTime)) ||
|
||||||
((startTime < endTime) &&
|
((startTime < endTime) &&
|
||||||
(currentTime > startTime && currentTime < endTime))) {
|
(currentTime > startTime && currentTime < endTime))) {
|
||||||
var mode = await autoSleepTimerModeStorage.getInt();
|
var mode = await _autoSleepTimerModeStorage.getInt();
|
||||||
_sleepTimerMode = SleepTimerMode.values[mode];
|
_sleepTimerMode = SleepTimerMode.values[mode];
|
||||||
var defaultTimer =
|
var defaultTimer =
|
||||||
await defaultSleepTimerStorage.getInt(defaultValue: 30);
|
await _defaultSleepTimerStorage.getInt(defaultValue: 30);
|
||||||
sleepTimer(defaultTimer);
|
sleepTimer(defaultTimer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -449,7 +451,7 @@ class AudioPlayerNotifier extends ChangeNotifier {
|
|||||||
_queue.delFromPlaylist(_episode);
|
_queue.delFromPlaylist(_episode);
|
||||||
_lastPostion = 0;
|
_lastPostion = 0;
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
await positionStorage.saveInt(_lastPostion);
|
await _positionStorage.saveInt(_lastPostion);
|
||||||
var history;
|
var history;
|
||||||
if (_markListened) {
|
if (_markListened) {
|
||||||
history = PlayHistory(_episode.title, _episode.enclosureUrl, 0, 1);
|
history = PlayHistory(_episode.title, _episode.enclosureUrl, 0, 1);
|
||||||
@ -498,7 +500,7 @@ class AudioPlayerNotifier extends ChangeNotifier {
|
|||||||
if (_backgroundAudioPosition > 0 &&
|
if (_backgroundAudioPosition > 0 &&
|
||||||
_backgroundAudioPosition < _backgroundAudioDuration) {
|
_backgroundAudioPosition < _backgroundAudioDuration) {
|
||||||
_lastPostion = _backgroundAudioPosition;
|
_lastPostion = _backgroundAudioPosition;
|
||||||
positionStorage.saveInt(_lastPostion);
|
_positionStorage.saveInt(_lastPostion);
|
||||||
}
|
}
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
}
|
}
|
||||||
@ -576,7 +578,7 @@ class AudioPlayerNotifier extends ChangeNotifier {
|
|||||||
var index = await _queue.delFromPlaylist(episodeNew);
|
var index = await _queue.delFromPlaylist(episodeNew);
|
||||||
if (index == 0) {
|
if (index == 0) {
|
||||||
_lastPostion = 0;
|
_lastPostion = 0;
|
||||||
await positionStorage.saveInt(0);
|
await _positionStorage.saveInt(0);
|
||||||
}
|
}
|
||||||
_queueUpdate = !_queueUpdate;
|
_queueUpdate = !_queueUpdate;
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
@ -592,7 +594,7 @@ class AudioPlayerNotifier extends ChangeNotifier {
|
|||||||
await _queue.addToPlayListAt(episode, newIndex);
|
await _queue.addToPlayListAt(episode, newIndex);
|
||||||
if (newIndex == 0) {
|
if (newIndex == 0) {
|
||||||
_lastPostion = 0;
|
_lastPostion = 0;
|
||||||
await positionStorage.saveInt(0);
|
await _positionStorage.saveInt(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -604,7 +606,7 @@ class AudioPlayerNotifier extends ChangeNotifier {
|
|||||||
} else {
|
} else {
|
||||||
await _queue.addToPlayListAt(episode, 0, existed: false);
|
await _queue.addToPlayListAt(episode, 0, existed: false);
|
||||||
_lastPostion = 0;
|
_lastPostion = 0;
|
||||||
positionStorage.saveInt(_lastPostion);
|
_positionStorage.saveInt(_lastPostion);
|
||||||
}
|
}
|
||||||
_queueUpdate = !_queueUpdate;
|
_queueUpdate = !_queueUpdate;
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
@ -658,14 +660,14 @@ class AudioPlayerNotifier extends ChangeNotifier {
|
|||||||
Future<void> setSpeed(double speed) async {
|
Future<void> setSpeed(double speed) async {
|
||||||
await AudioService.customAction('setSpeed', speed);
|
await AudioService.customAction('setSpeed', speed);
|
||||||
_currentSpeed = speed;
|
_currentSpeed = speed;
|
||||||
await speedStorage.saveDouble(_currentSpeed);
|
await _speedStorage.saveDouble(_currentSpeed);
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> setSkipSilence({@required bool skipSilence}) async {
|
Future<void> setSkipSilence({@required bool skipSilence}) async {
|
||||||
await AudioService.customAction('setSkipSilence', skipSilence);
|
await AudioService.customAction('setSkipSilence', skipSilence);
|
||||||
_skipSilence = skipSilence;
|
_skipSilence = skipSilence;
|
||||||
await skipSilenceStorage.saveBool(_skipSilence);
|
await _skipSilenceStorage.saveBool(_skipSilence);
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -674,7 +676,7 @@ class AudioPlayerNotifier extends ChangeNotifier {
|
|||||||
'setBoostVolume', [boostVolume, _volumeGain]);
|
'setBoostVolume', [boostVolume, _volumeGain]);
|
||||||
_boostVolume = boostVolume;
|
_boostVolume = boostVolume;
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
await boostVolumeStorage.saveBool(boostVolume);
|
await _boostVolumeStorage.saveBool(boostVolume);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Set sleep timer
|
//Set sleep timer
|
||||||
|
Loading…
x
Reference in New Issue
Block a user