-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Video Controls Overlay #838
Conversation
|
a4cd041
to
309b711
Compare
this.el.setAttribute("media-video", "volume", THREE.Math.clamp(this.data.volume + volumeMod, 0, 1)); | ||
this.volumeLabel.setAttribute( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You might avoid some work with:
this.volumeLabel.components.text.updateGeometry(this.geometry, font);
this.volumeLabel.components.text.updateLayout();
We have reservations for setAttribute
and also the update
for the text
component does some checks that aren't necessary for you (because you aren't changing font or shader or texture here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would leave the components data in a weird state. Since this is only when adjusting volume I am not too worried about it.
@@ -388,6 +376,11 @@ AFRAME.registerComponent("media-video", { | |||
this.video.removeEventListener("pause", this.onPauseStateChange); | |||
this.video.removeEventListener("play", this.onPauseStateChange); | |||
} | |||
if (this.hoverMenu) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might not exist if somehow this remove
is called before the hoverMenu
promise resolves
this.volumeLabel.object3D.visible = true; | ||
clearTimeout(this.hideVolumeLabelTimeout); | ||
if (this.data.volume) { | ||
this.hideVolumeLabelTimeout = setTimeout(() => (this.volumeLabel.object3D.visible = false), 1000); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok to set a timeout every frame? I suppose people aren't messing with volume all the time...
An alternative might be to write the time that the volume label should be made invisible here since tick is going to keep being called
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah again, since this is only when manipulating volume I don't feel too worried about it.
src/components/media-views.js
Outdated
this.seekForwardButton.object3D.visible = !!this.video && !this.videoIsLive; | ||
this.seekBackButton.object3D.visible = !!this.video && !this.videoIsLive; | ||
} | ||
|
||
// Only update playback posiiton for videos you don't own |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
posiiton -> position
Move video playback controls into an overlay that is shown on hover instead of in the pause menu. Also add feedback for volume level and playback position.
This PR adds a component
hover-menu
which can specify a template to show on hover of the entity (or any child entities). The menu is automatically hidden when paused to not conflict with the pause menu. Components wishing to use the hover menu can callgetMenu()
on thehover-menu
component to get a reference to the instantiated menu element (and then use the sub elements as they see fit).Note that the video overlay's layout currently assumes a 16:9 video. The controls will still work for other video sizes but will be positioned a bit oddly. Also the buttons are using multiple large textures similar to what we are doing in the HUD. This is not ideal but can be addressed as a whole when we decide to fix it in other parts of the UI. Also the way dimming works is pretty opinionated about the object the menu is on, we will need to expand this if we want to show hover menu on other objects.
This also fixes some bugs with volume control.