Fixed settings and updated player view. Fixed many other smaler things
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
extends PanelContainer
|
||||
|
||||
# LOC 20/1-24: 136
|
||||
|
||||
@onready
|
||||
var play_button := $HBoxContainer/PlayButton
|
||||
|
||||
@@ -27,6 +29,8 @@ var is_changing: bool = false
|
||||
var playback_position: float
|
||||
var stream: AudioStream
|
||||
|
||||
signal fetched
|
||||
|
||||
func set_songs(new_songs) -> void:
|
||||
songs = new_songs
|
||||
|
||||
@@ -61,29 +65,18 @@ func _process(_delta):
|
||||
progress.value = audio.get_playback_position()
|
||||
label.text = format_text(progress.value, stream.get_length())
|
||||
|
||||
signal fetched
|
||||
|
||||
func fetch_first_song() -> void:
|
||||
var http_request = HTTPRequest.new()
|
||||
add_child(http_request)
|
||||
#http.set_download_file("https://music.sanplex.tech/music/first")
|
||||
http_request.request_completed.connect(first_song_fetched)
|
||||
|
||||
# Perform a GET request. The URL below returns JSON as of writing.
|
||||
var error = http_request.request("https://music.sanplex.tech/music/rand")
|
||||
if error != OK:
|
||||
push_error("An error occurred in the HTTP request.")
|
||||
var first_song_fetched = func(result, _response_code, _headers, body):
|
||||
if result != HTTPRequest.RESULT_SUCCESS:
|
||||
push_error("Song couldn't be downloaded. Try a different song.")
|
||||
var sound = AudioStreamMP3.new()
|
||||
sound.data = body
|
||||
Settings.make_request2("/music/addQue", func(): fetched.emit(), true)
|
||||
play(sound)
|
||||
|
||||
func first_song_fetched(result, response_code, headers, body) -> void:
|
||||
if result != HTTPRequest.RESULT_SUCCESS:
|
||||
push_error("Song couldn't be downloaded. Try a different song.")
|
||||
var sound = AudioStreamMP3.new()
|
||||
sound.data = body
|
||||
make_request("https://music.sanplex.tech/music/addQue", add_que)
|
||||
#fetched.emit()
|
||||
play(sound)
|
||||
Settings.make_request2("/music/rand", first_song_fetched, true)
|
||||
|
||||
func add_que(result, response_code, headers, body) -> void:
|
||||
func add_que(_result, response_code, _headers, _body) -> void:
|
||||
print("response_code", response_code)
|
||||
fetched.emit()
|
||||
|
||||
@@ -99,7 +92,6 @@ func play(song) -> void:
|
||||
stream = audio.stream
|
||||
else:
|
||||
if songs:
|
||||
#print(songs)
|
||||
path = songs[0]
|
||||
print(path)
|
||||
print(FileAccess.file_exists(path))
|
||||
@@ -131,4 +123,4 @@ func load_mp3(_path) -> AudioStream:
|
||||
var file = FileAccess.open(_path, FileAccess.READ)
|
||||
var sound = AudioStreamMP3.new()
|
||||
sound.data = file.get_buffer(file.get_length())
|
||||
return sound
|
||||
return sound
|
||||
Reference in New Issue
Block a user