-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add audio stream and fix only current parcel id can plays audio (…
…#61) * feat: add audio stream and fix only current parcel id can plays audio * fix format * fix audio stream and video player, set the same logic * format * add local videos * format * apply review
- Loading branch information
1 parent
e3e68ed
commit 60e2fc8
Showing
21 changed files
with
751 additions
and
113 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...entraland_components/audio_streaming.tscn → ...decentraland_components/audio_stream.tscn
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[gd_scene load_steps=2 format=3 uid="uid://de7563ke1agyk"] | ||
|
||
[ext_resource type="Script" path="res://src/decentraland_components/audio_streaming.gd" id="1_oqq6w"] | ||
[ext_resource type="Script" path="res://src/decentraland_components/audio_stream.gd" id="1_oqq6w"] | ||
|
||
[node name="audio_streaming" type="AudioStreamPlayer"] | ||
[node name="audio_stream" type="DclAudioStream"] | ||
script = ExtResource("1_oqq6w") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
extends DclVideoPlayer | ||
|
||
var file_hash: String = "" | ||
|
||
|
||
func stream_buffer(data: PackedVector2Array): | ||
if not self.playing: | ||
self.play() | ||
|
||
self.get_stream_playback().push_buffer(data) | ||
|
||
|
||
func request_video(_file_hash): | ||
var content_mapping = Global.scene_runner.get_scene_content_mapping(dcl_scene_id) | ||
self.file_hash = _file_hash | ||
|
||
var fetching_resource = Global.content_manager.fetch_video(file_hash, content_mapping) | ||
if not fetching_resource: | ||
self._on_video_loaded(self.file_hash) | ||
else: | ||
Global.content_manager.content_loading_finished.connect( | ||
self._content_manager_resource_loaded | ||
) | ||
|
||
|
||
func _content_manager_resource_loaded(resource_hash: String): | ||
_on_video_loaded(resource_hash, true) | ||
|
||
|
||
func _on_video_loaded(resource_hash: String, from_signal: bool = false): | ||
if resource_hash != file_hash: | ||
return | ||
|
||
if from_signal: | ||
Global.content_manager.content_loading_finished.disconnect( | ||
self._content_manager_resource_loaded | ||
) | ||
|
||
var local_video_path = "user://content/" + file_hash | ||
var absolute_file_path = local_video_path.replace("user:/", OS.get_user_data_dir()) | ||
self.resolve_resource(absolute_file_path) | ||
|
||
|
||
func init_audio(frame_rate, frames, length, format, bit_rate, frame_size, channels): | ||
print( | ||
"audio_stream debug init ", | ||
frame_rate, | ||
" - ", | ||
frames, | ||
" - ", | ||
length, | ||
" - ", | ||
format, | ||
" - ", | ||
bit_rate, | ||
" - ", | ||
frame_size, | ||
" - ", | ||
channels | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[gd_scene load_steps=2 format=3 uid="uid://de7563ke1agyk"] | ||
|
||
[ext_resource type="Script" path="res://src/decentraland_components/video_player.gd" id="1_oqq6w"] | ||
|
||
[node name="video_player" type="DclVideoPlayer"] | ||
script = ExtResource("1_oqq6w") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.