@scarlett-player/embed 0.1.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/iframe.html ADDED
@@ -0,0 +1,101 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>Scarlett Player - iframe Embed</title>
7
+ <style>
8
+ * {
9
+ margin: 0;
10
+ padding: 0;
11
+ box-sizing: border-box;
12
+ }
13
+
14
+ html, body {
15
+ width: 100%;
16
+ height: 100%;
17
+ overflow: hidden;
18
+ background: #000;
19
+ }
20
+
21
+ #player {
22
+ width: 100%;
23
+ height: 100%;
24
+ }
25
+ </style>
26
+ </head>
27
+ <body>
28
+ <div id="player"></div>
29
+
30
+ <script type="module">
31
+ // Parse URL parameters
32
+ const params = new URLSearchParams(window.location.search);
33
+
34
+ // Build configuration from URL params
35
+ const config = {
36
+ container: '#player',
37
+ src: params.get('src') || '',
38
+ autoplay: params.get('autoplay') === 'true' || params.get('autoplay') === '1',
39
+ muted: params.get('muted') === 'true' || params.get('muted') === '1',
40
+ poster: params.get('poster') || undefined,
41
+ controls: params.get('controls') !== 'false' && params.get('controls') !== '0',
42
+ brandColor: params.get('brandColor') || params.get('brand-color') || undefined,
43
+ primaryColor: params.get('primaryColor') || params.get('primary-color') || undefined,
44
+ backgroundColor: params.get('backgroundColor') || params.get('background-color') || undefined,
45
+ loop: params.get('loop') === 'true' || params.get('loop') === '1',
46
+ };
47
+
48
+ // Parse numeric params
49
+ const hideDelay = params.get('hideDelay') || params.get('hide-delay');
50
+ if (hideDelay) {
51
+ config.hideDelay = parseInt(hideDelay, 10);
52
+ }
53
+
54
+ const playbackRate = params.get('playbackRate') || params.get('playback-rate');
55
+ if (playbackRate) {
56
+ config.playbackRate = parseFloat(playbackRate);
57
+ }
58
+
59
+ const startTime = params.get('startTime') || params.get('start-time');
60
+ if (startTime) {
61
+ config.startTime = parseFloat(startTime);
62
+ }
63
+
64
+ // Validate src
65
+ if (!config.src) {
66
+ document.body.innerHTML = `
67
+ <div style="display: flex; align-items: center; justify-content: center; height: 100%; color: white; font-family: sans-serif; text-align: center; padding: 20px;">
68
+ <div>
69
+ <h1 style="margin-bottom: 10px;">Missing Source</h1>
70
+ <p>Please provide a 'src' URL parameter.</p>
71
+ <p style="margin-top: 10px; font-size: 14px; opacity: 0.7;">
72
+ Example: iframe.html?src=https://example.com/video.m3u8
73
+ </p>
74
+ </div>
75
+ </div>
76
+ `;
77
+ } else {
78
+ // Import and initialize player
79
+ import('./dist/embed.js')
80
+ .then((module) => {
81
+ const player = module.create(config);
82
+
83
+ if (!player) {
84
+ console.error('Failed to create player');
85
+ }
86
+ })
87
+ .catch((error) => {
88
+ console.error('Failed to load Scarlett Player:', error);
89
+ document.body.innerHTML = `
90
+ <div style="display: flex; align-items: center; justify-content: center; height: 100%; color: white; font-family: sans-serif; text-align: center; padding: 20px;">
91
+ <div>
92
+ <h1 style="margin-bottom: 10px;">Error Loading Player</h1>
93
+ <p>${error.message}</p>
94
+ </div>
95
+ </div>
96
+ `;
97
+ });
98
+ }
99
+ </script>
100
+ </body>
101
+ </html>
package/package.json ADDED
@@ -0,0 +1,65 @@
1
+ {
2
+ "name": "@scarlett-player/embed",
3
+ "version": "0.1.0",
4
+ "description": "Standalone CDN-ready embed package for Scarlett Player",
5
+ "type": "module",
6
+ "main": "./dist/embed.umd.cjs",
7
+ "module": "./dist/embed.js",
8
+ "types": "./dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "import": "./dist/embed.js",
12
+ "require": "./dist/embed.umd.cjs",
13
+ "types": "./dist/index.d.ts"
14
+ }
15
+ },
16
+ "files": [
17
+ "dist",
18
+ "iframe.html"
19
+ ],
20
+ "scripts": {
21
+ "dev": "vite",
22
+ "build": "tsc && vite build",
23
+ "preview": "vite preview",
24
+ "test": "vitest run",
25
+ "test:watch": "vitest",
26
+ "test:coverage": "vitest run --coverage",
27
+ "typecheck": "tsc --noEmit",
28
+ "clean": "rimraf dist"
29
+ },
30
+ "keywords": [
31
+ "video",
32
+ "player",
33
+ "embed",
34
+ "cdn",
35
+ "hls",
36
+ "streaming",
37
+ "scarlett"
38
+ ],
39
+ "author": "The Stream Platform",
40
+ "license": "MIT",
41
+ "repository": {
42
+ "type": "git",
43
+ "url": "git+https://github.com/Hackney-Enterprises-Inc/scarlett-player.git",
44
+ "directory": "packages/embed"
45
+ },
46
+ "bugs": {
47
+ "url": "https://github.com/Hackney-Enterprises-Inc/scarlett-player/issues"
48
+ },
49
+ "homepage": "https://github.com/Hackney-Enterprises-Inc/scarlett-player#readme",
50
+ "dependencies": {
51
+ "@scarlett-player/core": "file:../core",
52
+ "@scarlett-player/hls": "file:../plugins/hls",
53
+ "@scarlett-player/ui": "file:../plugins/ui",
54
+ "hls.js": "^1.5.0"
55
+ },
56
+ "devDependencies": {
57
+ "@types/node": "^20.0.0",
58
+ "@vitest/ui": "^1.1.0",
59
+ "jsdom": "^23.0.0",
60
+ "rimraf": "^5.0.5",
61
+ "typescript": "^5.3.3",
62
+ "vite": "^5.0.11",
63
+ "vitest": "^1.1.0"
64
+ }
65
+ }