Decrease ad volume by 75%#239
Merged
Jayian1890 merged 2 commits intoOpenCloudGaming:devfrom Apr 11, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adjusts renderer-side queue ad playback to reduce audio volume during ad preview playback, with the intent to restore the prior volume afterward.
Changes:
- Captures the video element’s initial volume in a ref and scales playback volume to 25%.
- Attempts to restore the captured volume in the effect cleanup when the ad preview is torn down.
Comment on lines
+176
to
+181
| if (originalVolumeRef.current === null) { | ||
| originalVolumeRef.current = video.volume; | ||
| } | ||
| try { | ||
| video.volume = Math.max(0, Math.min(1, (originalVolumeRef.current ?? 1) * 0.25)); | ||
| } catch { |
There was a problem hiding this comment.
originalVolumeRef is only captured once for the lifetime of the component (it never resets when mediaUrl changes). If the element volume is modified between ads (or by the browser), subsequent ads will scale from a stale value and the cleanup will restore to the old volume. Consider capturing the original volume per-mediaUrl (e.g., reset the ref to null when mediaUrl changes, or keep originalVolume as a local variable in this effect and restore from that in cleanup).
… and adjust volume to 31.25%
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adjust the ad playback volume to a quarter of the original level, ensuring that the original volume can be restored when playback ends.