@kodezen/player 1.0.0

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Kodezen
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,89 @@
1
+ # @kodezen/player
2
+
3
+ A small, framework-agnostic media player core with a custom control bar.
4
+
5
+ **Tracking-free by design.** The library plays media, renders controls, emits
6
+ progress events, and accepts a resume position. It never persists anything and
7
+ knows nothing about WordPress, courses, or completion — the host wires progress
8
+ saving, resume, and completion gating on top of its events. That keeps it
9
+ reusable and makes it a clean seam for a future analytics/verification layer.
10
+
11
+ ## Status
12
+
13
+ Phase 1: `html5` (self-hosted / external mp4 & webm) + control bar + React
14
+ adapter. `youtube` and `vimeo` providers implement the same `Provider`
15
+ interface and land in Phase 2 — nothing else changes when they are added.
16
+
17
+ ## Install
18
+
19
+ ```bash
20
+ npm install @kodezen/player
21
+ ```
22
+
23
+ During local development against this repo directly (before a version is
24
+ published), it can also be consumed from disk (e.g. a webpack alias to
25
+ `dist/`):
26
+
27
+ ```bash
28
+ npm install
29
+ npm run build
30
+ ```
31
+
32
+ ## Vanilla usage
33
+
34
+ ```js
35
+ import { createPlayer } from '@kodezen/player';
36
+ import '@kodezen/player/styles.css';
37
+
38
+ const player = createPlayer(document.getElementById('mount'), {
39
+ source: { type: 'html5', url: 'https://example.com/lesson.mp4' },
40
+ resumeAt: 312, // seconds — host supplies from its own store
41
+ lockSeek: true, // block seeking past the furthest watched point
42
+ speeds: [1, 1.25, 1.5, 2],
43
+ });
44
+
45
+ player.on('timeupdate', ({ current, furthest, duration, percent }) => {
46
+ // Host saves this (throttled) to its own backend.
47
+ });
48
+ player.on('ended', () => {/* host may auto-complete */});
49
+
50
+ // player.play() / pause() / seek(s) / getState() / destroy()
51
+ ```
52
+
53
+ ## React usage
54
+
55
+ ```tsx
56
+ import { KodezenPlayer } from '@kodezen/player/react';
57
+ import '@kodezen/player/styles.css';
58
+
59
+ <KodezenPlayer
60
+ source={{ type: 'html5', url: lessonUrl }}
61
+ resumeAt={savedPosition}
62
+ lockSeek={gatingEnabled}
63
+ onTimeUpdate={({ percent, current }) => saveProgress(percent, current)}
64
+ onEnded={() => maybeComplete()}
65
+ />
66
+ ```
67
+
68
+ ## API
69
+
70
+ `createPlayer(container, options)` → instance.
71
+
72
+ **Options:** `source {type,url,id,poster,mime}`, `resumeAt`, `lockSeek`,
73
+ `autoplay`, `muted`, `speeds[]`, `controls{}`, `className`.
74
+
75
+ **Instance:** `play()`, `pause()`, `toggle()`, `seek(s)`, `getState()`,
76
+ `on(event, cb)`, `off(event, cb)`, `destroy()`.
77
+
78
+ **Events:** `ready`, `play`, `pause`, `timeupdate`, `durationchange`, `ended`,
79
+ `error`. `timeupdate` payload: `{ current, furthest, duration, percent }`
80
+ (`percent` = furthest / duration, so it reflects watched coverage, not the
81
+ scrub position).
82
+
83
+ ## Host integration notes
84
+
85
+ - **Resume** = pass `resumeAt`; player seeks on `ready` unless within 2s of end.
86
+ - **Watch gate** = enable `lockSeek` and read `percent` from `timeupdate`; the
87
+ furthest-position measure is only honest while seeking is locked.
88
+ - **Completion** = the host decides (e.g. auto-complete at a threshold or on
89
+ `ended`); the library stays out of it.