Skip to content

#feat: Sunbird content player v2 <react.js and vite> - #537

Open
JeraldJF wants to merge 5 commits into
Sunbird-Knowlg:masterfrom
JeraldJF:new-player
Open

#feat: Sunbird content player v2 <react.js and vite>#537
JeraldJF wants to merge 5 commits into
Sunbird-Knowlg:masterfrom
JeraldJF:new-player

Conversation

@JeraldJF

@JeraldJF JeraldJF commented Jul 1, 2026

Copy link
Copy Markdown
Collaborator

Content Player v2 — unified React plugin-registry player

Summary

Introduces @project-sunbird/content-player-v2: a single React + TypeScript
library that plays every Sunbird content type through one plugin-registry shell,
replacing the per-format web-component players. One mount point, one Telemetry v3
pipeline, one responsive theme, and a zero-React mount()/init() API for
vanilla-JS/web-component hosts.

Supports: ECML (questions + slides), PDF, EPUB, Video (mp4/webm), Audio (mp3),
YouTube, and HTML/H5P/SCORM — with a graceful fallback for unknown MIME types.

Renderer decisions

Content type Renderer Notes
Video (mp4/webm/audio) video.js (v8) Custom controls overlay; video.js manages playback, HLS-ready via @videojs/http-streaming
YouTube YouTube IFrame API (youtube.com/iframe_api) Loaded dynamically; SDK converts a <div> into the iframe
PDF PDF.js (pdfjsLib) Canvas-based; loaded from bundled assets (mobile) or CDN fallback
ePub epub.js + JSZip Loaded dynamically; renders via rendition API into a div
H5P / HTML / SCORM <iframe> H5P uses srcdoc (same-origin trick); HTML/SCORM use src
ECML Custom React renderer Fully in-house; no third-party player

What's included

  • Plugin architecturePluginRegistry (MIME → plugin), PluginRenderer,
    ContentPluginProps/ContentPluginRef contract; hosts can register custom plugins.
  • PluginsEcmlPlugin, PdfPlugin, EpubPlugin, VideoPlugin,
    YoutubePlugin, HtmlPlugin (SCORM via scorm-again), GenericPlugin (fallback).
  • ECML engine — parser, QuestionSet + review + assessment summary, 6 question
    types (MCQ/True-False/FTB/MTF/Sequence/Reorder), pointer-drag interactions,
    slide/stage renderer.
  • TelemetryTelemetryService (v3, batched); START/END/INTERACT/IMPRESSION/ ASSESS/ERROR/HEARTBEAT. END only on real completion; replay/exit emit INTERACT.
  • ServicesContentCursor contract + ContentService default (fetch + normalize).
  • Screens — Loading (with %), Start, Playing, End.
  • i18n + RTLt()/getDir() across shell and all plugins; en/hi/ta/ar/fr/pt.
  • Theme — Sunbird Spark tokens + player.css.
  • Tooling — Vite library build (ES/UMD + d.ts), ESLint, Vitest, CI workflow.

Changes in this revision

  • feat: PDF/EPUB Download menu item, gated by config.downloadContent
    (default true); blob-based download reliable for cross-origin URLs.
  • fix: ECML replay from the shell EndScreen (slides/resources) — EcmlPlugin.replay()
    now re-fires onReady so the shell returns to playing (matches PDF/EPUB/Video).
  • fix: ECML slide nav arrows moved to vertically-centered left/right (was a
    bottom pill), matching the questions layout; page indicator kept at bottom.
  • fix: assessment scoring — emit an ASSESS per every question on submit
    (was per-interaction only, so uncommitted/skipped questions produced no event and
    the collection Best-Score total came out as x/0).
  • refactor: rename unsupported/UnsupportedPlugingeneric/GenericPlugin.
  • feat: full i18n + RTL wiring across all plugins (previously shell-only).
  • chore: add Vitest + tests (i18n, ContentService, TelemetryService, screens,
    registry, plugin definitions, generic plugin — 38 tests).
  • chore: add ESLint config (none existed — npm run lint failed on all files).
  • chore: add player-v2.yml CI (lint+test+build on push/PR; npm publish on
    player-v2-v* tag; no blob publish).
  • chore: strip EPUB debug console.logs; .gitignore .DS_Store.

@JeraldJF
JeraldJF marked this pull request as ready for review July 2, 2026 05:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant