@openplayerjs/core 3.3.0 → 3.4.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/README.md +9 -9
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# @
|
|
1
|
+
# @openplayerjs/core
|
|
2
2
|
|
|
3
3
|
> Core player engine, plugin system, event bus, and public API for [OpenPlayerJS](https://openplayerjs.com).
|
|
4
4
|
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
## Installation
|
|
12
12
|
|
|
13
13
|
```bash
|
|
14
|
-
npm install @
|
|
14
|
+
npm install @openplayerjs/core
|
|
15
15
|
```
|
|
16
16
|
|
|
17
17
|
### Constructor
|
|
@@ -50,7 +50,7 @@ new Core(media: HTMLMediaElement | string, config?: PlayerConfig)
|
|
|
50
50
|
## Quick start
|
|
51
51
|
|
|
52
52
|
```ts
|
|
53
|
-
import { Core } from '@
|
|
53
|
+
import { Core } from '@openplayerjs/core';
|
|
54
54
|
|
|
55
55
|
const video = document.querySelector<HTMLVideoElement>('#player')!;
|
|
56
56
|
|
|
@@ -124,7 +124,7 @@ Pass options as the second argument to `new Core(...)`:
|
|
|
124
124
|
|
|
125
125
|
## Adding captions at runtime
|
|
126
126
|
|
|
127
|
-
Use `core.addCaptions(...)` from `@
|
|
127
|
+
Use `core.addCaptions(...)` from `@openplayerjs/core` to inject subtitle tracks after the player is already running (this is the preferred approach for single-page applications):
|
|
128
128
|
|
|
129
129
|
```ts
|
|
130
130
|
core.addCaptions({
|
|
@@ -189,7 +189,7 @@ core.on('error', (err) => console.error('media error', err));
|
|
|
189
189
|
A plugin is a class (or plain object) that implements `PlayerPlugin`. It receives a `PluginContext` in `setup()` and can subscribe to events, manipulate the media element, or register cleanup callbacks. Plugins have access to the player instance, the event bus, the media element, and a disposable store for automatic cleanup.
|
|
190
190
|
|
|
191
191
|
```ts
|
|
192
|
-
import type { PlayerPlugin, PluginContext } from '@
|
|
192
|
+
import type { PlayerPlugin, PluginContext } from '@openplayerjs/core';
|
|
193
193
|
|
|
194
194
|
export class AnalyticsPlugin implements PlayerPlugin {
|
|
195
195
|
name = 'analytics';
|
|
@@ -261,8 +261,8 @@ Every engine operates through a **`MediaSurface`** — a normalized abstraction
|
|
|
261
261
|
For engines that extend native HTML5 playback (like HLS or DASH via MSE), use `bindMediaEvents` to bridge DOM events into the player bus, and `bindCommands` to register the standard playback commands:
|
|
262
262
|
|
|
263
263
|
```ts
|
|
264
|
-
import { BaseMediaEngine } from '@
|
|
265
|
-
import type { IEngine, MediaEngineContext, MediaSource } from '@
|
|
264
|
+
import { BaseMediaEngine } from '@openplayerjs/core';
|
|
265
|
+
import type { IEngine, MediaEngineContext, MediaSource } from '@openplayerjs/core';
|
|
266
266
|
|
|
267
267
|
export class MyStreamEngine extends BaseMediaEngine implements IEngine {
|
|
268
268
|
name = 'my-stream-engine';
|
|
@@ -314,7 +314,7 @@ export class MyStreamEngine extends BaseMediaEngine implements IEngine {
|
|
|
314
314
|
For engines that embed a third-party player inside an iframe, use `IframeMediaSurface` to adapt the provider's API into the standard surface contract, then call `ctx.setSurface()` to register it:
|
|
315
315
|
|
|
316
316
|
```ts
|
|
317
|
-
import { BaseMediaEngine, IframeMediaSurface } from '@
|
|
317
|
+
import { BaseMediaEngine, IframeMediaSurface } from '@openplayerjs/core';
|
|
318
318
|
import type {
|
|
319
319
|
IEngine,
|
|
320
320
|
IframeMediaAdapter,
|
|
@@ -322,7 +322,7 @@ import type {
|
|
|
322
322
|
IframePlaybackState,
|
|
323
323
|
MediaEngineContext,
|
|
324
324
|
MediaSource,
|
|
325
|
-
} from '@
|
|
325
|
+
} from '@openplayerjs/core';
|
|
326
326
|
|
|
327
327
|
// 1. Implement the provider-specific adapter:
|
|
328
328
|
class MyProviderAdapter implements IframeMediaAdapter {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openplayerjs/core",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.4.0",
|
|
4
4
|
"description": "Core player engine, plugin system and public API for OpenPlayerJS",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Rafael Miranda",
|
|
@@ -35,10 +35,10 @@
|
|
|
35
35
|
"headless"
|
|
36
36
|
],
|
|
37
37
|
"scripts": {
|
|
38
|
-
"build:bundles": "rollup -c rollup.config.
|
|
38
|
+
"build:bundles": "rollup -c rollup.config.cjs",
|
|
39
39
|
"test": "jest --passWithNoTests --config ../../jest.config.cjs",
|
|
40
40
|
"release": "dotenv -o -- release-it --config .release-it.cjs",
|
|
41
|
-
"watch": "rollup -c rollup.config.
|
|
41
|
+
"watch": "rollup -c rollup.config.cjs --watch"
|
|
42
42
|
},
|
|
43
43
|
"publishConfig": {
|
|
44
44
|
"access": "public"
|