mirror of
https://github.com/KRTirtho/spotube.git
synced 2025-09-13 07:55:18 +00:00
fix: macos build error, mobile player duration and playing state and background disposal of player
This commit is contained in:
parent
6430a25870
commit
be91e33828
@ -42,7 +42,8 @@ class AlbumCard extends HookConsumerWidget {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context, ref) {
|
Widget build(BuildContext context, ref) {
|
||||||
final playlist = ref.watch(PlaylistQueueNotifier.provider);
|
final playlist = ref.watch(PlaylistQueueNotifier.provider);
|
||||||
final playing = useStream(audioPlayer.playingStream).data ?? false;
|
final playing =
|
||||||
|
useStream(audioPlayer.playingStream).data ?? audioPlayer.isPlaying;
|
||||||
final playlistNotifier = ref.watch(PlaylistQueueNotifier.notifier);
|
final playlistNotifier = ref.watch(PlaylistQueueNotifier.notifier);
|
||||||
final queryClient = useQueryClient();
|
final queryClient = useQueryClient();
|
||||||
final query = queryClient
|
final query = queryClient
|
||||||
|
@ -44,7 +44,9 @@ class PlayerControls extends HookConsumerWidget {
|
|||||||
[]);
|
[]);
|
||||||
final playlist = ref.watch(PlaylistQueueNotifier.provider);
|
final playlist = ref.watch(PlaylistQueueNotifier.provider);
|
||||||
final playlistNotifier = ref.watch(PlaylistQueueNotifier.notifier);
|
final playlistNotifier = ref.watch(PlaylistQueueNotifier.notifier);
|
||||||
final playing = useStream(audioPlayer.playingStream).data ?? false;
|
|
||||||
|
final playing =
|
||||||
|
useStream(audioPlayer.playingStream).data ?? audioPlayer.isPlaying;
|
||||||
final buffering = useStream(audioPlayer.bufferingStream).data ?? true;
|
final buffering = useStream(audioPlayer.bufferingStream).data ?? true;
|
||||||
final theme = Theme.of(context);
|
final theme = Theme.of(context);
|
||||||
|
|
||||||
|
@ -28,7 +28,8 @@ class PlayerOverlay extends HookConsumerWidget {
|
|||||||
);
|
);
|
||||||
final playlistNotifier = ref.watch(PlaylistQueueNotifier.notifier);
|
final playlistNotifier = ref.watch(PlaylistQueueNotifier.notifier);
|
||||||
final playlist = ref.watch(PlaylistQueueNotifier.provider);
|
final playlist = ref.watch(PlaylistQueueNotifier.provider);
|
||||||
final playing = useStream(audioPlayer.playingStream).data ?? false;
|
final playing =
|
||||||
|
useStream(audioPlayer.playingStream).data ?? audioPlayer.isPlaying;
|
||||||
|
|
||||||
final theme = Theme.of(context);
|
final theme = Theme.of(context);
|
||||||
final textColor = theme.colorScheme.primary;
|
final textColor = theme.colorScheme.primary;
|
||||||
|
@ -21,7 +21,8 @@ class PlaylistCard extends HookConsumerWidget {
|
|||||||
Widget build(BuildContext context, ref) {
|
Widget build(BuildContext context, ref) {
|
||||||
final playlistQueue = ref.watch(PlaylistQueueNotifier.provider);
|
final playlistQueue = ref.watch(PlaylistQueueNotifier.provider);
|
||||||
final playlistNotifier = ref.watch(PlaylistQueueNotifier.notifier);
|
final playlistNotifier = ref.watch(PlaylistQueueNotifier.notifier);
|
||||||
final playing = useStream(audioPlayer.playingStream).data ?? false;
|
final playing =
|
||||||
|
useStream(audioPlayer.playingStream).data ?? audioPlayer.isPlaying;
|
||||||
final queryBowl = QueryClient.of(context);
|
final queryBowl = QueryClient.of(context);
|
||||||
final query = queryBowl.getQuery<List<Track>, dynamic>(
|
final query = queryBowl.getQuery<List<Track>, dynamic>(
|
||||||
"playlist-tracks/${playlist.id}",
|
"playlist-tracks/${playlist.id}",
|
||||||
|
@ -12,10 +12,17 @@ Tuple4<double, Duration, Duration, double> useProgress(WidgetRef ref) {
|
|||||||
useStream(audioPlayer.bufferedPositionStream).data?.inSeconds ?? 0;
|
useStream(audioPlayer.bufferedPositionStream).data?.inSeconds ?? 0;
|
||||||
final playlistNotifier = ref.watch(PlaylistQueueNotifier.notifier);
|
final playlistNotifier = ref.watch(PlaylistQueueNotifier.notifier);
|
||||||
|
|
||||||
final duration = useStream(audioPlayer.durationStream).data ?? Duration.zero;
|
// Duration future is needed for getting the duration of the song
|
||||||
|
// as stream can be null when no event occurs (Mostly needed for android)
|
||||||
|
final durationFuture = useFuture(audioPlayer.duration);
|
||||||
|
final duration = useStream(audioPlayer.durationStream).data ??
|
||||||
|
durationFuture.data ??
|
||||||
|
Duration.zero;
|
||||||
|
final positionFuture = useFuture(audioPlayer.position);
|
||||||
final positionSnapshot = useStream(audioPlayer.positionStream);
|
final positionSnapshot = useStream(audioPlayer.positionStream);
|
||||||
|
|
||||||
final position = positionSnapshot.data ?? Duration.zero;
|
final position =
|
||||||
|
positionSnapshot.data ?? positionFuture.data ?? Duration.zero;
|
||||||
|
|
||||||
final sliderMax = duration.inSeconds;
|
final sliderMax = duration.inSeconds;
|
||||||
final sliderValue = position.inSeconds;
|
final sliderValue = position.inSeconds;
|
||||||
|
@ -199,9 +199,10 @@ class SpotubeState extends ConsumerState<Spotube> {
|
|||||||
|
|
||||||
useInitSysTray(ref);
|
useInitSysTray(ref);
|
||||||
|
|
||||||
/// For enabling hot reload for audio player
|
|
||||||
useEffect(() {
|
useEffect(() {
|
||||||
return () {
|
return () {
|
||||||
|
/// For enabling hot reload for audio player
|
||||||
|
if (!kDebugMode) return;
|
||||||
audioPlayer.dispose();
|
audioPlayer.dispose();
|
||||||
youtube.close();
|
youtube.close();
|
||||||
};
|
};
|
||||||
|
@ -52,7 +52,7 @@ class SpotubeAudioPlayer {
|
|||||||
// stream getters
|
// stream getters
|
||||||
Stream<Duration> get durationStream {
|
Stream<Duration> get durationStream {
|
||||||
if (apSupportedPlatform) {
|
if (apSupportedPlatform) {
|
||||||
return _audioPlayer!.onDurationChanged;
|
return _audioPlayer!.onDurationChanged.asBroadcastStream();
|
||||||
} else {
|
} else {
|
||||||
throw UnimplementedError();
|
throw UnimplementedError();
|
||||||
}
|
}
|
||||||
@ -60,7 +60,7 @@ class SpotubeAudioPlayer {
|
|||||||
|
|
||||||
Stream<Duration> get positionStream {
|
Stream<Duration> get positionStream {
|
||||||
if (apSupportedPlatform) {
|
if (apSupportedPlatform) {
|
||||||
return _audioPlayer!.onPositionChanged;
|
return _audioPlayer!.onPositionChanged.asBroadcastStream();
|
||||||
} else {
|
} else {
|
||||||
throw UnimplementedError();
|
throw UnimplementedError();
|
||||||
}
|
}
|
||||||
@ -69,7 +69,7 @@ class SpotubeAudioPlayer {
|
|||||||
Stream<Duration> get bufferedPositionStream {
|
Stream<Duration> get bufferedPositionStream {
|
||||||
if (apSupportedPlatform) {
|
if (apSupportedPlatform) {
|
||||||
// audioplayers doesn't have the capability to get buffered position
|
// audioplayers doesn't have the capability to get buffered position
|
||||||
return const Stream.empty();
|
return const Stream<Duration>.empty().asBroadcastStream();
|
||||||
} else {
|
} else {
|
||||||
throw UnimplementedError();
|
throw UnimplementedError();
|
||||||
}
|
}
|
||||||
@ -77,7 +77,7 @@ class SpotubeAudioPlayer {
|
|||||||
|
|
||||||
Stream<void> get completedStream {
|
Stream<void> get completedStream {
|
||||||
if (apSupportedPlatform) {
|
if (apSupportedPlatform) {
|
||||||
return _audioPlayer!.onPlayerComplete;
|
return _audioPlayer!.onPlayerComplete.asBroadcastStream();
|
||||||
} else {
|
} else {
|
||||||
throw UnimplementedError();
|
throw UnimplementedError();
|
||||||
}
|
}
|
||||||
@ -87,7 +87,7 @@ class SpotubeAudioPlayer {
|
|||||||
if (apSupportedPlatform) {
|
if (apSupportedPlatform) {
|
||||||
return _audioPlayer!.onPlayerStateChanged.map((state) {
|
return _audioPlayer!.onPlayerStateChanged.map((state) {
|
||||||
return state == ap.PlayerState.playing;
|
return state == ap.PlayerState.playing;
|
||||||
});
|
}).asBroadcastStream();
|
||||||
} else {
|
} else {
|
||||||
throw UnimplementedError();
|
throw UnimplementedError();
|
||||||
}
|
}
|
||||||
@ -95,7 +95,7 @@ class SpotubeAudioPlayer {
|
|||||||
|
|
||||||
Stream<bool> get bufferingStream {
|
Stream<bool> get bufferingStream {
|
||||||
if (apSupportedPlatform) {
|
if (apSupportedPlatform) {
|
||||||
return Stream.value(false);
|
return Stream.value(false).asBroadcastStream();
|
||||||
} else {
|
} else {
|
||||||
throw UnimplementedError();
|
throw UnimplementedError();
|
||||||
}
|
}
|
||||||
@ -103,7 +103,8 @@ class SpotubeAudioPlayer {
|
|||||||
|
|
||||||
Stream<PlayerState> get playerStateStream =>
|
Stream<PlayerState> get playerStateStream =>
|
||||||
_audioPlayer!.onPlayerStateChanged
|
_audioPlayer!.onPlayerStateChanged
|
||||||
.map((state) => PlayerState.fromApPlayerState(state));
|
.map((state) => PlayerState.fromApPlayerState(state))
|
||||||
|
.asBroadcastStream();
|
||||||
|
|
||||||
// regular info getter
|
// regular info getter
|
||||||
|
|
||||||
|
@ -11,11 +11,11 @@
|
|||||||
<key>com.apple.security.network.client</key>
|
<key>com.apple.security.network.client</key>
|
||||||
<true />
|
<true />
|
||||||
<!-- Just Audio Config -->
|
<!-- Just Audio Config -->
|
||||||
<key>NSAppTransportSecurity</key>
|
<!-- <key>NSAppTransportSecurity</key>
|
||||||
<dict>
|
<dict>
|
||||||
<key>NSAllowsArbitraryLoads</key>
|
<key>NSAllowsArbitraryLoads</key>
|
||||||
<true />
|
<true />
|
||||||
</dict>
|
</dict> -->
|
||||||
<!-- Requires Certification -->
|
<!-- Requires Certification -->
|
||||||
<!-- <key>keychain-access-groups</key>
|
<!-- <key>keychain-access-groups</key>
|
||||||
<array /> -->
|
<array /> -->
|
||||||
|
@ -6,14 +6,14 @@
|
|||||||
<true />
|
<true />
|
||||||
<key>com.apple.security.network.server</key>
|
<key>com.apple.security.network.server</key>
|
||||||
<true />
|
<true />
|
||||||
<!-- Just Audio Config -->
|
|
||||||
<key>com.apple.security.network.client</key>
|
<key>com.apple.security.network.client</key>
|
||||||
<true />
|
<true />
|
||||||
<key>NSAppTransportSecurity</key>
|
<!-- Just Audio Config -->
|
||||||
|
<!-- <key>NSAppTransportSecurity</key>
|
||||||
<dict>
|
<dict>
|
||||||
<key>NSAllowsArbitraryLoads</key>
|
<key>NSAllowsArbitraryLoads</key>
|
||||||
<true />
|
<true />
|
||||||
</dict>
|
</dict> -->
|
||||||
<!-- Requires Certification -->
|
<!-- Requires Certification -->
|
||||||
<!-- <key>keychain-access-groups</key>
|
<!-- <key>keychain-access-groups</key>
|
||||||
<array /> -->
|
<array /> -->
|
||||||
|
Loading…
Reference in New Issue
Block a user