add src attribute on <audio>
This commit is contained in:
@@ -127,6 +127,12 @@ static func _lua_audio_index_handler(vm: LuauVM) -> int:
|
|||||||
"paused":
|
"paused":
|
||||||
vm.lua_pushboolean(not audio_node.is_playing)
|
vm.lua_pushboolean(not audio_node.is_playing)
|
||||||
return 1
|
return 1
|
||||||
|
"src":
|
||||||
|
if audio_node.current_element:
|
||||||
|
vm.lua_pushstring(audio_node.current_element.get_attribute("src"))
|
||||||
|
else:
|
||||||
|
vm.lua_pushstring("")
|
||||||
|
return 1
|
||||||
_:
|
_:
|
||||||
# Look up other methods/properties in the table itself
|
# Look up other methods/properties in the table itself
|
||||||
vm.lua_rawget(1)
|
vm.lua_rawget(1)
|
||||||
@@ -151,6 +157,12 @@ static func _lua_audio_newindex_handler(vm: LuauVM) -> int:
|
|||||||
"currentTime":
|
"currentTime":
|
||||||
audio_node.call_deferred("set_current_time", float(value))
|
audio_node.call_deferred("set_current_time", float(value))
|
||||||
return 0
|
return 0
|
||||||
|
"src":
|
||||||
|
var src_url = str(value)
|
||||||
|
if audio_node.current_element:
|
||||||
|
audio_node.current_element.set_attribute("src", src_url)
|
||||||
|
audio_node.call_deferred("load_audio_async", src_url)
|
||||||
|
return 0
|
||||||
_:
|
_:
|
||||||
vm.lua_rawset(1)
|
vm.lua_rawset(1)
|
||||||
return 0
|
return 0
|
||||||
@@ -222,6 +234,12 @@ static func handle_dom_audio_index(vm: LuauVM, element_id: String, key: String)
|
|||||||
"paused":
|
"paused":
|
||||||
vm.lua_pushboolean(not audio_node.is_playing)
|
vm.lua_pushboolean(not audio_node.is_playing)
|
||||||
return 1
|
return 1
|
||||||
|
"src":
|
||||||
|
if audio_node.current_element:
|
||||||
|
vm.lua_pushstring(audio_node.current_element.get_attribute("src"))
|
||||||
|
else:
|
||||||
|
vm.lua_pushstring("")
|
||||||
|
return 1
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
@@ -238,5 +256,10 @@ static func handle_dom_audio_newindex(vm: LuauVM, element_id: String, key: Strin
|
|||||||
audio_node.call_deferred("set", "loop", bool(value))
|
audio_node.call_deferred("set", "loop", bool(value))
|
||||||
"currentTime":
|
"currentTime":
|
||||||
audio_node.call_deferred("set_current_time", float(value))
|
audio_node.call_deferred("set_current_time", float(value))
|
||||||
|
"src":
|
||||||
|
var src_url = str(value)
|
||||||
|
if audio_node.current_element:
|
||||||
|
audio_node.current_element.set_attribute("src", src_url)
|
||||||
|
audio_node.call_deferred("load_audio_async", src_url)
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
|
|||||||
Reference in New Issue
Block a user