Added auto repeat and made some small fixes

This commit is contained in:
2024-10-20 20:28:06 +02:00
parent e8171d81a9
commit c4a7d743d3
26 changed files with 797 additions and 39 deletions

View File

@@ -77,9 +77,12 @@ func play_or_pause() -> void:
progress_slider.max_value = round(stream.get_length())
progress_slider.tick_count = round(stream.get_length() / 60)
else:
audio_player.stream_paused = true
playback_position = audio_player.get_playback_position()
play_button.texture_normal = play_icon
pause()
func pause() -> void:
audio_player.stream_paused = true
playback_position = audio_player.get_playback_position()
play_button.texture_normal = play_icon
func restart() -> void:
audio_player.stop()
@@ -94,6 +97,10 @@ func restart() -> void:
func _on_finished() -> void:
play_button.texture_normal = play_icon
song_finished = true
if !Settings.stop_after_current:
fetch_next_song()
if Settings.auto_repeat_song:
restart()
func _on_drag_started() -> void:
is_changing = true
@@ -103,8 +110,8 @@ func _on_drag_ended(_changed: bool) -> void:
playback_position = progress_slider.value
is_changing = false
func seek(position: float) -> void:
progress_slider.value += position
func seek(new_position: float) -> void:
progress_slider.value += new_position
is_changing = true
audio_player.seek(progress_slider.value)
playback_position = progress_slider.value
@@ -161,16 +168,12 @@ func song_fetched(body: PackedByteArray) -> void:
stream = audio_player.stream
progress_slider.max_value = round(stream.get_length())
progress_slider.tick_count = round(stream.get_length() / 60)
add_to_queue.emit()
if Settings.add_to_stats:
print("add to stats")
Settings.make_request3("/music/addPlayed")
if !Settings.stop_after_current:
audio_player.finished.connect(fetch_next_song)
if !Settings.hide_next_track:
show_answer.emit()
add_to_queue.emit()
func fetch_next_song() -> void:
#if audio_player.is_playing():