fix restoring queueIndex

build-linux: fix getting commit hash
This commit is contained in:
Pato05 2024-02-14 23:29:03 +01:00
parent e782643ee0
commit 99fef45fb8
No known key found for this signature in database
GPG key ID: ED4C6F9C3D574FB6
3 changed files with 13 additions and 7 deletions

View file

@ -108,6 +108,10 @@ class AudioPlayerTask extends BaseAudioHandler {
/// Last playback position (used for restoring position when player died) /// Last playback position (used for restoring position when player died)
Duration? _lastPosition; Duration? _lastPosition;
/// Last playback queueIndex (used for restoring when player died)
int? _lastQueueIndex;
AudioServiceRepeatMode _repeatMode = AudioServiceRepeatMode.none; AudioServiceRepeatMode _repeatMode = AudioServiceRepeatMode.none;
/// LastFM API /// LastFM API
@ -319,6 +323,7 @@ class AudioPlayerTask extends BaseAudioHandler {
Future skipToQueueItem(int index) async { Future skipToQueueItem(int index) async {
await _maybeResume(); await _maybeResume();
_lastPosition = null; _lastPosition = null;
_lastQueueIndex = null;
// next or prev track? // next or prev track?
unawaited(_logListenedTrack( unawaited(_logListenedTrack(
currentMediaItem.id, currentMediaItem.id,
@ -336,10 +341,11 @@ class AudioPlayerTask extends BaseAudioHandler {
Future play() async { Future play() async {
await _maybeResume(); await _maybeResume();
_player.play(); _player.play();
//Restore position on play //Restore position and queue index on play
if (_lastPosition != null) { if (_lastPosition != null) {
_player.seek(_lastPosition); _player.seek(_lastPosition, index: _lastQueueIndex);
_lastPosition = null; _lastPosition = null;
_lastQueueIndex = null;
} }
} }
@ -789,7 +795,7 @@ class AudioPlayerTask extends BaseAudioHandler {
} }
final q = ((await _box.get('queue')) as List?)?.cast<MediaItem>(); final q = ((await _box.get('queue')) as List?)?.cast<MediaItem>();
_queueIndex = await _box.get('index', defaultValue: 0); _lastQueueIndex = _queueIndex = await _box.get('index', defaultValue: 0);
_lastPosition = await _box.get('position', defaultValue: Duration.zero); _lastPosition = await _box.get('position', defaultValue: Duration.zero);
queueSource = queueSource =
await _box.get('queueSource', defaultValue: const QueueSource()); await _box.get('queueSource', defaultValue: const QueueSource());

View file

@ -145,7 +145,7 @@ endif()
# === Create Tarball === # === Create Tarball ===
# Make a tarball out of the install bundle (only in Release mode) # Make a tarball out of the install bundle (only in Release mode)
if(NOT CMAKE_BUILD_TYPE MATCHES "Debug") if(NOT CMAKE_BUILD_TYPE MATCHES "Debug")
configure_file(create-tarball.sh ${PROJECT_BINARY_DIR} configure_file(create-tarball.sh ${PROJECT_BINARY_DIR} @ONLY
FILE_PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ) FILE_PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ)
add_custom_target(create_tar ALL COMMAND "${PROJECT_BINARY_DIR}/create-tarball.sh") add_custom_target(create_tar ALL COMMAND "${PROJECT_BINARY_DIR}/create-tarball.sh")
add_dependencies(create_tar ${BINARY_NAME}) add_dependencies(create_tar ${BINARY_NAME})

View file

@ -1,5 +1,5 @@
#!/bin/sh #!/bin/sh
cd "${PROJECT_BINARY_DIR}/../../../.." cd "@PROJECT_BINARY_DIR@/../../../.."
COMMIT_HASH=`git log -1 --pretty=format:%h` COMMIT_HASH=`git log -1 --pretty=format:%h`
cd "${BUILD_BUNDLE_DIR}" cd "@BUILD_BUNDLE_DIR@"
${CMAKE_COMMAND} -E tar cvzf "${PROJECT_BINARY_DIR}/freezer-linux-${COMMIT_HASH}.tar.gz" . @CMAKE_COMMAND@ -E tar cvzf "@PROJECT_BINARY_DIR@/freezer-linux-${COMMIT_HASH}.tar.gz" .