playron 1.0.2 → 1.0.3

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.
Files changed (2) hide show
  1. package/README.md +111 -16
  2. package/package.json +8 -2
package/README.md CHANGED
@@ -11,7 +11,7 @@ Playron is a modular, tree-shakeable video player library designed for OTT platf
11
11
 
12
12
  ```tsx
13
13
  import { Player } from 'playron'
14
- import 'playron/dist/playron.css'
14
+ import 'playron/style.css'
15
15
 
16
16
  <Player src="https://example.com/stream.m3u8" />
17
17
  ```
@@ -42,11 +42,11 @@ npx yalc add playron
42
42
 
43
43
  ## Quick Start
44
44
 
45
- ### React / Next.js
45
+ ### React (Vite / CRA)
46
46
 
47
47
  ```tsx
48
48
  import { Player } from 'playron'
49
- import 'playron/dist/playron.css'
49
+ import 'playron/style.css'
50
50
 
51
51
  export default function VideoPage() {
52
52
  return (
@@ -54,10 +54,7 @@ export default function VideoPage() {
54
54
  src="https://example.com/stream.m3u8"
55
55
  poster="https://example.com/poster.jpg"
56
56
  config={{
57
- player: {
58
- defaultVolume: 0.8,
59
- skipSeconds: 10,
60
- },
57
+ player: { defaultVolume: 0.8, skipSeconds: 10 },
61
58
  features: {
62
59
  pip: true,
63
60
  fullscreen: true,
@@ -67,34 +64,74 @@ export default function VideoPage() {
67
64
  playbackSpeed: true,
68
65
  keyboardShortcuts: true,
69
66
  },
70
- branding: {
71
- primaryColor: '#e50914',
72
- },
67
+ branding: { primaryColor: '#e50914' },
73
68
  }}
74
69
  />
75
70
  )
76
71
  }
77
72
  ```
78
73
 
79
- ### Next.js App Router
74
+ ### Next.js App Router
75
+
76
+ > **Important:** Playron uses browser-only APIs (MediaSource, EME, hls.js, dash.js).
77
+ > You **must** use `dynamic()` with `ssr: false`. Using only `'use client'` is not enough —
78
+ > Next.js still pre-renders client components on the server for the initial HTML.
79
+
80
+ **Step 1** — Create a client wrapper with `dynamic`:
80
81
 
81
82
  ```tsx
83
+ // components/VideoPlayer.tsx
82
84
  'use client'
83
- import { Player } from 'playron'
84
- import 'playron/dist/playron.css'
85
+ import dynamic from 'next/dynamic'
86
+ import 'playron/style.css'
87
+
88
+ const Player = dynamic(
89
+ () => import('playron').then(m => m.Player),
90
+ {
91
+ ssr: false,
92
+ loading: () => (
93
+ <div style={{ width: '100%', aspectRatio: '16/9', background: '#000' }} />
94
+ ),
95
+ }
96
+ )
97
+
98
+ export default function VideoPlayer({ src }: { src: string }) {
99
+ return <Player src={src} />
100
+ }
101
+ ```
102
+
103
+ **Step 2** — Use it in your page (Server Component is fine here):
104
+
105
+ ```tsx
106
+ // app/page.tsx
107
+ import VideoPlayer from '@/components/VideoPlayer'
108
+
109
+ export default function Page() {
110
+ return <VideoPlayer src="https://example.com/stream.m3u8" />
111
+ }
85
112
  ```
86
113
 
87
- ### Next.js Pages Router
114
+ ### Next.js Pages Router
88
115
 
89
116
  ```tsx
117
+ // pages/video.tsx
90
118
  import dynamic from 'next/dynamic'
91
- const Player = dynamic(() => import('playron').then(m => m.Player), { ssr: false })
119
+ import 'playron/style.css'
120
+
121
+ const Player = dynamic(
122
+ () => import('playron').then(m => m.Player),
123
+ { ssr: false }
124
+ )
125
+
126
+ export default function VideoPage() {
127
+ return <Player src="https://example.com/stream.m3u8" />
128
+ }
92
129
  ```
93
130
 
94
131
  ### Vanilla JavaScript
95
132
 
96
133
  ```html
97
- <link rel="stylesheet" href="playron/dist/playron.css" />
134
+ <link rel="stylesheet" href="node_modules/playron/dist/playron.css" />
98
135
 
99
136
  <div id="player"></div>
100
137
 
@@ -482,6 +519,64 @@ npm run lint # ESLint
482
519
 
483
520
  ---
484
521
 
522
+ ## Troubleshooting
523
+
524
+ ### `window is not defined` (Next.js)
525
+
526
+ **Cause:** Playron bundles hls.js and dash.js which access browser APIs at module evaluation time. Next.js pre-renders even `'use client'` components on the server for the initial HTML — `'use client'` alone is not sufficient.
527
+
528
+ **Fix:** Always wrap Playron in `dynamic()` with `ssr: false`:
529
+
530
+ ```tsx
531
+ // ❌ Wrong — causes "window is not defined" on the server
532
+ 'use client'
533
+ import { Player } from 'playron'
534
+
535
+ // ✅ Correct
536
+ 'use client'
537
+ import dynamic from 'next/dynamic'
538
+
539
+ const Player = dynamic(
540
+ () => import('playron').then(m => m.Player),
541
+ { ssr: false }
542
+ )
543
+ ```
544
+
545
+ ---
546
+
547
+ ### `Module not found: Can't resolve 'playron/dist/playron.css'`
548
+
549
+ **Cause:** The correct CSS export path is `playron/style.css`, not `playron/dist/playron.css`.
550
+
551
+ ```tsx
552
+ // ❌ Wrong
553
+ import 'playron/dist/playron.css'
554
+
555
+ // ✅ Correct
556
+ import 'playron/style.css'
557
+ ```
558
+
559
+ Both paths now work as of v1.0.3, but `playron/style.css` is the canonical import.
560
+
561
+ ---
562
+
563
+ ### Player renders but has no styles
564
+
565
+ Make sure you import the CSS **once** at the top level of your app (e.g. `layout.tsx`, `_app.tsx`, or `globals.css`):
566
+
567
+ ```tsx
568
+ // app/layout.tsx
569
+ import 'playron/style.css'
570
+ ```
571
+
572
+ ---
573
+
574
+ ### Video plays but DRM content fails on Safari
575
+
576
+ FairPlay (Safari/iOS) is not yet implemented. Playron will automatically show a DRM error overlay with browser recommendations when Widevine content is loaded in Safari. See the [DRM section](#drm-usage) for the current support matrix.
577
+
578
+ ---
579
+
485
580
  ## License
486
581
 
487
582
  MIT © Suat Erkilic
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "playron",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "description": "Modern OTT video player for React, Next.js, and vanilla JS",
5
5
  "type": "module",
6
6
  "main": "./dist/playron.cjs.js",
@@ -12,8 +12,14 @@
12
12
  "import": "./dist/playron.es.js",
13
13
  "require": "./dist/playron.cjs.js"
14
14
  },
15
- "./style.css": "./dist/playron.css"
15
+ "./style.css": "./dist/playron.css",
16
+ "./dist/playron.css": "./dist/playron.css",
17
+ "./dist/*": "./dist/*"
16
18
  },
19
+ "sideEffects": [
20
+ "*.css",
21
+ "./dist/playron.css"
22
+ ],
17
23
  "files": [
18
24
  "dist"
19
25
  ],