balloon 读取 wav 文件是否存在时检查 .IMPORT
This commit is contained in:
parent
346efd0b59
commit
67d5722b2f
@ -121,10 +121,10 @@ func _apply_tags() -> void:
|
||||
if db_str:
|
||||
var db = float(db_str)
|
||||
audio_stream_player.volume_db = db
|
||||
if GlobalConfig.DEBUG:
|
||||
print("audio_stream_player.volume_db = %s" % db)
|
||||
else:
|
||||
audio_stream_player.volume_db = 0
|
||||
if GlobalConfig.DEBUG:
|
||||
print("audio_stream_player.volume_db = %s" % audio_stream_player.volume_db)
|
||||
dialogue_line.text = text
|
||||
|
||||
current_line_ban_skip = dialogue_line.tags.has("ban_skip")
|
||||
@ -184,21 +184,29 @@ func apply_dialogue_line() -> void:
|
||||
# await dialogue_label.finished_typing
|
||||
|
||||
#sound
|
||||
var initial_translation_key = dialogue_line.translation_key
|
||||
var chapter = initial_translation_key.substr(0, 3)
|
||||
var audio_time_len := 0.0
|
||||
# 因为版权问题,有些 mp3 文件打不开,所以使用 ogg 格式
|
||||
var audio_path = (
|
||||
"res://asset/audio/peiyin_new/" + chapter + "/" + initial_translation_key + ".wav"
|
||||
)
|
||||
if FileAccess.file_exists(audio_path):
|
||||
var stream = load(audio_path)
|
||||
audio_time_len = stream.get_length()
|
||||
if audio_stream_player.stream != stream or not audio_stream_player.playing:
|
||||
audio_stream_player.stream = stream
|
||||
audio_stream_player.play()
|
||||
elif audio_stream_player.playing:
|
||||
audio_stream_player.stop()
|
||||
var initial_translation_key = dialogue_line.translation_key
|
||||
if initial_translation_key and initial_translation_key.match("c??_*"):
|
||||
var chapter = initial_translation_key.substr(0, 3)
|
||||
# 因为版权问题,有些 mp3 文件打不开,所以使用 ogg 格式
|
||||
var audio_path = (
|
||||
"res://asset/audio/peiyin_new/" + chapter + "/" + initial_translation_key + ".wav"
|
||||
)
|
||||
# 打包时只有 .import 文件可供检查!
|
||||
var audio_import_path = (
|
||||
"res://asset/audio/peiyin_new/" + chapter + "/" + initial_translation_key + ".wav.import"
|
||||
)
|
||||
if FileAccess.file_exists(audio_import_path):
|
||||
var stream = load(audio_path)
|
||||
audio_time_len = stream.get_length()
|
||||
if audio_stream_player.stream != stream or not audio_stream_player.playing:
|
||||
audio_stream_player.stream = stream
|
||||
audio_stream_player.play()
|
||||
else:
|
||||
if audio_stream_player.playing:
|
||||
audio_stream_player.stop()
|
||||
if GlobalConfig.DEBUG:
|
||||
printerr("Dialogue no audio found! audio_path = %s audio_import_path = %s" % [audio_path, audio_import_path])
|
||||
|
||||
# if dialogue_label.is_typing:
|
||||
# await dialogue_label.finished_typing
|
||||
|
Loading…
Reference in New Issue
Block a user