mirror of
https://github.com/KRTirtho/spotube.git
synced 2025-09-14 16:25:16 +00:00
fix: shuffle play logic
cd(nightly): fix linux runner bug
This commit is contained in:
parent
166710f041
commit
65cad07e3a
8
.github/workflows/spotube-nightly.yml
vendored
8
.github/workflows/spotube-nightly.yml
vendored
@ -7,7 +7,7 @@ on:
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build_ubuntu:
|
build_ubuntu:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-20.04
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
- uses: subosito/flutter-action@v2.8.0
|
- uses: subosito/flutter-action@v2.8.0
|
||||||
@ -20,9 +20,9 @@ jobs:
|
|||||||
sudo apt-get update -y
|
sudo apt-get update -y
|
||||||
sudo apt-get install -y tar clang cmake ninja-build pkg-config libgtk-3-dev make python3-pip python3-setuptools patchelf desktop-file-utils libgdk-pixbuf2.0-dev fakeroot strace fuse libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev
|
sudo apt-get install -y tar clang cmake ninja-build pkg-config libgtk-3-dev make python3-pip python3-setuptools patchelf desktop-file-utils libgdk-pixbuf2.0-dev fakeroot strace fuse libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev
|
||||||
- run: |
|
- run: |
|
||||||
wget -O appimage-builder-x86_64.AppImage https://github.com/AppImageCrafters/appimage-builder/releases/download/v1.0.0-beta.1/appimage-builder-1.0.0-677acbd-x86_64.AppImage
|
wget -O appimage-builder https://github.com/AppImageCrafters/appimage-builder/releases/download/v1.1.0/appimage-builder-1.1.0-x86_64.AppImage
|
||||||
chmod +x appimage-builder-x86_64.AppImage
|
chmod +x appimage-builder
|
||||||
mv appimage-builder-x86_64.AppImage /usr/local/bin/appimage-builder
|
mv appimage-builder /usr/local/bin/
|
||||||
|
|
||||||
- run: |
|
- run: |
|
||||||
curl -sS https://webi.sh/yq | sh
|
curl -sS https://webi.sh/yq | sh
|
||||||
|
@ -1,20 +0,0 @@
|
|||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:platform_ui/platform_ui.dart';
|
|
||||||
|
|
||||||
class PlaylistShuffleButton extends StatelessWidget {
|
|
||||||
final onPressed;
|
|
||||||
|
|
||||||
const PlaylistShuffleButton({
|
|
||||||
Key? key,
|
|
||||||
this.onPressed,
|
|
||||||
});
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return PlatformIconButton(
|
|
||||||
tooltip: "Shuffle",
|
|
||||||
icon: const Icon(Icons.shuffle),
|
|
||||||
onPressed: this.onPressed,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
@ -24,9 +24,9 @@ class TrackCollectionView<T> extends HookConsumerWidget {
|
|||||||
final String titleImage;
|
final String titleImage;
|
||||||
final bool isPlaying;
|
final bool isPlaying;
|
||||||
final void Function([Track? currentTrack]) onPlay;
|
final void Function([Track? currentTrack]) onPlay;
|
||||||
|
final void Function([Track? currentTrack]) onShuffledPlay;
|
||||||
final void Function() onShare;
|
final void Function() onShare;
|
||||||
final Widget? heartBtn;
|
final Widget? heartBtn;
|
||||||
final Widget? shuffleButton;
|
|
||||||
final AlbumSimple? album;
|
final AlbumSimple? album;
|
||||||
|
|
||||||
final bool showShare;
|
final bool showShare;
|
||||||
@ -41,10 +41,10 @@ class TrackCollectionView<T> extends HookConsumerWidget {
|
|||||||
required this.titleImage,
|
required this.titleImage,
|
||||||
required this.isPlaying,
|
required this.isPlaying,
|
||||||
required this.onPlay,
|
required this.onPlay,
|
||||||
|
required this.onShuffledPlay,
|
||||||
required this.onShare,
|
required this.onShare,
|
||||||
required this.routePath,
|
required this.routePath,
|
||||||
this.heartBtn,
|
this.heartBtn,
|
||||||
this.shuffleButton,
|
|
||||||
this.album,
|
this.album,
|
||||||
this.description,
|
this.description,
|
||||||
this.showShare = true,
|
this.showShare = true,
|
||||||
@ -70,7 +70,14 @@ class TrackCollectionView<T> extends HookConsumerWidget {
|
|||||||
onPressed: onShare,
|
onPressed: onShare,
|
||||||
),
|
),
|
||||||
if (heartBtn != null) heartBtn!,
|
if (heartBtn != null) heartBtn!,
|
||||||
if (shuffleButton != null) shuffleButton!,
|
PlatformIconButton(
|
||||||
|
tooltip: "Shuffle",
|
||||||
|
icon: Icon(
|
||||||
|
Icons.shuffle,
|
||||||
|
color: color?.titleTextColor,
|
||||||
|
),
|
||||||
|
onPressed: onShuffledPlay,
|
||||||
|
),
|
||||||
const SizedBox(width: 5),
|
const SizedBox(width: 5),
|
||||||
// play playlist
|
// play playlist
|
||||||
PlatformIconButton(
|
PlatformIconButton(
|
||||||
|
@ -14,7 +14,6 @@ import 'package:spotube/utils/type_conversion_utils.dart';
|
|||||||
import 'package:spotube/models/current_playlist.dart';
|
import 'package:spotube/models/current_playlist.dart';
|
||||||
import 'package:spotube/provider/playback_provider.dart';
|
import 'package:spotube/provider/playback_provider.dart';
|
||||||
import 'package:spotube/provider/spotify_provider.dart';
|
import 'package:spotube/provider/spotify_provider.dart';
|
||||||
import 'package:spotube/components/shared/playlist_shuffle_button.dart';
|
|
||||||
|
|
||||||
class AlbumPage extends HookConsumerWidget {
|
class AlbumPage extends HookConsumerWidget {
|
||||||
final AlbumSimple album;
|
final AlbumSimple album;
|
||||||
@ -113,26 +112,32 @@ class AlbumPage extends HookConsumerWidget {
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
heartBtn: AlbumHeartButton(album: album),
|
heartBtn: AlbumHeartButton(album: album),
|
||||||
shuffleButton: PlaylistShuffleButton(onPressed: () {
|
onShuffledPlay: ([track]) {
|
||||||
var albumTracks = tracksSnapshot.data!
|
|
||||||
.map((track) =>
|
|
||||||
TypeConversionUtils.simpleTrack_X_Track(track, album))
|
|
||||||
.toList();
|
|
||||||
// Shuffle the tracks (create a copy of playlist)
|
// Shuffle the tracks (create a copy of playlist)
|
||||||
var tracks = [...albumTracks];
|
if (tracksSnapshot.hasData) {
|
||||||
tracks.shuffle();
|
final tracks = tracksSnapshot.data!
|
||||||
|
.map((track) =>
|
||||||
// If playback is playing a track then pause it
|
TypeConversionUtils.simpleTrack_X_Track(track, album))
|
||||||
if (playback.isPlaying) {
|
.toList()
|
||||||
playback.pause();
|
..shuffle();
|
||||||
|
if (!isAlbumPlaying) {
|
||||||
|
playPlaylist(
|
||||||
|
playback,
|
||||||
|
tracks,
|
||||||
|
ref,
|
||||||
|
);
|
||||||
|
} else if (isAlbumPlaying && track != null) {
|
||||||
|
playPlaylist(
|
||||||
|
playback,
|
||||||
|
tracks,
|
||||||
|
ref,
|
||||||
|
currentTrack: track,
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
playback.stop();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
// Play the shuffled playlist
|
|
||||||
playPlaylist( playback,
|
|
||||||
tracks,
|
|
||||||
ref,
|
|
||||||
);
|
|
||||||
}),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,6 @@ import 'package:spotube/services/queries/queries.dart';
|
|||||||
|
|
||||||
import 'package:spotube/utils/service_utils.dart';
|
import 'package:spotube/utils/service_utils.dart';
|
||||||
import 'package:spotube/utils/type_conversion_utils.dart';
|
import 'package:spotube/utils/type_conversion_utils.dart';
|
||||||
import 'package:spotube/components/shared/playlist_shuffle_button.dart';
|
|
||||||
|
|
||||||
class PlaylistView extends HookConsumerWidget {
|
class PlaylistView extends HookConsumerWidget {
|
||||||
final logger = getLogger(PlaylistView);
|
final logger = getLogger(PlaylistView);
|
||||||
@ -127,23 +126,29 @@ class PlaylistView extends HookConsumerWidget {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
heartBtn: PlaylistHeartButton(playlist: playlist),
|
heartBtn: PlaylistHeartButton(playlist: playlist),
|
||||||
shuffleButton: PlaylistShuffleButton(onPressed: () {
|
onShuffledPlay: ([track]) {
|
||||||
// Shuffle the tracks (create a copy of playlist)
|
final tracks = [...?tracksSnapshot.data]..shuffle();
|
||||||
var tracks = [...?tracksSnapshot.data];
|
|
||||||
tracks.shuffle();
|
|
||||||
|
|
||||||
// If playback is playing a track then pause it
|
if (tracksSnapshot.hasData) {
|
||||||
if (playback.isPlaying) {
|
if (!isPlaylistPlaying) {
|
||||||
playback.pause();
|
playPlaylist(
|
||||||
|
playback,
|
||||||
|
tracks,
|
||||||
|
ref,
|
||||||
|
currentTrack: track,
|
||||||
|
);
|
||||||
|
} else if (isPlaylistPlaying && track != null) {
|
||||||
|
playPlaylist(
|
||||||
|
playback,
|
||||||
|
tracks,
|
||||||
|
ref,
|
||||||
|
currentTrack: track,
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
playback.stop();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
// Play the shuffled playlist
|
|
||||||
playPlaylist( playback,
|
|
||||||
tracks,
|
|
||||||
ref,
|
|
||||||
currentTrack: null,
|
|
||||||
);
|
|
||||||
}),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user