Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
H
Hubs
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ar-noc
Hubs
Commits
2314f962
Commit
2314f962
authored
6 years ago
by
Greg Fodor
Browse files
Options
Downloads
Patches
Plain Diff
Fixes for firefox and pinning
parent
1db62c98
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/components/media-views.js
+8
-6
8 additions, 6 deletions
src/components/media-views.js
src/scene-entry-manager.js
+60
-12
60 additions, 12 deletions
src/scene-entry-manager.js
src/utils/pinned-entity-to-gltf.js
+8
-1
8 additions, 1 deletion
src/utils/pinned-entity-to-gltf.js
with
76 additions
and
19 deletions
src/components/media-views.js
+
8
−
6
View file @
2314f962
...
@@ -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
;
...
...
This diff is collapsed.
Click to expand it.
src/scene-entry-manager.js
+
60
−
12
View file @
2314f962
...
@@ -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
}
});
});
});
};
};
...
...
This diff is collapsed.
Click to expand it.
src/utils/pinned-entity-to-gltf.js
+
8
−
1
View file @
2314f962
...
@@ -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
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment