diff options
Diffstat (limited to 'web')
-rw-r--r-- | web/script/player/player.ts | 6 | ||||
-rw-r--r-- | web/script/player/profiles.ts | 9 |
2 files changed, 10 insertions, 5 deletions
diff --git a/web/script/player/player.ts b/web/script/player/player.ts index 696fab2..cc778f0 100644 --- a/web/script/player/player.ts +++ b/web/script/player/player.ts @@ -80,10 +80,12 @@ export class Player { const metadata = await res.json() as JhlsMetadata this.set_pers() + this.profile_selector = new ProfileSelector(this, this.downloader.bandwidth, metadata) + this.set_pers("Checking codec support...") + await this.profile_selector.init() + this.duration.value = metadata.duration this.video.src = URL.createObjectURL(this.media_source) - this.profile_selector = new ProfileSelector(this, this.downloader.bandwidth, metadata) - this.media_source.addEventListener("sourceopen", async () => { this.set_pers("Initializing Media Extensions...") this.tracks.value.push(await PlayerTrack.new(this, this.node_id, 0, metadata.tracks[0])) diff --git a/web/script/player/profiles.ts b/web/script/player/profiles.ts index caa46bd..eef28c4 100644 --- a/web/script/player/profiles.ts +++ b/web/script/player/profiles.ts @@ -1,6 +1,6 @@ import { OVar } from "../jshelper/mod.ts"; import { EncodingProfile, JhlsMetadata } from "./jhls.d.ts"; -import { test_media_capability } from "./mediacaps.ts"; +import { profile_to_partial_track, test_media_capability } from "./mediacaps.ts"; import { Player } from "./player.ts"; const PROFILE_UP_FAC = 0.6 @@ -14,8 +14,11 @@ export class ProfileSelector { remux_bandwidth = new Map<number, { size: number, duration: number }>() constructor(private player: Player, private bandwidth: OVar<number>, private metadata: JhlsMetadata) { - for (let id = 0; id < metadata.extra_profiles.length; id++) { - const p = metadata.extra_profiles[id]; + } + async init() { + for (let id = 0; id < this.metadata.extra_profiles.length; id++) { + const p = this.metadata.extra_profiles[id]; + if (!await test_media_capability(profile_to_partial_track(p))) continue if (p.audio) this.profiles_audio.push({ id, order: 0, ...p }) if (p.video) this.profiles_video.push({ id, order: 0, ...p }) if (p.subtitles) this.profiles_subtitles.push({ id, order: 0, ...p }) |