don't delete cache for currently playing bgm

This commit is contained in:
Luke Hubmayer-Werner 2024-07-18 14:46:40 +09:30
parent 3ebcf6883f
commit efca0b8e8c
1 changed files with 4 additions and 1 deletions

View File

@ -94,10 +94,14 @@ func evaluate_bgm(id: int):
bgm_tracksets[id] = tracks bgm_tracksets[id] = tracks
func _play_bgm_jaot(key: String) -> void: func _play_bgm_jaot(key: String) -> void:
self.queued_bgm_playback = ''
var target_time := 0.0 var target_time := 0.0
var bgm_key_and_tempo_thou := key.split('-') var bgm_key_and_tempo_thou := key.split('-')
var bgm_key := bgm_key_and_tempo_thou[0] var bgm_key := bgm_key_and_tempo_thou[0]
var tempo_thou := int(bgm_key_and_tempo_thou[1]) var tempo_thou := int(bgm_key_and_tempo_thou[1])
if key == self.current_bgm_playback:
self.audio_player.play(0)
return
if audio_player.playing and self.current_bgm_playback.begins_with(bgm_key): if audio_player.playing and self.current_bgm_playback.begins_with(bgm_key):
var old_tempo_thou := int(self.current_bgm_playback.split('-')[1]) var old_tempo_thou := int(self.current_bgm_playback.split('-')[1])
var old_playback_pos: float = audio_player.get_playback_position() var old_playback_pos: float = audio_player.get_playback_position()
@ -109,7 +113,6 @@ func _play_bgm_jaot(key: String) -> void:
self.audio_player.play(target_time) self.audio_player.play(target_time)
self.prerendered_bgms.erase(self.current_bgm_playback) # purge previous stream from cache self.prerendered_bgms.erase(self.current_bgm_playback) # purge previous stream from cache
self.current_bgm_playback = key self.current_bgm_playback = key
self.queued_bgm_playback = ''
func play_bgm(id: int, live: bool) -> void: func play_bgm(id: int, live: bool) -> void: