cg-media-viewer
A DeepSeek Harness plugin that plays video and audio inside the right sidebar, including the
file tree of dsh-better-sidebar.
The problem it solves
The right sidebar has two different preview paths, and each one keeps its own viewer registry:
| Where you open the file | Who renders it | Video/audio |
|---|---|---|
| Built-in Files tab | ctx.documentPreviews (video / audio renderers) |
works while dsh-media-web-preview is active |
| dsh-better-sidebar file tree | its own ctx.betterSidebar registry |
fell through to binary-download: "no preview, download" |
dsh-better-sidebar never consults documentPreviews (zero references in its bundle), so turning
dsh-media-web-preview on or off changes nothing in its tree. What was missing were viewers
registered in its registry.
What it does
Registers two file viewers in ctx.betterSidebar:
| Viewer | Extensions |
|---|---|
cg-media:video |
mp4 m4v webm ogv mov mkv avi mpg mpeg 3gp 3g2 m2ts |
cg-media:audio |
mp3 m4a m4b aac wav flac ogg oga opus weba |
- Native browser player (
<video>/<audio>) with controls, seek, volume and fullscreen. - Real seek when the bytes come from a route that honours
Range: the viewer asksGET /api/media?path=<absolute path>(the Host half ofdsh-media-web-preview), which answers206 Partial ContentwithContent-Range. Seeking does not download the whole file. - Honest fallback with no ranges. When the only available source is the
mediaUrlthat thedsh-better-sidebarhost already computes (/sidebar/file, whole file, no ranges), the viewer says so: the footer shows "No seek: the server does not support byte ranges, so the whole file is downloaded", the element starts withpreload="none", and Download becomes the primary action. It does not pretend the two modes are equivalent. - Errors told apart.
MediaError.code2 (network) and 3 (decode) show a network notice with a Retry button; code 4 (format not supported) shows the format notice; code 1 (aborted, i.e. the page or the user cancelled the load) is not treated as a failure. - Footer with the tab title, the size when the host reports it, Download and Open in new tab.
- When the harness exposes its
localeservice, the UI follows the active language (English and Spanish dictionaries); otherwise it stays in English.
mkv and avi are claimed because the file still deserves a player, but Chromium usually cannot
decode them: there the viewer shows the format notice and leaves the download. That call belongs to
the browser, not to the plugin.
Deliberately not claimed:
ts: in a coding harness a.tsfile is almost always TypeScript. Claiming it as MPEG-TS video would replace the code view with a broken player.aiff,aif,wma,mid,midi: Chromium does not decode them, so claiming them only swaps a download panel that works for a notice that does not.
Requirements
- DeepSeek Harness
>=0.2.1-rc.2 <0.3.0-0. dsh-better-sidebar>=0.28.0. Third-party and an optional peer dependency: without it this bundle still loads and simply stays inert (there is no registry to register into), and nothing in the harness breaks.- For ranged seeking, a route that answers
Rangeonapi/media: that isdsh-media-web-preview, the Host half that owns/api/media. Without it, playback still works through the hostmediaUrl, without seek.
Install
From npm:
npm install cg-media-viewer
Then, inside DSH:
plugin_manager action=install_bundle target=cg-media-viewer
Refresh the page once so the client bundle enters the module graph. To remove it:
plugin_manager action=remove_bundle target=cg-media-viewer
From a repository checkout (development):
git clone https://github.com/DonGeeo87/cg-media-viewer.git
plugin_manager action=install_bundle target=<path to the cg-media-viewer directory>
With a link: install, editing lib/client.js is enough for the next load; if the browser already
had the old module, restart DSH.
How to tell it is alive
- Settings > Side: the viewer inventory lists Video and Audio with the play triangle and their switches.
- Open an MP4 from the sidebar tree: the panel shows a
<video>with controls instead of the download button. - The root node of the player carries
data-cg-media="video"(or"audio").
Verification
node --check lib/client.js
node --check lib/index.js
node --test
The suite (test/client.test.mjs) loads the real lib/client.js with a fake window loader and a
minimal React, and checks: both viewers register with fetchStrategy: 'mediaUrl' and priority 100;
the claimed extension lists contain no ts, aiff, aif, wma, mid or midi; one effect
registers both viewers and returns both disposers; a viewer id already taken does not prevent the
other from registering; the no-range footer notice, preload="none" and primary download; the
MediaError classification with Retry; the two-step fallback from /api/media to mediaUrl; the
tab title coming from props.title; and the locale path (dictionaries registered, active language
used, English fallback when the service throws).
Known limits
- The Host half registers no routes: it reuses
/api/media. Ifdsh-media-web-previewis removed, everything keeps working through the fallback, without seek. - The size is shown only when the host reports it. With
fetchStrategy: 'mediaUrl'the host does not measure the file, so the footer normally shows just the title (no extra HEAD request per open). - No subtitle tracks, playlists or playback rate: it is the browser's player.
- A missing file that also fails on the host route is reported by Chromium as
MEDIA_ERR_SRC_NOT_SUPPORTED(code 4), so it surfaces as the format notice; Retry is still offered for transient cases.
Where it lives
| Where | Identifier |
|---|---|
| npm | cg-media-viewer |
| GitHub | https://github.com/DonGeeo87/cg-media-viewer (MIT) |
License
MIT.
Español
Plugin de DeepSeek Harness que reproduce video y audio dentro del sidebar derecho, también desde
el árbol de archivos de dsh-better-sidebar.
El sidebar derecho tiene dos caminos de vista previa y cada uno lleva su propio registro de viewers.
La pestaña Files de fábrica usa ctx.documentPreviews (los renderers video / audio de
dsh-media-web-preview), pero el árbol de dsh-better-sidebar usa su propio registro y no consulta
ese servicio: por eso un MP4 abierto desde ahí caía en su panel de descarga. Este bundle registra
cg-media:video y cg-media:audio en ctx.betterSidebar y llena ese hueco.
- Reproductor nativo del navegador, con controles, seek, volumen y pantalla completa.
- Seek real cuando los bytes vienen de una ruta que respeta
Range(GET /api/media?path=<ruta absoluta>, la mitad Host dedsh-media-web-preview, que responde206 Partial Content). - Respaldo honesto: si el único origen disponible es el
mediaUrldel host (/sidebar/file, archivo completo, sin rangos), el pie lo dice, el elemento arranca conpreload="none"y Descargar pasa a ser la acción principal. No se presenta como equivalente. - Errores diferenciados:
MediaError.code2 (red) y 3 (decodificación) muestran el aviso de red con Reintentar; el código 4 (formato no soportado) muestra el aviso de formato; el código 1 (abortado) no se trata como falla. - El pie muestra el título de la pestaña, el tamaño cuando el host lo informa, Descargar y Abrir en pestaña nueva.
- Si el harness expone su servicio
locale, la interfaz sigue el idioma activo (diccionarios en inglés y español); si no, queda en inglés.
A propósito no reclama ts (en un harness de código un .ts es TypeScript), ni aiff, aif,
wma, mid ni midi (Chromium no los decodifica: reclamarlos cambia un panel de descarga que
funciona por un aviso que no).
Requisitos: DeepSeek Harness >=0.2.1-rc.2 <0.3.0-0; dsh-better-sidebar
>=0.28.0 como peer opcional (sin él el bundle queda inerte y nada se rompe); y
dsh-media-web-preview si se quiere seek por rangos.
Instalar: npm install cg-media-viewer y después
plugin_manager action=install_bundle target=cg-media-viewer; refresca la página una vez. Desde un
clon del repositorio se instala igual apuntando target a la carpeta. Se quita con
plugin_manager action=remove_bundle target=cg-media-viewer.
Verificar: node --check lib/client.js, node --check lib/index.js y node --test (19 pruebas).
Límites: el tamaño aparece solo si el host lo informa (con fetchStrategy: 'mediaUrl' no lo
mide); sin dsh-media-web-preview todo funciona por el respaldo, sin seek; no hay subtítulos,
listas de reproducción ni velocidad, es el reproductor del navegador.
Licencia MIT.
No comments yet. Be the first to write one.