Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Media audio can be very loud on room entry and scene changes #5550

Merged
merged 1 commit into from
Jul 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/components/avatar-audio-source.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ AFRAME.registerComponent("avatar-audio-source", {
} else {
audio = new THREE.Audio(audioListener);
}
// Default to being quiet so it fades in when volume is set by audio systems
audio.gain.gain.value = 0;

this.audioSystem.addAudio({ sourceType: SourceType.AVATAR_AUDIO_SOURCE, node: audio });

if (SHOULD_CREATE_SILENT_AUDIO_ELS) {
Expand Down
4 changes: 4 additions & 0 deletions src/components/media-video.js
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,8 @@ AFRAME.registerComponent("media-video", {
} else {
this.audio = new THREE.Audio(audioListener);
}
// Default to being quiet so it fades in when volume is set by audio systems
this.audio.gain.gain.value = 0;
this.audioSystem.addAudio({ sourceType: SourceType.MEDIA_VIDEO, node: this.audio });

this.audio.setNodeSource(this.mediaElementAudioSource);
Expand All @@ -370,6 +372,8 @@ AFRAME.registerComponent("media-video", {

APP.audios.set(this.el, this.audio);
updateAudioSettings(this.el, this.audio);
// Original audio source volume can now be restored as audio systems will take over
this.mediaElementAudioSource.mediaElement.volume = 1;
},

async updateSrc(oldData) {
Expand Down
3 changes: 2 additions & 1 deletion src/utils/media-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,8 @@ export function createVideoOrAudioEl(type) {
el.muted = isIOS;
el.preload = "auto";
el.crossOrigin = "anonymous";

// Audio should default to zero or it be heard before it is positioning and adjusted
el.volume = 0;
return el;
}

Expand Down