fix buttons that require navigation in track menu
wakelock when lyrics screen open
This commit is contained in:
parent
36f8666906
commit
2e67b50332
|
@ -143,6 +143,7 @@ class AudioPlayerTask extends BaseAudioHandler {
|
|||
JustAudioMediaKit.ensureInitialized();
|
||||
JustAudioMediaKit.title = 'Freezer';
|
||||
JustAudioMediaKit.protocolWhitelist = const ['http'];
|
||||
JustAudioMediaKit.prefetchPlaylist = true;
|
||||
//JustAudioMediaKit.bufferSize = 128;
|
||||
|
||||
_deezerAPI = initArgs.deezerAPI;
|
||||
|
@ -366,23 +367,6 @@ class AudioPlayerTask extends BaseAudioHandler {
|
|||
return Future.value();
|
||||
}
|
||||
|
||||
// unused.
|
||||
@override
|
||||
Future<void> seekForward(bool begin) => Future.value();
|
||||
|
||||
Future<void> seekBackward(bool begin) async {
|
||||
// (un)favourite action
|
||||
if (cache.libraryTracks.contains(currentMediaItem.id)) {
|
||||
cache.libraryTracks.remove(currentMediaItem.id);
|
||||
_broadcastState();
|
||||
return _deezerAPI.removeFavorite(currentMediaItem.id);
|
||||
}
|
||||
|
||||
cache.libraryTracks.add(currentMediaItem.id);
|
||||
_broadcastState();
|
||||
return _deezerAPI.addFavoriteTrack(currentMediaItem.id);
|
||||
}
|
||||
|
||||
//Remove item from queue
|
||||
@override
|
||||
Future<void> removeQueueItem(MediaItem mediaItem) async {
|
||||
|
@ -415,13 +399,9 @@ class AudioPlayerTask extends BaseAudioHandler {
|
|||
@override
|
||||
Future<void> skipToPrevious() async {
|
||||
if (_queueIndex == 0) return;
|
||||
//Update buffering state
|
||||
//_skipState = AudioProcessingState.skippingToPrevious;
|
||||
//Normal skip to previous
|
||||
unawaited(_logListenedTrack(currentMediaItem.id, sync: false, prev: true));
|
||||
_queueIndex--;
|
||||
await _player.seekToPrevious();
|
||||
//_skipState = null;
|
||||
}
|
||||
|
||||
Future<void> _logListenedTrack(String trackId,
|
||||
|
@ -479,42 +459,52 @@ class AudioPlayerTask extends BaseAudioHandler {
|
|||
customAction: CustomMediaAction(name: 'favorite'));
|
||||
}
|
||||
|
||||
Future<void> toggleFavoriteCurrent() async {
|
||||
// (un)favourite action
|
||||
if (cache.libraryTracks.contains(currentMediaItem.id)) {
|
||||
cache.libraryTracks.remove(currentMediaItem.id);
|
||||
_broadcastState();
|
||||
await _deezerAPI.removeFavorite(currentMediaItem.id);
|
||||
return;
|
||||
}
|
||||
|
||||
cache.libraryTracks.add(currentMediaItem.id);
|
||||
_broadcastState();
|
||||
await _deezerAPI.addFavoriteTrack(currentMediaItem.id);
|
||||
}
|
||||
|
||||
//Update state on all clients
|
||||
void _broadcastState() {
|
||||
final controls = !currentMediaItemIsShow
|
||||
? [
|
||||
if (queue.value.isNotEmpty) favoriteControl(),
|
||||
if (_queueIndex != 0) MediaControl.skipToPrevious,
|
||||
_player.playing ? MediaControl.pause : MediaControl.play,
|
||||
MediaControl.stop,
|
||||
if (queue.hasValue && _queueIndex != queue.value.length - 1)
|
||||
MediaControl.skipToNext,
|
||||
]
|
||||
: [
|
||||
const MediaControl(
|
||||
androidIcon: 'drawable/ic_replay_30',
|
||||
label: 'replay 30',
|
||||
action: MediaAction.rewind,
|
||||
), // acts as prev-30
|
||||
_player.playing ? MediaControl.pause : MediaControl.play,
|
||||
MediaControl.stop,
|
||||
const MediaControl(
|
||||
androidIcon: 'drawable/ic_forward_30',
|
||||
label: 'forward 30',
|
||||
action: MediaAction.fastForward,
|
||||
), // next-30
|
||||
];
|
||||
playbackState.add(PlaybackState(
|
||||
controls: !currentMediaItemIsShow
|
||||
? [
|
||||
if (queue.value.isNotEmpty) favoriteControl(),
|
||||
/*if (_queueIndex != 0)*/ MediaControl.skipToPrevious,
|
||||
_player.playing ? MediaControl.pause : MediaControl.play,
|
||||
/**/ MediaControl.skipToNext,
|
||||
//Stop -- USELESS.
|
||||
// MediaControl(
|
||||
// androidIcon: 'drawable/ic_action_stop',
|
||||
// label: 'stop',
|
||||
// action: MediaAction.stop),
|
||||
// i mean, the user can just swipe the notification away to stop
|
||||
]
|
||||
: [
|
||||
const MediaControl(
|
||||
androidIcon: 'drawable/ic_replay_30',
|
||||
label: 'replay 30',
|
||||
action: MediaAction.rewind,
|
||||
), // acts as prev-30
|
||||
_player.playing ? MediaControl.pause : MediaControl.play,
|
||||
const MediaControl(
|
||||
androidIcon: 'drawable/ic_forward_30',
|
||||
label: 'forward 30',
|
||||
action: MediaAction.fastForward,
|
||||
), // next-30
|
||||
],
|
||||
controls: controls,
|
||||
systemActions: !currentMediaItemIsShow
|
||||
? {
|
||||
? const {
|
||||
MediaAction.seek,
|
||||
if (queue.hasValue && _queueIndex != queue.value.length - 1)
|
||||
MediaAction.skipToNext,
|
||||
if (_queueIndex != 0) MediaAction.skipToPrevious,
|
||||
MediaAction.stop
|
||||
MediaAction.seekForward,
|
||||
MediaAction.seekBackward,
|
||||
}
|
||||
: const {
|
||||
MediaAction.seek,
|
||||
|
@ -527,8 +517,9 @@ class AudioPlayerTask extends BaseAudioHandler {
|
|||
bufferedPosition: _player.bufferedPosition,
|
||||
speed: _player.speed,
|
||||
queueIndex: _queueIndex,
|
||||
androidCompactActionIndices:
|
||||
!currentMediaItemIsShow ? const [1, 2, 3] : const [0, 1, 2],
|
||||
androidCompactActionIndices: List.generate(controls.length, (i) => i)
|
||||
.whereNot((i) => controls[i].action == MediaAction.stop)
|
||||
.toList(growable: false),
|
||||
repeatMode: _repeatMode,
|
||||
shuffleMode: _originalQueue == null
|
||||
? AudioServiceShuffleMode.none
|
||||
|
@ -536,16 +527,16 @@ class AudioPlayerTask extends BaseAudioHandler {
|
|||
));
|
||||
}
|
||||
|
||||
//just_audio state -> audio_service state. If skipping, use _skipState
|
||||
//just_audio state -> audio_service state.
|
||||
AudioProcessingState _convertProcessingState(
|
||||
ProcessingState processingState) {
|
||||
return const <ProcessingState, AudioProcessingState>{
|
||||
ProcessingState.idle: AudioProcessingState.idle,
|
||||
ProcessingState.loading: AudioProcessingState.loading,
|
||||
ProcessingState.buffering: AudioProcessingState.buffering,
|
||||
ProcessingState.ready: AudioProcessingState.ready,
|
||||
ProcessingState.completed: AudioProcessingState.completed,
|
||||
}[processingState]!;
|
||||
return switch (processingState) {
|
||||
ProcessingState.idle => AudioProcessingState.idle,
|
||||
ProcessingState.loading => AudioProcessingState.loading,
|
||||
ProcessingState.buffering => AudioProcessingState.buffering,
|
||||
ProcessingState.ready => AudioProcessingState.ready,
|
||||
ProcessingState.completed => AudioProcessingState.completed,
|
||||
};
|
||||
}
|
||||
|
||||
//Replace current queue
|
||||
|
@ -699,6 +690,8 @@ class AudioPlayerTask extends BaseAudioHandler {
|
|||
case 'setIndex':
|
||||
_queueIndex = extras!['index'];
|
||||
break;
|
||||
case 'favorite':
|
||||
toggleFavoriteCurrent();
|
||||
//Start visualizer
|
||||
// case 'startVisualizer':
|
||||
// if (_visualizerSubscription != null) break;
|
||||
|
|
|
@ -166,8 +166,8 @@ class MenuSheet {
|
|||
title: option.label,
|
||||
leading: option.icon,
|
||||
onTap: () {
|
||||
option.onTap.call();
|
||||
Navigator.pop(context);
|
||||
option.onTap.call();
|
||||
},
|
||||
))
|
||||
.toList(growable: false)),
|
||||
|
@ -367,10 +367,7 @@ class MenuSheet {
|
|||
onTap: () {
|
||||
navigatorKey.currentState!
|
||||
.push(MaterialPageRoute(builder: (context) => ArtistDetails(a)));
|
||||
|
||||
if (navigateCallback != null) {
|
||||
navigateCallback!();
|
||||
}
|
||||
navigateCallback?.call();
|
||||
},
|
||||
);
|
||||
|
||||
|
@ -385,9 +382,7 @@ class MenuSheet {
|
|||
navigatorKey.currentState!
|
||||
.push(MaterialPageRoute(builder: (context) => AlbumDetails(a)));
|
||||
|
||||
if (navigateCallback != null) {
|
||||
navigateCallback!();
|
||||
}
|
||||
navigateCallback?.call();
|
||||
},
|
||||
);
|
||||
|
||||
|
@ -686,7 +681,9 @@ class MenuSheet {
|
|||
);
|
||||
|
||||
MenuSheetOption wakelock() => MenuSheetOption(
|
||||
Text('Keep the screen on'.i18n),
|
||||
Text(cache.wakelock
|
||||
? 'Don\'t keep screen on'.i18n
|
||||
: 'Keep the screen on'.i18n),
|
||||
icon: const Icon(Icons.screen_lock_portrait),
|
||||
onTap: () async {
|
||||
//Enable
|
||||
|
|
|
@ -31,6 +31,7 @@ import 'package:marquee/marquee.dart';
|
|||
import 'package:palette_generator/palette_generator.dart';
|
||||
import 'package:photo_view/photo_view.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:wakelock_plus/wakelock_plus.dart';
|
||||
|
||||
const _blurStrength = 90.0;
|
||||
|
||||
|
@ -949,11 +950,19 @@ class _BigAlbumArtState extends State<BigAlbumArt> with WidgetsBindingObserver {
|
|||
super.dispose();
|
||||
}
|
||||
|
||||
void _pushLyrics() {
|
||||
void _pushLyrics() async {
|
||||
// enable wakelock if not already enabled
|
||||
final wakelockChanged = !(await WakelockPlus.enabled);
|
||||
if (wakelockChanged) {
|
||||
WakelockPlus.enable();
|
||||
}
|
||||
builder(ctx) => ChangeNotifierProvider<BackgroundProvider>.value(
|
||||
value: Provider.of<BackgroundProvider>(context),
|
||||
child: const LyricsScreen());
|
||||
Navigator.of(context).pushRoute(builder: builder);
|
||||
final pushed = Navigator.of(context).pushRoute(builder: builder);
|
||||
if (wakelockChanged) {
|
||||
pushed.then((_) => WakelockPlus.disable());
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -1044,9 +1053,9 @@ class _BigAlbumArtState extends State<BigAlbumArt> with WidgetsBindingObserver {
|
|||
)),
|
||||
);
|
||||
|
||||
return Center(
|
||||
child: AspectRatio(
|
||||
aspectRatio: 1.0,
|
||||
return AspectRatio(
|
||||
aspectRatio: 1.0,
|
||||
child: Center(
|
||||
child: settings.playerAlbumArtDropShadow
|
||||
? Consumer<BackgroundProvider>(
|
||||
builder: (context, background, child) => AnimatedContainer(
|
||||
|
|
|
@ -1538,13 +1538,15 @@ class _GeneralSettingsState extends State<GeneralSettings> {
|
|||
ScaffoldMessenger.of(context).snack('Copied'.i18n);
|
||||
},
|
||||
),
|
||||
// ListTile(
|
||||
// title: const Text('DEBUG: stop audioHandler'),
|
||||
// onTap: () => audioHandler.stop()),
|
||||
// ListTile(
|
||||
// title: const Text('DEBUG: show login screen'),
|
||||
// onTap: () => Navigator.of(context, rootNavigator: true)
|
||||
// .pushRoute(builder: (ctx) => LoginWidget())),
|
||||
if (kDebugMode) ...[
|
||||
ListTile(
|
||||
title: const Text('DEBUG: stop audioHandler'),
|
||||
onTap: () => audioHandler.stop()),
|
||||
ListTile(
|
||||
title: const Text('DEBUG: show login screen'),
|
||||
onTap: () => Navigator.of(context, rootNavigator: true)
|
||||
.pushRoute(builder: (ctx) => LoginWidget())),
|
||||
],
|
||||
],
|
||||
),
|
||||
);
|
||||
|
|
|
@ -73,7 +73,7 @@ apply_standard_settings(${BINARY_NAME})
|
|||
# Add dependency libraries. Add any application-specific dependencies here.
|
||||
target_link_libraries(${BINARY_NAME} PRIVATE flutter)
|
||||
target_link_libraries(${BINARY_NAME} PRIVATE PkgConfig::GTK)
|
||||
|
||||
target_link_libraries(${BINARY_NAME} PRIVATE ${MIMALLOC_LIB})
|
||||
# Run the Flutter tool portions of the build. This must not be removed.
|
||||
add_dependencies(${BINARY_NAME} flutter_assemble)
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ if [ ! -w "$APPLICATIONS_DIR" ]; then
|
|||
exit 1
|
||||
fi
|
||||
|
||||
cat <<EOF
|
||||
cat <<EOF > "$APPLICATIONS_DIR/freezer.desktop"
|
||||
[Desktop Entry]
|
||||
Type=Application
|
||||
Name=freezer
|
||||
|
@ -30,5 +30,5 @@ Icon=$ICON
|
|||
Categories=Audio;Music;Player;AudioVideo;
|
||||
Keywords=Music;Player;Streaming;Online;
|
||||
Terminal=false
|
||||
EOF > "$APPLICATIONS_DIR/freezer.desktop"
|
||||
EOF
|
||||
|
||||
|
|
3540
pubspec.lock
3540
pubspec.lock
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue