Skip to content

Commit

Permalink
Do not show snap button for audio media
Browse files Browse the repository at this point in the history
  • Loading branch information
keianhzo committed Jan 24, 2024
1 parent 3cbd8f5 commit 862c74a
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/bit-components.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,8 @@ export const MediaContentBounds = defineComponent({
});
export const MediaInfo = defineComponent({
accessibleUrl: Types.ui32,
contentType: Types.ui32
contentType: Types.ui32,
mediaType: Types.ui8
});
MediaInfo.accessibleUrl[$isStringType] = true;
MediaInfo.contentType[$isStringType] = true;
Expand Down
1 change: 1 addition & 0 deletions src/bit-systems/media-loading.ts
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,7 @@ function* loadMedia(world: HubsWorld, eid: EntityID) {
addComponent(world, MediaInfo, media);
MediaInfo.accessibleUrl[media] = APP.getSid(urlData.accessibleUrl);
MediaInfo.contentType[media] = APP.getSid(urlData.contentType);
MediaInfo.mediaType[media] = urlData.mediaType || 0;
} catch (e) {
console.error(e);
media = renderAsEntity(world, ErrorObject());
Expand Down
4 changes: 4 additions & 0 deletions src/bit-systems/video-menu-system.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
HeldRemoteRight,
HoveredRemoteRight,
Interacted,
MediaInfo,
MediaLoader,
MediaSnapped,
MediaVideo,
Expand All @@ -28,6 +29,7 @@ import { Emitter2Audio } from "./audio-emitter-system";
import { EntityID } from "../utils/networking-types";
import { findAncestorWithComponent, hasAnyComponent } from "../utils/bit-utils";
import { ObjectMenuTransformFlags } from "../inflators/object-menu-transform";
import { MediaType } from "../utils/media-utils";

const videoMenuQuery = defineQuery([VideoMenu]);
const hoveredQuery = defineQuery([HoveredRemoteRight]);
Expand Down Expand Up @@ -112,6 +114,8 @@ function flushToObject3Ds(world: HubsWorld, menu: EntityID, frozen: boolean) {
APP.world.scene.add(obj);
ObjectMenuTransform.targetObjectRef[menu] = target;
ObjectMenuTransform.flags[menu] |= ObjectMenuTransformFlags.Enabled;
const snapButton = world.eid2obj.get(VideoMenu.snapRef[menu])!;
snapButton.visible = MediaInfo.mediaType[target] === MediaType.VIDEO;
} else {
obj.removeFromParent();
setCursorRaycastable(world, menu, false);
Expand Down
4 changes: 2 additions & 2 deletions src/prefabs/video-menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ function VideoActionButton({ buttonIcon, ...props }: VideoButtonProps) {
const { texture, cacheKey } = loadTextureFromCache(buttonIcon, 1);
return (
<Button3D
position={[0, -0.1, uiZ]}
position={[0, 0, uiZ]}
scale={BIG_BUTTON_SCALE}
width={BUTTON_HEIGHT}
height={BUTTON_WIDTH}
Expand Down Expand Up @@ -102,7 +102,7 @@ export function VideoMenuPrefab() {
scale={[0.5, 0.5, 0.5]}
position={[0.5 - 0.02, halfHeight - 0.02, uiZ]}
/>
<SnapButton name="Snap Button" ref={snapRef} position={[0.0, 0.2, uiZ]} />
<SnapButton name="Snap Button" ref={snapRef} position={[0, 0.2, uiZ]} />
<Slider ref={sliderRef} trackRef={trackRef} headRef={headRef} position={[0, -halfHeight + 0.025, uiZ]} />
<VideoActionButton ref={playIndicatorRef} name={"Play Button"} buttonIcon={playImageUrl} />
<VideoActionButton ref={pauseIndicatorRef} name={"Pause Button"} buttonIcon={pauseImageUrl} />
Expand Down

0 comments on commit 862c74a

Please sign in to comment.