aboutsummaryrefslogtreecommitdiff
path: root/web/script/player/track
diff options
context:
space:
mode:
authormetamuffin <metamuffin@disroot.org>2025-04-16 00:09:35 +0200
committermetamuffin <metamuffin@disroot.org>2025-04-16 00:09:35 +0200
commit39dee6820db4581fa41cfac8bcfdd399a96f5319 (patch)
treec605156a6757e5623fae36635722758947e0db65 /web/script/player/track
parent50dc0e7bea02d7fc5b38edb7f943e19bd8c0285b (diff)
downloadjellything-39dee6820db4581fa41cfac8bcfdd399a96f5319.tar
jellything-39dee6820db4581fa41cfac8bcfdd399a96f5319.tar.bz2
jellything-39dee6820db4581fa41cfac8bcfdd399a96f5319.tar.zst
transcode impl but broken
Diffstat (limited to 'web/script/player/track')
-rw-r--r--web/script/player/track/mse.ts20
1 files changed, 16 insertions, 4 deletions
diff --git a/web/script/player/track/mse.ts b/web/script/player/track/mse.ts
index 9fa5e42..199aa14 100644
--- a/web/script/player/track/mse.ts
+++ b/web/script/player/track/mse.ts
@@ -4,7 +4,7 @@
Copyright (C) 2025 metamuffin <metamuffin.org>
*/
import { OVar } from "../../jshelper/mod.ts";
-import { track_to_content_type } from "../mediacaps.ts";
+import { test_media_capability, track_to_content_type } from "../mediacaps.ts";
import { BufferRange, Player } from "../player.ts";
import { PlayerTrack, AppendRange, TARGET_BUFFER_DURATION, MIN_BUFFER_DURATION } from "./mod.ts";
import { e } from "../../jshelper/src/element.ts";
@@ -49,7 +49,19 @@ export class MSEPlayerTrack extends PlayerTrack {
}
this.buffered.value = []
- this.active_format.value = { usable_index: 0, format_index: 0, container: "webm", format: this.trackinfo.formats[0] }
+ console.log(this.trackinfo);
+
+ for (let i = 0; i < this.trackinfo.formats.length; i++) {
+ const format = this.trackinfo.formats[i];
+ for (const container of format.containers) {
+ if (container != "webm" && container != "mpeg4") continue;
+ if (await test_media_capability(format, container))
+ this.usable_formats.push({ container, format, format_index: i, usable_index: this.usable_formats.length })
+ }
+ }
+ if (!this.usable_formats.length)
+ return this.player.logger?.log("No availble format is supported by this device. The track can't be played back.")
+ this.active_format.value = this.usable_formats[0]
const ct = track_to_content_type(this.active_format.value!.format, this.active_format.value!.container);
this.source_buffer = this.player.media_source.addSourceBuffer(ct);
@@ -142,8 +154,8 @@ export class MSEPlayerTrack extends PlayerTrack {
this.current_load = frag;
// TODO why is appending so unreliable?! sometimes it does not add it
this.source_buffer.changeType(track_to_content_type(this.active_format.value!.format, this.active_format.value!.container));
- this.source_buffer.timestampOffset = 0 // TODO send if relative PTS //this.active_format.value !== undefined ? frag.start : 0
- console.log(`append track ${this.track_index}`);
+ this.source_buffer.timestampOffset = this.active_format.value?.format.remux ? 0 : frag.start
+ console.log(`append track at ${this.source_buffer.timestampOffset} ${this.trackinfo.kind} ${this.track_index}`);
this.source_buffer.appendBuffer(frag.buf);
}
}