@soffits/dsh-media-hub 0.15.1 → 0.15.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,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.15.2
4
+
5
+ - A click on the picture plays or pauses, for everyone in the room, and a double click goes full screen with the danmaku. On a phone the first tap still shows the controls.
6
+
3
7
  ## 0.15.1
4
8
 
5
9
  - On a phone the player's settings open under the player bar and scroll when they are taller than the screen; above it they ran under the page's header.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@soffits/dsh-media-hub",
3
- "version": "0.15.1",
3
+ "version": "0.15.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,21 @@
1
+ /**
2
+ * What a press on the picture does, as players have it: a mouse click plays
3
+ * or pauses, a double click goes full screen, and a tap leaves it to the
4
+ * browser (its first tap shows the controls). Presses on the browser's own
5
+ * control bar along the bottom are its own. Pure.
6
+ */
7
+
8
+ /** How tall the browser's control bar is at most, from the bottom of the picture (CSS pixels). */
9
+ export const CONTROLS_HEIGHT = 56
10
+ /** How long a click waits to see whether it is the first half of a double click. */
11
+ export const DOUBLE_CLICK_MS = 250
12
+
13
+ /**
14
+ * @param {{ pointerType: string, y: number, height: number, toggledByBrowser: boolean }} press - `y` from the
15
+ * picture's top; `toggledByBrowser`: the element already changed between playing and paused for this press
16
+ * @returns {'toggle' | 'none'}
17
+ */
18
+ export function pictureClick({ pointerType, y, height, toggledByBrowser }) {
19
+ if (pointerType !== 'mouse' || toggledByBrowser) return 'none'
20
+ return y < height - CONTROLS_HEIGHT ? 'toggle' : 'none'
21
+ }
package/web/player.js CHANGED
@@ -16,6 +16,7 @@ import { DRIFT, clockOffset, correction, expectedPosition, preloadDue } from './
16
16
  import { canStart, offerTap, shouldPrime } from './readiness.js'
17
17
  import { playsHlsNatively } from './hls-engine.js'
18
18
  import { defaultCaption, parseCaption } from './captions.js'
19
+ import { DOUBLE_CLICK_MS, pictureClick } from './picture-click.js'
19
20
 
20
21
  /** Reconcile the player with the room this often. */
21
22
  const TICK_MS = 500
@@ -52,7 +53,7 @@ const PRIME_LIMIT_MS = 5000
52
53
  const swapKeepsPlayPermission = () => !('webkitSupportsPresentationMode' in HTMLVideoElement.prototype)
53
54
 
54
55
  /** 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). */
55
- function createVideoPlayer(stage, events, { base, language, trackLabel }) {
56
+ function createVideoPlayer(stage, events, { base, language, trackLabel, onFullScreen }) {
56
57
  let video = null
57
58
  let hls = null
58
59
  let src = null
@@ -101,6 +102,29 @@ function createVideoPlayer(stage, events, { base, language, trackLabel }) {
101
102
  if (expect.rate !== null && Math.abs(el.playbackRate - expect.rate) < 1e-6) return
102
103
  events.onRate?.(el.playbackRate)
103
104
  })
105
+ // A click on the picture plays or pauses (through the element, so the room hears it like any play or pause),
106
+ // a double click goes full screen; the browser keeps taps and its own control bar.
107
+ let press = null
108
+ let clickTimer = null
109
+ el.addEventListener('pointerdown', (event) => { press = { pointerType: event.pointerType, paused: el.paused } })
110
+ el.addEventListener('click', (event) => {
111
+ if (!front() || press === null) return
112
+ const pressed = press
113
+ const y = event.clientY - el.getBoundingClientRect().top
114
+ clearTimeout(clickTimer)
115
+ clickTimer = setTimeout(() => {
116
+ if (pictureClick({ pointerType: pressed.pointerType, y, height: el.clientHeight, toggledByBrowser: el.paused !== pressed.paused }) === 'toggle') {
117
+ if (el.paused) Promise.resolve(el.play()).catch(() => {})
118
+ else el.pause()
119
+ }
120
+ }, DOUBLE_CLICK_MS)
121
+ })
122
+ el.addEventListener('dblclick', (event) => {
123
+ if (!front() || press?.pointerType !== 'mouse') return
124
+ clearTimeout(clickTimer)
125
+ event.preventDefault()
126
+ onFullScreen?.()
127
+ })
104
128
  el.addEventListener('ended', () => { if (front()) events.onEnded?.() })
105
129
  el.addEventListener('loadedmetadata', () => { if (front() && Number.isFinite(el.duration)) events.onDuration?.(el.duration) })
106
130
  el.addEventListener('error', () => { if (front()) events.onError?.(el.error?.message || 'This video could not be played.') })
@@ -328,7 +352,7 @@ function tabClientId() {
328
352
  * @param {(view: object) => void} options.onUpdate - connection, room, members, needsGesture, drift
329
353
  * @param {(event: object) => void} options.onEvent - { kind: 'action', last } | { kind: 'joined' | 'left', name }
330
354
  */
331
- export function joinRoom({ base, roomId, name, language = '', trackLabel = label => label, stage, onUpdate, onEvent }) {
355
+ export function joinRoom({ base, roomId, name, language = '', trackLabel = label => label, stage, onUpdate, onEvent, onFullScreen }) {
332
356
  const clientId = tabClientId()
333
357
  const samples = []
334
358
  let offset = null
@@ -566,7 +590,7 @@ export function joinRoom({ base, roomId, name, language = '', trackLabel = label
566
590
 
567
591
  function ensurePlayer() {
568
592
  if (player !== null) return player
569
- player = createVideoPlayer(stage, events, { base, language, trackLabel })
593
+ player = createVideoPlayer(stage, events, { base, language, trackLabel, onFullScreen })
570
594
  loadedIndex = null
571
595
  return player
572
596
  }
package/web/room-view.js CHANGED
@@ -78,6 +78,8 @@ export function RoomView({ t, roomId, onLeave, onOpen }) {
78
78
  const [danmaku, setDanmaku] = React.useState({ index: null, items: NO_DANMAKU })
79
79
  const [qualityBusy, setQualityBusy] = React.useState(false)
80
80
  const screen = useFullScreen(playerBox)
81
+ const toggleFull = React.useRef(screen.toggle)
82
+ toggleFull.current = screen.toggle
81
83
  const session = React.useRef(null)
82
84
  const [view, setView] = React.useState({ connection: 'connecting', room: null, members: [], needsGesture: false })
83
85
  const [toasts, setToasts] = React.useState([])
@@ -107,6 +109,7 @@ export function RoomView({ t, roomId, onLeave, onOpen }) {
107
109
  stage: stage.current,
108
110
  onUpdate: setView,
109
111
  onEvent: event => toast(toastText(t, event)),
112
+ onFullScreen: () => toggleFull.current(),
110
113
  })
111
114
  }
112
115
  start().catch(error => toast(error.message))