Skip to content
Snippets Groups Projects
Commit 2314f962 authored by Greg Fodor's avatar Greg Fodor
Browse files

Fixes for firefox and pinning

parent 1db62c98
No related branches found
No related tags found
No related merge requests found
...@@ -327,15 +327,17 @@ AFRAME.registerComponent("media-video", { ...@@ -327,15 +327,17 @@ AFRAME.registerComponent("media-video", {
return; return;
} }
texture.audioSource = this.el.sceneEl.audioListener.context.createMediaElementSource(texture.image); if (!src.startsWith("webrtc://")) {
this.video = texture.image; texture.audioSource = this.el.sceneEl.audioListener.context.createMediaElementSource(texture.image);
const sound = new THREE.PositionalAudio(this.el.sceneEl.audioListener);
sound.setNodeSource(texture.audioSource);
this.el.setObject3D("sound", sound);
}
this.video = texture.image;
this.video.addEventListener("pause", this.onPauseStateChange); this.video.addEventListener("pause", this.onPauseStateChange);
this.video.addEventListener("play", this.onPauseStateChange); this.video.addEventListener("play", this.onPauseStateChange);
const sound = new THREE.PositionalAudio(this.el.sceneEl.audioListener);
sound.setNodeSource(texture.audioSource);
this.el.setObject3D("sound", sound);
} catch (e) { } catch (e) {
console.error("Error loading video", this.data.src, e); console.error("Error loading video", this.data.src, e);
texture = errorTexture; texture = errorTexture;
......
...@@ -174,6 +174,8 @@ export default class SceneEntryManager { ...@@ -174,6 +174,8 @@ export default class SceneEntryManager {
orientation: or orientation: or
}); });
}); });
return entity;
}; };
this.scene.addEventListener("add_media", e => { this.scene.addEventListener("add_media", e => {
...@@ -186,6 +188,8 @@ export default class SceneEntryManager { ...@@ -186,6 +188,8 @@ export default class SceneEntryManager {
const el = e.detail.el; const el = e.detail.el;
const networkId = el.components.networked.data.networkId; const networkId = el.components.networked.data.networkId;
const gltfNode = pinnedEntityToGltf(el); const gltfNode = pinnedEntityToGltf(el);
if (!gltfNode) return;
el.setAttribute("networked", { persistent: true }); el.setAttribute("networked", { persistent: true });
this.hubChannel.pin(networkId, gltfNode); this.hubChannel.pin(networkId, gltfNode);
...@@ -235,26 +239,70 @@ export default class SceneEntryManager { ...@@ -235,26 +239,70 @@ export default class SceneEntryManager {
} }
}); });
this.scene.addEventListener("action_share_screen", async () => { let currentVideoShareEntity;
const constraints = { let isHandlingVideoShare = false;
const shareVideoMediaStream = async constraints => {
if (isHandlingVideoShare) return;
isHandlingVideoShare = true;
if (!currentVideoShareEntity) {
const newStream = await navigator.mediaDevices.getUserMedia(constraints);
const videoTracks = newStream ? newStream.getVideoTracks() : [];
if (videoTracks.length > 0) {
newStream.getVideoTracks().forEach(track => mediaStream.addTrack(track));
NAF.connection.adapter.setLocalMediaStream(mediaStream);
currentVideoShareEntity = spawnMediaInfrontOfPlayer(mediaStream, undefined);
}
} else {
currentVideoShareEntity.parentNode.removeChild(currentVideoShareEntity);
for (const track of mediaStream.getVideoTracks()) {
mediaStream.removeTrack(track);
}
NAF.connection.adapter.setLocalMediaStream(mediaStream);
currentVideoShareEntity = null;
}
isHandlingVideoShare = false;
};
this.scene.addEventListener("action_share_camera", () => {
shareVideoMediaStream({
video: { video: {
mediaSource: "screen", mediaSource: "camera",
width: 720,
frameRate: 30
}
});
});
this.scene.addEventListener("action_share_window", () => {
shareVideoMediaStream({
video: {
mediaSource: "window",
// Work around BMO 1449832 by calculating the width. This will break for multi monitors if you share anything // Work around BMO 1449832 by calculating the width. This will break for multi monitors if you share anything
// other than your current monitor that has a different aspect ratio. // other than your current monitor that has a different aspect ratio.
width: 720 * (screen.width / screen.height), width: 720 * (screen.width / screen.height),
height: 720, height: 720,
frameRate: 30 frameRate: 30
} }
}; });
});
const newStream = await navigator.mediaDevices.getUserMedia(constraints);
const videoTracks = newStream ? newStream.getVideoTracks() : [];
if (videoTracks.length > 0) { this.scene.addEventListener("action_share_screen", () => {
newStream.getVideoTracks().forEach(track => mediaStream.addTrack(track)); shareVideoMediaStream({
NAF.connection.adapter.setLocalMediaStream(mediaStream); video: {
spawnMediaInfrontOfPlayer(mediaStream, undefined); mediaSource: "screen",
} // Work around BMO 1449832 by calculating the width. This will break for multi monitors if you share anything
// other than your current monitor that has a different aspect ratio.
width: 720 * (screen.width / screen.height),
height: 720,
frameRate: 30
}
});
}); });
}; };
......
...@@ -20,7 +20,14 @@ export default function pinnedEntityToGltf(el) { ...@@ -20,7 +20,14 @@ export default function pinnedEntityToGltf(el) {
if (!equalArray(scale, [1, 1, 1])) gltfNode.scale = scale; if (!equalArray(scale, [1, 1, 1])) gltfNode.scale = scale;
if (components["media-loader"]) { if (components["media-loader"]) {
gltfComponents.media = { src: components["media-loader"].data.src, id: networkId }; const mediaSrc = components["media-loader"].data.src;
if (mediaSrc.startsWith("webrtc://")) {
// Do not persist webrtc media shares
return null;
}
gltfComponents.media = { src: mediaSrc, id: networkId };
if (components["media-pager"]) { if (components["media-pager"]) {
gltfComponents.media.pageIndex = components["media-pager"].data.index; gltfComponents.media.pageIndex = components["media-pager"].data.index;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment