Skip to content

Commit

Permalink
Dim video on overlay and persist MUTE indicator
Browse files Browse the repository at this point in the history
  • Loading branch information
netpro2k committed Jan 19, 2019
1 parent 22cff64 commit 309b711
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
6 changes: 5 additions & 1 deletion src/components/hover-menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ AFRAME.registerComponent("hover-menu", {
multiple: true,
schema: {
template: { type: "selector" },
dirs: { type: "array" }
dirs: { type: "array" },
dim: { default: true }
},

async init() {
Expand Down Expand Up @@ -46,6 +47,9 @@ AFRAME.registerComponent("hover-menu", {
applyHoverState() {
if (!this.menu) return;
this.menu.object3D.visible = !this.el.sceneEl.is("frozen") && this.hovering;
if (this.data.dim && this.el.object3DMap.mesh && this.el.object3DMap.mesh.material) {
this.el.object3DMap.mesh.material.color.setScalar(this.menu.object3D.visible ? 0.5 : 1);
}
},

play() {
Expand Down
12 changes: 9 additions & 3 deletions src/components/media-views.js
Original file line number Diff line number Diff line change
Expand Up @@ -553,12 +553,18 @@ AFRAME.registerComponent("media-video", {

const userinput = this.el.sceneEl.systems.userinput;
const volumeMod = userinput.get(paths.actions.cursor.mediaVolumeMod);
if (volumeMod) {
if (this.el.is("hovered") && volumeMod) {
this.el.setAttribute("media-video", "volume", THREE.Math.clamp(this.data.volume + volumeMod, 0, 1));
this.volumeLabel.setAttribute("text", "value", `VOL: ${Math.round(this.data.volume * 100)}%`);
this.volumeLabel.setAttribute(
"text",
"value",
this.data.volume === 0 ? "MUTE" : `VOL: ${Math.round(this.data.volume * 100)}%`
);
this.volumeLabel.object3D.visible = true;
clearTimeout(this.hideVolumeLabelTimeout);
this.hideVolumeLabelTimeout = setTimeout(() => (this.volumeLabel.object3D.visible = false), 1000);
if (this.data.volume) {
this.hideVolumeLabelTimeout = setTimeout(() => (this.volumeLabel.object3D.visible = false), 1000);
}
}

if (this.hoverMenu.object3D.visible && !this.videoIsLive) {
Expand Down

0 comments on commit 309b711

Please sign in to comment.