mirror of
https://github.com/KRTirtho/spotube.git
synced 2025-09-13 07:55:18 +00:00
Seekbar support added to Android Media Controls
Turned off MPRIS for flatpak
This commit is contained in:
parent
9129c4d2b1
commit
4453049e08
@ -23,6 +23,7 @@ import 'package:spotube/provider/YouTube.dart';
|
|||||||
import 'package:spotube/services/LinuxAudioService.dart';
|
import 'package:spotube/services/LinuxAudioService.dart';
|
||||||
import 'package:spotube/services/MobileAudioService.dart';
|
import 'package:spotube/services/MobileAudioService.dart';
|
||||||
import 'package:spotube/utils/PersistedChangeNotifier.dart';
|
import 'package:spotube/utils/PersistedChangeNotifier.dart';
|
||||||
|
import 'package:spotube/utils/platform.dart';
|
||||||
import 'package:youtube_explode_dart/youtube_explode_dart.dart' hide Playlist;
|
import 'package:youtube_explode_dart/youtube_explode_dart.dart' hide Playlist;
|
||||||
import 'package:collection/collection.dart';
|
import 'package:collection/collection.dart';
|
||||||
import 'package:spotube/extensions/list-sort-multiple.dart';
|
import 'package:spotube/extensions/list-sort-multiple.dart';
|
||||||
@ -73,7 +74,7 @@ class Playback extends PersistedChangeNotifier {
|
|||||||
_subscriptions = [],
|
_subscriptions = [],
|
||||||
status = PlaybackStatus.idle,
|
status = PlaybackStatus.idle,
|
||||||
super() {
|
super() {
|
||||||
if (Platform.isLinux) {
|
if (Platform.isLinux && !kIsFlatpak) {
|
||||||
_linuxAudioService = LinuxAudioService(this);
|
_linuxAudioService = LinuxAudioService(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -151,19 +152,21 @@ class Playback extends PersistedChangeNotifier {
|
|||||||
status = PlaybackStatus.loading;
|
status = PlaybackStatus.loading;
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// the track is not a SpotubeTrack so turning it to one
|
||||||
|
if (track is! SpotubeTrack) {
|
||||||
|
track = await toSpotubeTrack(track);
|
||||||
|
}
|
||||||
|
|
||||||
final tag = MediaItem(
|
final tag = MediaItem(
|
||||||
id: track.id!,
|
id: track.id!,
|
||||||
title: track.name!,
|
title: track.name!,
|
||||||
album: track.album?.name,
|
album: track.album?.name,
|
||||||
artist: artistsToString(track.artists ?? <ArtistSimple>[]),
|
artist: artistsToString(track.artists ?? <ArtistSimple>[]),
|
||||||
artUri: Uri.parse(imageToUrlString(track.album?.images)),
|
artUri: Uri.parse(imageToUrlString(track.album?.images)),
|
||||||
|
duration: track.ytTrack.duration,
|
||||||
);
|
);
|
||||||
mobileAudioService?.addItem(tag);
|
mobileAudioService?.addItem(tag);
|
||||||
|
|
||||||
// the track is not a SpotubeTrack so turning it to one
|
|
||||||
if (track is! SpotubeTrack) {
|
|
||||||
track = await toSpotubeTrack(track);
|
|
||||||
}
|
|
||||||
_logger.v("[Track Direct Source] - ${(track).ytUri}");
|
_logger.v("[Track Direct Source] - ${(track).ytUri}");
|
||||||
this.track = track;
|
this.track = track;
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
|
@ -15,6 +15,10 @@ class MobileAudioService extends BaseAudioHandler {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
_player.onPositionChanged.listen((pos) async {
|
||||||
|
playbackState.add(await _transformEvent());
|
||||||
|
});
|
||||||
|
|
||||||
_player.onPlayerComplete.listen((_) {
|
_player.onPlayerComplete.listen((_) {
|
||||||
if (playback.playlist == null && playback.track == null) {
|
if (playback.playlist == null && playback.track == null) {
|
||||||
playbackState.add(
|
playbackState.add(
|
||||||
@ -70,6 +74,9 @@ class MobileAudioService extends BaseAudioHandler {
|
|||||||
MediaControl.skipToNext,
|
MediaControl.skipToNext,
|
||||||
MediaControl.stop,
|
MediaControl.stop,
|
||||||
],
|
],
|
||||||
|
systemActions: {
|
||||||
|
MediaAction.seek,
|
||||||
|
},
|
||||||
androidCompactActionIndices: const [0, 1, 2],
|
androidCompactActionIndices: const [0, 1, 2],
|
||||||
playing: playback.player.state == PlayerState.playing,
|
playing: playback.player.state == PlayerState.playing,
|
||||||
updatePosition:
|
updatePosition:
|
||||||
|
@ -3,3 +3,5 @@ import 'dart:io';
|
|||||||
final kIsDesktop = Platform.isLinux || Platform.isWindows || Platform.isMacOS;
|
final kIsDesktop = Platform.isLinux || Platform.isWindows || Platform.isMacOS;
|
||||||
|
|
||||||
final kIsMobile = Platform.isAndroid || Platform.isIOS;
|
final kIsMobile = Platform.isAndroid || Platform.isIOS;
|
||||||
|
|
||||||
|
final kIsFlatpak = Platform.environment["FLATPAK_ID"] != null;
|
||||||
|
Loading…
Reference in New Issue
Block a user