@soffits/dsh-media-hub 0.10.0 → 0.10.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,10 +1,20 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.10.2
4
+
5
+ - hls.js now loads. The page asked for it at the wrong address, so a browser that needed it (any Chromium one, since 0.10.1) never got past loading. Episodes that are still being made play there again.
6
+
7
+ ## 0.10.1
8
+
9
+ - Replaying an episode that has to be transcoded now plays in Chrome, Brave and Edge. Their own HLS player can't take an episode that's still being made and stopped with "could not parse"; the page now uses hls.js there. Safari and iPhone keep their own player.
10
+
3
11
  ## 0.10.0
4
12
 
5
13
  - Discover shows something before you search. Under the picked source and category it lists what the source itself puts forward (a source's rank lists and new arrivals, from the new optional `trending` verb of [docs/source-protocol.md](docs/source-protocol.md), asked for the kinds configured with `"trending": true`) and, when a `recommender` is set, *For you*: picks with the reason for each, narrowed to the source and category (the recommender now also gets `--source`, `--kind` and `--language`). Under *All sources* the picks are interleaved and each source's lists stay under its name. Link has neither.
6
14
  - Both are dated local copies, rendered at once and asked again in the background when someone looks and the copy is about a day old (a failing source is left alone for an hour, the old copy stays), so the page never waits on a site. The Watching tab's picks use the same copies instead of waiting for the recommender.
7
15
  - The default sources declare trending for Fanqie's dramas, audiobooks and novels and for bookfetch's ebooks. A source whose command lacks the verb just shows no lists.
16
+
17
+
8
18
  ## 0.9.0
9
19
 
10
20
  - Points extras (`points` setting, [docs/points-protocol.md](docs/points-protocol.md)): with a points extension, the people it plays with pay points for starting a series that is new to the hub and for a binge night (starting to watch late at night, one ticket for the whole night). The page shows the price and their balance at that moment and buys on *Buy*; going on with a series, later seasons, films, single videos and rooms already playing stay free. Without an extension, or for anyone it doesn't play with, nothing changes.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@soffits/dsh-media-hub",
3
- "version": "0.10.0",
3
+ "version": "0.10.2",
4
4
  "description": "A media hub for DeepSeek Harness: search shows, novels, ebooks and papers across sources, watch together in sync, and download books in the format you want onto your own shelf.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Which engine plays an HLS item: the browser's own, or hls.js. Native HLS is kept for WebKit, whose player takes
3
+ * the growing playlists of an episode still being made; Chromium-based browsers answer "maybe" to HLS too since
4
+ * their own player arrived, but it fails a playlist without an end (DEMUXER_ERROR_COULD_NOT_PARSE), so they get
5
+ * hls.js. A browser without Media Source cannot run hls.js and uses native HLS when it has it.
6
+ * @param {{ canPlayType: (type: string) => string }} video
7
+ * @param {{ webkit?: boolean, mse?: boolean }} [env]
8
+ */
9
+ export function playsHlsNatively(video, {
10
+ webkit = typeof HTMLVideoElement !== 'undefined' && 'webkitSupportsPresentationMode' in HTMLVideoElement.prototype,
11
+ mse = typeof MediaSource !== 'undefined' || typeof ManagedMediaSource !== 'undefined',
12
+ } = {}) {
13
+ if (video.canPlayType('application/vnd.apple.mpegurl') === '') return false
14
+ return webkit || !mse
15
+ }
package/web/player.js CHANGED
@@ -14,6 +14,7 @@
14
14
  */
15
15
  import { DRIFT, clockOffset, correction, expectedPosition, preloadDue } from './sync.js'
16
16
  import { canStart, offerTap, shouldPrime } from './readiness.js'
17
+ import { playsHlsNatively } from './hls-engine.js'
17
18
  import { defaultCaption, parseCaption } from './captions.js'
18
19
 
19
20
  /** Reconcile the player with the room this often. */
@@ -50,7 +51,7 @@ const PRIME_LIMIT_MS = 5000
50
51
  */
51
52
  const swapKeepsPlayPermission = () => !('webkitSupportsPresentationMode' in HTMLVideoElement.prototype)
52
53
 
53
- /** An HTML <video> as a media hub player, with hls.js where the browser has no native HLS. */
54
+ /** An HTML <video> as a media hub player, with hls.js where the browser's own HLS is not the one to use (web/hls-engine.js). */
54
55
  function createVideoPlayer(stage, events, { base, language, trackLabel }) {
55
56
  let video = null
56
57
  let hls = null
@@ -137,7 +138,7 @@ function createVideoPlayer(stage, events, { base, language, trackLabel }) {
137
138
 
138
139
  /** A playlist that may still grow (an episode being fetched) starts where the room is, not at its newest segment. */
139
140
  async function attachHls(url, startAt) {
140
- const { default: Hls } = await import(new URL('hls.mjs', base).href)
141
+ const { default: Hls } = await import(new URL('./hls.mjs', import.meta.url).href)
141
142
  if (!Hls.isSupported()) throw new Error('This browser cannot play HLS.')
142
143
  hls = new Hls({ startPosition: startAt })
143
144
  hls.loadSource(url)
@@ -215,7 +216,7 @@ function createVideoPlayer(stage, events, { base, language, trackLabel }) {
215
216
  preload(item) {
216
217
  const url = absolute(item)
217
218
  if (next?.url === url || url === src || !swapKeepsPlayPermission()) return
218
- if (item.kind === 'hls' && video.canPlayType('application/vnd.apple.mpegurl') === '') return
219
+ if (item.kind === 'hls' && !playsHlsNatively(video)) return
219
220
  dropNext()
220
221
  const el = makeVideo()
221
222
  el.className = 'vsync-preload'
@@ -238,7 +239,7 @@ function createVideoPlayer(stage, events, { base, language, trackLabel }) {
238
239
  if (usable) return swapIn(startAt)
239
240
  dropNext()
240
241
  addTracks(video, item)
241
- if (item.kind === 'hls' && video.canPlayType('application/vnd.apple.mpegurl') === '') {
242
+ if (item.kind === 'hls' && !playsHlsNatively(video)) {
242
243
  attachHls(url, startAt).catch(error => events.onError?.(error.message))
243
244
  } else {
244
245
  video.src = url