Closed jo-hnny closed 5 years ago
Hi @johnny19941216, looks like our
README
example was a bit out of date, so I've just opened a PR (#172) with an updated example (view here) and a working CodeSandbox demo (view demo).Please give those a try!
thank you very much, it's work,but on my project ,load very slow , so i delete the_load hook, load source in constructor, it's work better
import Hls from 'hls.js'
import VideoContext from 'videocontext'
export default class HLSNode extends VideoContext.NODES.VideoNode {
constructor(
src,
gl,
renderGraph,
currentTime,
sourceOffset,
preloadTime,
videoElementAttributes = {},
playbackRate = 1.0,
hlsOptions = {}
) {
const video = document.createElement('video')
super(
video,
gl,
renderGraph,
currentTime,
playbackRate,
sourceOffset,
preloadTime,
undefined,
videoElementAttributes
)
this.hls = new Hls(hlsOptions)
this.hls.attachMedia(video)
this.hls.loadSource(src)
this._displayName = 'HLSNode'
this._elementType = 'hls'
}
destroy() {
if (this.hls) {
this.hls.destroy()
}
super.destroy()
}
}
Great!
You could also try increasing the preloadTime
if your video isn't loading in time for playback. That would mean _load
is called earlier before playback.
Give us a shout if you have any questions
i'm defginition a HLSNode, but it's not work; hls-node.js
index.js