Support boost volume.
This commit is contained in:
parent
058e97a8f2
commit
28c7222d06
|
@ -87,6 +87,7 @@ class MessageLookup extends MessageLookupByLibrary {
|
||||||
"all" : MessageLookupByLibrary.simpleMessage("All"),
|
"all" : MessageLookupByLibrary.simpleMessage("All"),
|
||||||
"autoDownload" : MessageLookupByLibrary.simpleMessage("Auto download"),
|
"autoDownload" : MessageLookupByLibrary.simpleMessage("Auto download"),
|
||||||
"back" : MessageLookupByLibrary.simpleMessage("Back"),
|
"back" : MessageLookupByLibrary.simpleMessage("Back"),
|
||||||
|
"boostVolume" : MessageLookupByLibrary.simpleMessage("Boost volume"),
|
||||||
"buffering" : MessageLookupByLibrary.simpleMessage("Buffering"),
|
"buffering" : MessageLookupByLibrary.simpleMessage("Buffering"),
|
||||||
"cancel" : MessageLookupByLibrary.simpleMessage("CANCEL"),
|
"cancel" : MessageLookupByLibrary.simpleMessage("CANCEL"),
|
||||||
"cellularConfirm" : MessageLookupByLibrary.simpleMessage("Cellular data warning"),
|
"cellularConfirm" : MessageLookupByLibrary.simpleMessage("Cellular data warning"),
|
||||||
|
|
|
@ -87,6 +87,7 @@ class MessageLookup extends MessageLookupByLibrary {
|
||||||
"all" : MessageLookupByLibrary.simpleMessage("Todos"),
|
"all" : MessageLookupByLibrary.simpleMessage("Todos"),
|
||||||
"autoDownload" : MessageLookupByLibrary.simpleMessage("Auto-descargar"),
|
"autoDownload" : MessageLookupByLibrary.simpleMessage("Auto-descargar"),
|
||||||
"back" : MessageLookupByLibrary.simpleMessage("Atras"),
|
"back" : MessageLookupByLibrary.simpleMessage("Atras"),
|
||||||
|
"boostVolume" : MessageLookupByLibrary.simpleMessage("Boost volume"),
|
||||||
"buffering" : MessageLookupByLibrary.simpleMessage("Cargando "),
|
"buffering" : MessageLookupByLibrary.simpleMessage("Cargando "),
|
||||||
"cancel" : MessageLookupByLibrary.simpleMessage("CANCELAR"),
|
"cancel" : MessageLookupByLibrary.simpleMessage("CANCELAR"),
|
||||||
"cellularConfirm" : MessageLookupByLibrary.simpleMessage("Alerta de datos móviles "),
|
"cellularConfirm" : MessageLookupByLibrary.simpleMessage("Alerta de datos móviles "),
|
||||||
|
|
|
@ -87,6 +87,7 @@ class MessageLookup extends MessageLookupByLibrary {
|
||||||
"all" : MessageLookupByLibrary.simpleMessage("Tout"),
|
"all" : MessageLookupByLibrary.simpleMessage("Tout"),
|
||||||
"autoDownload" : MessageLookupByLibrary.simpleMessage("Téléchargements auto"),
|
"autoDownload" : MessageLookupByLibrary.simpleMessage("Téléchargements auto"),
|
||||||
"back" : MessageLookupByLibrary.simpleMessage("Retour"),
|
"back" : MessageLookupByLibrary.simpleMessage("Retour"),
|
||||||
|
"boostVolume" : MessageLookupByLibrary.simpleMessage("Boost volume"),
|
||||||
"buffering" : MessageLookupByLibrary.simpleMessage("Buffering"),
|
"buffering" : MessageLookupByLibrary.simpleMessage("Buffering"),
|
||||||
"cancel" : MessageLookupByLibrary.simpleMessage("ANNULER"),
|
"cancel" : MessageLookupByLibrary.simpleMessage("ANNULER"),
|
||||||
"cellularConfirm" : MessageLookupByLibrary.simpleMessage("Avertissement utilisation des données mobiles"),
|
"cellularConfirm" : MessageLookupByLibrary.simpleMessage("Avertissement utilisation des données mobiles"),
|
||||||
|
|
|
@ -87,6 +87,7 @@ class MessageLookup extends MessageLookupByLibrary {
|
||||||
"all" : MessageLookupByLibrary.simpleMessage("全部"),
|
"all" : MessageLookupByLibrary.simpleMessage("全部"),
|
||||||
"autoDownload" : MessageLookupByLibrary.simpleMessage("自动下载"),
|
"autoDownload" : MessageLookupByLibrary.simpleMessage("自动下载"),
|
||||||
"back" : MessageLookupByLibrary.simpleMessage("返回"),
|
"back" : MessageLookupByLibrary.simpleMessage("返回"),
|
||||||
|
"boostVolume" : MessageLookupByLibrary.simpleMessage("增强声音"),
|
||||||
"buffering" : MessageLookupByLibrary.simpleMessage("缓冲中"),
|
"buffering" : MessageLookupByLibrary.simpleMessage("缓冲中"),
|
||||||
"cancel" : MessageLookupByLibrary.simpleMessage("取消"),
|
"cancel" : MessageLookupByLibrary.simpleMessage("取消"),
|
||||||
"cellularConfirm" : MessageLookupByLibrary.simpleMessage("流量确认"),
|
"cellularConfirm" : MessageLookupByLibrary.simpleMessage("流量确认"),
|
||||||
|
|
|
@ -119,6 +119,16 @@ class S {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// `Boost volume`
|
||||||
|
String get boostVolume {
|
||||||
|
return Intl.message(
|
||||||
|
'Boost volume',
|
||||||
|
name: 'boostVolume',
|
||||||
|
desc: 'Boost volume in player widget.',
|
||||||
|
args: [],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/// `Buffering`
|
/// `Buffering`
|
||||||
String get buffering {
|
String get buffering {
|
||||||
return Intl.message(
|
return Intl.message(
|
||||||
|
|
|
@ -261,8 +261,11 @@ class LastPosition extends StatelessWidget {
|
||||||
return Selector<AudioPlayerNotifier, EpisodeBrief>(
|
return Selector<AudioPlayerNotifier, EpisodeBrief>(
|
||||||
selector: (_, audio) => audio.episode,
|
selector: (_, audio) => audio.episode,
|
||||||
builder: (context, episode, child) {
|
builder: (context, episode, child) {
|
||||||
return Row(
|
return SingleChildScrollView(
|
||||||
|
scrollDirection: Axis.horizontal,
|
||||||
|
child: Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
children: [
|
children: [
|
||||||
Selector<AudioPlayerNotifier, bool>(
|
Selector<AudioPlayerNotifier, bool>(
|
||||||
selector: (_, audio) => audio.skipSilence,
|
selector: (_, audio) => audio.skipSilence,
|
||||||
|
@ -286,16 +289,17 @@ class LastPosition extends StatelessWidget {
|
||||||
.onSurface
|
.onSurface
|
||||||
.withOpacity(0.12))),
|
.withOpacity(0.12))),
|
||||||
textColor: data ? Colors.white : null,
|
textColor: data ? Colors.white : null,
|
||||||
onPressed: () => audio.setSkipSilence(skipSilence: !data))),
|
onPressed: () =>
|
||||||
|
audio.setSkipSilence(skipSilence: !data))),
|
||||||
SizedBox(width: 10),
|
SizedBox(width: 10),
|
||||||
Selector<AudioPlayerNotifier, bool>(
|
Selector<AudioPlayerNotifier, bool>(
|
||||||
selector: (_, audio) => audio.boostVolume,
|
selector: (_, audio) => audio.boostVolume,
|
||||||
builder: (_, data, __) => FlatButton(
|
builder: (_, data, __) => FlatButton(
|
||||||
child: Row(
|
child: Row(
|
||||||
children: [
|
children: [
|
||||||
Icon(Icons.flash_on, size: 18),
|
Icon(Icons.volume_up, size: 18),
|
||||||
SizedBox(width: 5),
|
SizedBox(width: 5),
|
||||||
Text('Boost Volume'),
|
Text(s.boostVolume),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
color: data ? context.accentColor : Colors.transparent,
|
color: data ? context.accentColor : Colors.transparent,
|
||||||
|
@ -310,7 +314,8 @@ class LastPosition extends StatelessWidget {
|
||||||
.onSurface
|
.onSurface
|
||||||
.withOpacity(0.12))),
|
.withOpacity(0.12))),
|
||||||
textColor: data ? Colors.white : null,
|
textColor: data ? Colors.white : null,
|
||||||
onPressed: () => audio.setBoostVolume(boostVolume: !data))),
|
onPressed: () =>
|
||||||
|
audio.setBoostVolume(boostVolume: !data))),
|
||||||
SizedBox(width: 10),
|
SizedBox(width: 10),
|
||||||
FutureBuilder<PlayHistory>(
|
FutureBuilder<PlayHistory>(
|
||||||
future: getPosition(episode),
|
future: getPosition(episode),
|
||||||
|
@ -373,6 +378,7 @@ class LastPosition extends StatelessWidget {
|
||||||
: Center(),
|
: Center(),
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
|
@ -24,6 +24,10 @@
|
||||||
"@autoDownload": {},
|
"@autoDownload": {},
|
||||||
"back": "Back",
|
"back": "Back",
|
||||||
"@back": {},
|
"@back": {},
|
||||||
|
"boostVolume": "Boost volume",
|
||||||
|
"@boostVolume": {
|
||||||
|
"description": "Boost volume in player widget."
|
||||||
|
},
|
||||||
"buffering": "Buffering",
|
"buffering": "Buffering",
|
||||||
"@buffering": {},
|
"@buffering": {},
|
||||||
"cancel": "CANCEL",
|
"cancel": "CANCEL",
|
||||||
|
|
|
@ -24,6 +24,10 @@
|
||||||
"@autoDownload": {},
|
"@autoDownload": {},
|
||||||
"back": "Atras",
|
"back": "Atras",
|
||||||
"@back": {},
|
"@back": {},
|
||||||
|
"boostVolume": "Boost volume",
|
||||||
|
"@boostVolume": {
|
||||||
|
"description": "Boost volume in player widget."
|
||||||
|
},
|
||||||
"buffering": "Cargando ",
|
"buffering": "Cargando ",
|
||||||
"@buffering": {},
|
"@buffering": {},
|
||||||
"cancel": "CANCELAR",
|
"cancel": "CANCELAR",
|
||||||
|
|
|
@ -24,6 +24,10 @@
|
||||||
"@autoDownload": {},
|
"@autoDownload": {},
|
||||||
"back": "Retour",
|
"back": "Retour",
|
||||||
"@back": {},
|
"@back": {},
|
||||||
|
"boostVolume": "Boost volume",
|
||||||
|
"@boostVolume": {
|
||||||
|
"description": "Boost volume in player widget."
|
||||||
|
},
|
||||||
"buffering": "Buffering",
|
"buffering": "Buffering",
|
||||||
"@buffering": {},
|
"@buffering": {},
|
||||||
"cancel": "ANNULER",
|
"cancel": "ANNULER",
|
||||||
|
|
|
@ -24,6 +24,10 @@
|
||||||
"@autoDownload": {},
|
"@autoDownload": {},
|
||||||
"back": "返回",
|
"back": "返回",
|
||||||
"@back": {},
|
"@back": {},
|
||||||
|
"boostVolume": "增强声音",
|
||||||
|
"@boostVolume": {
|
||||||
|
"description": "Boost volume in player widget."
|
||||||
|
},
|
||||||
"buffering": "缓冲中",
|
"buffering": "缓冲中",
|
||||||
"@buffering": {},
|
"@buffering": {},
|
||||||
"cancel": "取消",
|
"cancel": "取消",
|
||||||
|
|
|
@ -66,6 +66,8 @@ class AudioPlayerNotifier extends ChangeNotifier {
|
||||||
var playerHeightStorage = KeyValueStorage(playerHeightKey);
|
var playerHeightStorage = KeyValueStorage(playerHeightKey);
|
||||||
var speedStorage = KeyValueStorage(speedKey);
|
var speedStorage = KeyValueStorage(speedKey);
|
||||||
var skipSilenceStorage = KeyValueStorage(skipSilenceKey);
|
var skipSilenceStorage = KeyValueStorage(skipSilenceKey);
|
||||||
|
var boostVolumeStorage = KeyValueStorage(boostVolumeKey);
|
||||||
|
var volumeGainStorage = KeyValueStorage(volumeGainKey);
|
||||||
|
|
||||||
/// Current playing episdoe.
|
/// Current playing episdoe.
|
||||||
EpisodeBrief _episode;
|
EpisodeBrief _episode;
|
||||||
|
@ -148,6 +150,12 @@ class AudioPlayerNotifier extends ChangeNotifier {
|
||||||
/// Player skip silence.
|
/// Player skip silence.
|
||||||
bool _skipSilence;
|
bool _skipSilence;
|
||||||
|
|
||||||
|
/// Boost volumn
|
||||||
|
bool _boostVolume;
|
||||||
|
|
||||||
|
/// Boost volume gain.
|
||||||
|
int _volumeGain;
|
||||||
|
|
||||||
// ignore: prefer_final_fields
|
// ignore: prefer_final_fields
|
||||||
bool _playerRunning = false;
|
bool _playerRunning = false;
|
||||||
|
|
||||||
|
@ -175,6 +183,8 @@ class AudioPlayerNotifier extends ChangeNotifier {
|
||||||
int get rewindSeconds => _rewindSeconds;
|
int get rewindSeconds => _rewindSeconds;
|
||||||
PlayerHeight get playerHeight => _playerHeight;
|
PlayerHeight get playerHeight => _playerHeight;
|
||||||
bool get skipSilence => _skipSilence;
|
bool get skipSilence => _skipSilence;
|
||||||
|
bool get boostVolume => _boostVolume;
|
||||||
|
int get volumeGain => _volumeGain;
|
||||||
|
|
||||||
set setSwitchValue(double value) {
|
set setSwitchValue(double value) {
|
||||||
_switchValue = value;
|
_switchValue = value;
|
||||||
|
@ -197,6 +207,8 @@ class AudioPlayerNotifier extends ChangeNotifier {
|
||||||
_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);
|
||||||
|
_volumeGain = await volumeGainStorage.getInt(defaultValue: 3000);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future _savePlayerHeight() async {
|
Future _savePlayerHeight() async {
|
||||||
|
@ -345,12 +357,23 @@ class AudioPlayerNotifier extends ChangeNotifier {
|
||||||
sleepTimer(defaultTimer);
|
sleepTimer(defaultTimer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Set player speed.
|
||||||
if (_currentSpeed != 1.0) {
|
if (_currentSpeed != 1.0) {
|
||||||
await AudioService.customAction('setSpeed', _currentSpeed);
|
await AudioService.customAction('setSpeed', _currentSpeed);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Set slipsilence.
|
||||||
if (_skipSilence) {
|
if (_skipSilence) {
|
||||||
await AudioService.customAction('setSkipSilence', skipSilence);
|
await AudioService.customAction('setSkipSilence', skipSilence);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Set boostValome.
|
||||||
|
if (_boostVolume) {
|
||||||
|
await AudioService.customAction(
|
||||||
|
'setBoostVolume', [_boostVolume, _volumeGain]);
|
||||||
|
}
|
||||||
|
|
||||||
await AudioService.play();
|
await AudioService.play();
|
||||||
|
|
||||||
AudioService.currentMediaItemStream
|
AudioService.currentMediaItemStream
|
||||||
|
@ -456,6 +479,8 @@ class AudioPlayerNotifier extends ChangeNotifier {
|
||||||
|
|
||||||
playNext() async {
|
playNext() async {
|
||||||
await AudioService.skipToNext();
|
await AudioService.skipToNext();
|
||||||
|
_queueUpdate = !_queueUpdate;
|
||||||
|
notifyListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
addToPlaylist(EpisodeBrief episode) async {
|
addToPlaylist(EpisodeBrief episode) async {
|
||||||
|
@ -520,6 +545,19 @@ class AudioPlayerNotifier extends ChangeNotifier {
|
||||||
return index;
|
return index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future reorderPlaylist(int oldIndex, int newIndex) async {
|
||||||
|
var episode = _queue.playlist[oldIndex];
|
||||||
|
if (playerRunning) {
|
||||||
|
await AudioService.removeQueueItem(episode.toMediaItem());
|
||||||
|
await AudioService.addQueueItemAt(episode.toMediaItem(), newIndex);
|
||||||
|
}
|
||||||
|
await _queue.addToPlayListAt(episode, newIndex);
|
||||||
|
if (newIndex == 0) {
|
||||||
|
_lastPostion = 0;
|
||||||
|
await positionStorage.saveInt(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Future<bool> moveToTop(EpisodeBrief episode) async {
|
Future<bool> moveToTop(EpisodeBrief episode) async {
|
||||||
await delFromPlaylist(episode);
|
await delFromPlaylist(episode);
|
||||||
if (playerRunning) {
|
if (playerRunning) {
|
||||||
|
@ -535,11 +573,11 @@ class AudioPlayerNotifier extends ChangeNotifier {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
pauseAduio() async {
|
Future<void> pauseAduio() async {
|
||||||
AudioService.pause();
|
await AudioService.pause();
|
||||||
}
|
}
|
||||||
|
|
||||||
resumeAudio() async {
|
Future<void> resumeAudio() async {
|
||||||
if (_audioState != AudioProcessingState.connecting &&
|
if (_audioState != AudioProcessingState.connecting &&
|
||||||
_audioState != AudioProcessingState.none) AudioService.play();
|
_audioState != AudioProcessingState.none) AudioService.play();
|
||||||
}
|
}
|
||||||
|
@ -591,6 +629,14 @@ class AudioPlayerNotifier extends ChangeNotifier {
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setBoostVolume({@required bool boostVolume, int gain}) async {
|
||||||
|
await AudioService.customAction(
|
||||||
|
'setBoostVolume', [boostVolume, _volumeGain]);
|
||||||
|
_boostVolume = boostVolume;
|
||||||
|
notifyListeners();
|
||||||
|
await boostVolumeStorage.saveBool(boostVolume);
|
||||||
|
}
|
||||||
|
|
||||||
//Set sleep timer
|
//Set sleep timer
|
||||||
sleepTimer(int mins) {
|
sleepTimer(int mins) {
|
||||||
if (_sleepTimerMode == SleepTimerMode.timer) {
|
if (_sleepTimerMode == SleepTimerMode.timer) {
|
||||||
|
@ -953,6 +999,9 @@ class AudioPlayerTask extends BackgroundAudioTask {
|
||||||
case 'setSkipSilence':
|
case 'setSkipSilence':
|
||||||
await _setSkipSilence(argument);
|
await _setSkipSilence(argument);
|
||||||
break;
|
break;
|
||||||
|
case 'setBoostVolume':
|
||||||
|
await _setBoostVolume(argument[0], argument[1]);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -962,6 +1011,10 @@ class AudioPlayerTask extends BackgroundAudioTask {
|
||||||
AudioServiceBackground.setMediaItem(mediaItem.copyWith(duration: duration));
|
AudioServiceBackground.setMediaItem(mediaItem.copyWith(duration: duration));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future _setBoostVolume(bool boo, int gain) async {
|
||||||
|
await _audioPlayer.setBoostVolume(boo, gain: gain);
|
||||||
|
}
|
||||||
|
|
||||||
Future<void> _setState({
|
Future<void> _setState({
|
||||||
AudioProcessingState processingState,
|
AudioProcessingState processingState,
|
||||||
Duration position,
|
Duration position,
|
||||||
|
|
Loading…
Reference in New Issue