Skip to content

Instantly share code, notes, and snippets.

@Utopiah
Created June 8, 2020 09:47
Show Gist options
  • Save Utopiah/c3927fd16c93fc919a74036325faacd4 to your computer and use it in GitHub Desktop.
Save Utopiah/c3927fd16c93fc919a74036325faacd4 to your computer and use it in GitHub Desktop.
var hubsProxy = "https://hubs-spatializedinternal-link-cors-proxy.vrtohubs.workers.dev/"
var playlist = [
"https://vrtovideostreaming.s3.us-east-2.amazonaws.com/Accessibility/CC+John+Avila+-+Designing+Accessible+Experiences+for+VR+and+AR+720p.mp4",
"https://vrtovideostreaming.s3.us-east-2.amazonaws.com/Accessibility/CC+VRTO2020+Wishplay+and+VR+-+David+Parker+-+Final.mp4"
]
var currentVideo = 0
function videoEnded(){
console.log('video ended')
if (currentVideo == playlist.length-1 ) {
currentVideo = 0; nextVideoSrc = playlist[currentVideo]
} else {
nextVideoSrc = playlist[++currentVideo]
}
vid.setAttribute("media-video", {src: hubsProxy+nextVideoSrc} )
console.log("playing next video of playlist", nextVideoSrc)
//vid.components["media-video"].video.play()
}
var vid = document.createElement("a-entity")
// from https://gist.github.com/Utopiah/1cfc123239fa2994569fc7c5c60b2928/
AFRAME.scenes[0].appendChild(vid)
vid.setAttribute("media-loader", { src: hubsProxy+playlist[currentVideo], fitToBox: true, resolve: true })
vid.setAttribute("networked", { template: "#interactable-media" } )
vid.object3D.scale.setScalar(10)
vid.object3D.position.z = -35
vid.components["media-video"].video.loop = false
vid.components["media-video"].video.addEventListener("ended", videoEnded)
// testing with the end of the video -1 second
vid.components["media-video"].video.currentTime = vid.components["media-video"].video.duration - 1
vid.components["media-video"].video.play()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment