@soffits/dsh-media-hub 0.15.0 → 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 +9 -0
- package/package.json +1 -1
- package/web/panel.css +3 -0
- package/web/picture-click.js +21 -0
- package/web/player.js +29 -3
- package/web/room-view.js +3 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
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
|
+
|
|
7
|
+
## 0.15.1
|
|
8
|
+
|
|
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.
|
|
10
|
+
- The <video>'s own full-screen button is gone where the browser allows it (Chrome, Edge, Android): the bar's button is the one that keeps the danmaku on the picture.
|
|
11
|
+
|
|
3
12
|
## 0.15.0
|
|
4
13
|
|
|
5
14
|
- Spending points moved to the points plugin, [@soffits/dsh-points](https://github.com/soffits/dsh-points): when an extra costs points, its dialog shows the price, your points and what's left, and buys it there. The hub's own offer bar is gone. Setup changes: install @soffits/dsh-points and move the ledger command from this plugin's `points.command` to its `command`; `points.night` is now `bingeNight`; `docs/points-protocol.md` is replaced by the points plugin's ledger protocol. The fetch and room routes no longer take `buy`.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@soffits/dsh-media-hub",
|
|
3
|
-
"version": "0.15.
|
|
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",
|
package/web/panel.css
CHANGED
|
@@ -369,6 +369,9 @@
|
|
|
369
369
|
.vsync-danmakuToggle[aria-checked=true]{color:var(--dsw-alias-state-business-primary);box-shadow:inset 0 0 0 var(--dsh-hairline-width,.5px) var(--dsw-alias-state-business-primary)}
|
|
370
370
|
.vsync-danmakuToggle[aria-checked=false]{color:var(--dsw-alias-label-tertiary)}
|
|
371
371
|
.vsync-popover{position:absolute;right:0;bottom:calc(100% + 6px);z-index:30;box-sizing:border-box;width:min(320px,calc(100vw - 24px));display:flex;flex-direction:column;gap:14px;padding:14px;border:.5px solid var(--dsw-alias-border-l2);border-radius:var(--dsw-radius-lg);background:var(--dsw-alias-bg-layer-1,var(--dsw-alias-bg-base));color:var(--dsw-alias-label-primary);box-shadow:var(--dsw-shadow-lv3)}
|
|
372
|
+
.vsync-playerBar .vsync-popover{max-height:min(480px,calc(100dvh - 160px));overflow-y:auto}
|
|
373
|
+
@media (width<=900px){.vsync-playerBar .vsync-popover{top:calc(100% + 6px);bottom:auto}}
|
|
374
|
+
.vsync-player:fullscreen .vsync-playerBar .vsync-popover,.vsync-player[data-covering=true] .vsync-playerBar .vsync-popover{top:auto;bottom:calc(100% + 6px)}
|
|
372
375
|
.vsync-setting{display:flex;flex-direction:column;gap:6px}
|
|
373
376
|
.vsync-settingLabel{color:var(--dsw-alias-label-secondary);font-size:12px;line-height:18px}
|
|
374
377
|
.vsync-settingChoices{display:flex;flex-wrap:wrap;gap:6px}
|
|
@@ -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
|
|
@@ -74,6 +75,8 @@ function createVideoPlayer(stage, events, { base, language, trackLabel }) {
|
|
|
74
75
|
el.className = 'vsync-media'
|
|
75
76
|
el.playsInline = true
|
|
76
77
|
el.preload = 'auto'
|
|
78
|
+
// Full screen is the player's box, with the danmaku over the picture (room-view.js); a bare <video> there hides them.
|
|
79
|
+
el.controlsList?.add('nofullscreen')
|
|
77
80
|
const front = () => el === video
|
|
78
81
|
const reports = () => front() && !priming
|
|
79
82
|
el.addEventListener('loadstart', () => progressAt.set(el, now()))
|
|
@@ -99,6 +102,29 @@ function createVideoPlayer(stage, events, { base, language, trackLabel }) {
|
|
|
99
102
|
if (expect.rate !== null && Math.abs(el.playbackRate - expect.rate) < 1e-6) return
|
|
100
103
|
events.onRate?.(el.playbackRate)
|
|
101
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
|
+
})
|
|
102
128
|
el.addEventListener('ended', () => { if (front()) events.onEnded?.() })
|
|
103
129
|
el.addEventListener('loadedmetadata', () => { if (front() && Number.isFinite(el.duration)) events.onDuration?.(el.duration) })
|
|
104
130
|
el.addEventListener('error', () => { if (front()) events.onError?.(el.error?.message || 'This video could not be played.') })
|
|
@@ -326,7 +352,7 @@ function tabClientId() {
|
|
|
326
352
|
* @param {(view: object) => void} options.onUpdate - connection, room, members, needsGesture, drift
|
|
327
353
|
* @param {(event: object) => void} options.onEvent - { kind: 'action', last } | { kind: 'joined' | 'left', name }
|
|
328
354
|
*/
|
|
329
|
-
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 }) {
|
|
330
356
|
const clientId = tabClientId()
|
|
331
357
|
const samples = []
|
|
332
358
|
let offset = null
|
|
@@ -564,7 +590,7 @@ export function joinRoom({ base, roomId, name, language = '', trackLabel = label
|
|
|
564
590
|
|
|
565
591
|
function ensurePlayer() {
|
|
566
592
|
if (player !== null) return player
|
|
567
|
-
player = createVideoPlayer(stage, events, { base, language, trackLabel })
|
|
593
|
+
player = createVideoPlayer(stage, events, { base, language, trackLabel, onFullScreen })
|
|
568
594
|
loadedIndex = null
|
|
569
595
|
return player
|
|
570
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))
|