feat: adaptive bitrate support, engine improvements, demo updates, and electron preload
This commit is contained in:
@@ -12,6 +12,7 @@ export class VideoManager {
|
||||
private preloaded: Map<'A' | 'B', string> = new Map()
|
||||
private switching = false
|
||||
private sceneVideo: HTMLVideoElement | null = null
|
||||
streamingQuality = ''
|
||||
|
||||
private get active(): HTMLVideoElement {
|
||||
return this.activeSlot === 'A' ? this.elA! : this.elB!
|
||||
@@ -169,6 +170,30 @@ export class VideoManager {
|
||||
if (this.elB) this.elB.muted = muted
|
||||
}
|
||||
|
||||
resolveVideoUrl(scene: { videoUrl: string; streamingUrl?: Record<string, string> }, quality?: string): string {
|
||||
const isElectron = typeof window !== 'undefined' && !!(window as any).__ELECTRON__
|
||||
if (!isElectron && scene.streamingUrl) {
|
||||
const key = quality || Object.keys(scene.streamingUrl)[0]
|
||||
return scene.streamingUrl[key] || scene.videoUrl
|
||||
}
|
||||
return scene.videoUrl
|
||||
}
|
||||
|
||||
switchQuality(src: string, seekTime: number) {
|
||||
const active = this.active
|
||||
this.currentSrc = src
|
||||
active.src = src
|
||||
this.preloaded.set(this.keyOf(active), src)
|
||||
this.waitReady(active).then(() => {
|
||||
active.currentTime = seekTime
|
||||
active.play().catch(() => {})
|
||||
})
|
||||
}
|
||||
|
||||
private keyOf(el: HTMLVideoElement): 'A' | 'B' {
|
||||
return el === this.elA ? 'A' : 'B'
|
||||
}
|
||||
|
||||
onEnd(cb: VideoEndCallback) {
|
||||
this.onEndCallback = cb
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user