diff --git a/src/bit-components.js b/src/bit-components.js index 78d76dcbea..a586068f15 100644 --- a/src/bit-components.js +++ b/src/bit-components.js @@ -165,6 +165,14 @@ MediaLoaded.src[$isStringType] = true; export const MediaContentBounds = defineComponent({ bounds: [Types.f32, 3] }); +export const MediaInfo = defineComponent({ + accessibleUrl: Types.ui32, + canonicalUrl: Types.ui32, + canonicalAudioUrl: Types.ui32, + contentType: Types.ui32, + mediaType: Types.ui8, + thumbnail: Types.ui32 +}); export const SceneRoot = defineComponent(); export const NavMesh = defineComponent(); diff --git a/src/bit-systems/media-loading.ts b/src/bit-systems/media-loading.ts index c110281435..9fb22b6189 100644 --- a/src/bit-systems/media-loading.ts +++ b/src/bit-systems/media-loading.ts @@ -4,6 +4,7 @@ import { HubsWorld } from "../app"; import { GLTFModel, MediaContentBounds, + MediaInfo, MediaLoaded, MediaLoader, Networked, @@ -206,10 +207,12 @@ function* loadMedia(world: HubsWorld, eid: EntityID) { } media = yield* loader(world, eid, urlData); addComponent(world, MediaLoaded, media); - const srcSid = APP.getSid(urlData.accessibleUrl); - MediaLoaded.src[media] = srcSid; - const contentTypeSid = APP.getSid(urlData.contentType); - MediaLoaded.contentType[media] = contentTypeSid; + MediaInfo.accessibleUrl[media] = APP.getSid(urlData.accessibleUrl); + MediaInfo.canonicalUrl[media] = APP.getSid(urlData.canonicalUrl); + urlData.canonicalAudioUrl && (MediaInfo.canonicalAudioUrl[media] = APP.getSid(urlData.canonicalAudioUrl)); + MediaInfo.contentType[media] = APP.getSid(urlData.contentType); + urlData.mediaType && (MediaInfo.mediaType[media] = urlData.mediaType); + addComponent(world, MediaInfo, media); } catch (e) { console.error(e); media = renderAsEntity(world, ErrorObject()); diff --git a/src/react-components/room/hooks/useObjectList.js b/src/react-components/room/hooks/useObjectList.js index 0db625dbab..0d29de6c60 100644 --- a/src/react-components/room/hooks/useObjectList.js +++ b/src/react-components/room/hooks/useObjectList.js @@ -1,11 +1,13 @@ import React, { useState, useEffect, useContext, createContext, useCallback, Children, cloneElement } from "react"; import PropTypes from "prop-types"; import { mediaSort, getMediaType } from "../../../utils/media-sorting.js"; +import { defineQuery } from "bitecs"; +import { MediaInfo } from "../../../bit-components.js"; function getDisplayString(elOrEid) { let url; if (!elOrEid.isEntity) { - const srcSid = MediaLoaded.src[elOrEid]; + const srcSid = MediaInfo.accessibleUrl[elOrEid]; url = APP.getString(srcSid); } else { // Having a listed-media component does not guarantee the existence of a media-loader component, @@ -74,7 +76,7 @@ function handleDeselect(scene, object, callback) { } } -const queryListedMedia = defineQuery([MediaLoaded]); +const queryListedMedia = defineQuery([MediaInfo]); export function ObjectListProvider({ scene, children }) { const [objects, setObjects] = useState([]); const [focusedObject, setFocusedObject] = useState(null); // The object currently shown in the viewport diff --git a/src/react-components/room/object-hooks.js b/src/react-components/room/object-hooks.js index 5742b30db4..281b5bee6c 100644 --- a/src/react-components/room/object-hooks.js +++ b/src/react-components/room/object-hooks.js @@ -4,7 +4,7 @@ import { rotateInPlaceAroundWorldUp, affixToWorldUp } from "../../utils/three-ut import { getPromotionTokenForFile } from "../../utils/media-utils"; import { hasComponent } from "bitecs"; import { isPinned as getPinnedState } from "../../bit-systems/networking"; -import { MediaLoaded, Pinnable, Pinned, Static } from "../../bit-components"; +import { MediaInfo, MediaLoaded, Pinnable, Pinned, Static } from "../../bit-components"; import { deleteTheDeletableAncestor } from "../../bit-systems/delete-entity-system"; export function isMe(object) { @@ -27,7 +27,7 @@ export function getObjectUrl(object) { url = mediaLoader && ((mediaLoader.data.mediaOptions && mediaLoader.data.mediaOptions.href) || mediaLoader.data.src); } else { - const urlSid = MediaLoaded.src[object.el]; + const urlSid = MediaInfo.accessibleUrl[object.el]; url = APP.getString(urlSid); }