strataplayer 1.0.0 → 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.
package/README.md CHANGED
@@ -1,18 +1,18 @@
1
1
  # StrataPlayer
2
2
 
3
3
  <div align="center">
4
- <img src="public/logo.png" alt="StrataPlayer Logo" width="128" />
4
+ <img src="https://dev-ashishranjan.github.io/StrataPlayer/logo.png" alt="StrataPlayer Logo" width="128" />
5
5
 
6
6
  <p align="center">
7
- <strong>A robust, secure, and production-grade video player built for the modern web.</strong>
7
+ <strong>The Universal Media Engine for the Modern Web.</strong>
8
8
  </p>
9
9
 
10
10
  <p align="center">
11
11
  <a href="https://github.com/dev-AshishRanjan/StrataPlayer/blob/main/LICENSE">
12
12
  <img src="https://img.shields.io/badge/license-MIT-blue.svg" alt="License" />
13
13
  </a>
14
- <a href="https://react.dev">
15
- <img src="https://img.shields.io/badge/react-19.0-blue" alt="React" />
14
+ <a href="https://www.npmjs.com/package/strataplayer">
15
+ <img src="https://img.shields.io/npm/v/strataplayer" alt="NPM Version" />
16
16
  </a>
17
17
  <a href="https://www.typescriptlang.org/">
18
18
  <img src="https://img.shields.io/badge/typescript-5.0-blue" alt="TypeScript" />
@@ -20,72 +20,53 @@
20
20
  </p>
21
21
  </div>
22
22
 
23
- ## Overview
23
+ ## Introduction
24
24
 
25
- StrataPlayer is a highly customizable, high-performance HTML5 video player designed for React applications. It features a lightweight core with a plugin architecture, advanced subtitle management, robust error handling, and a sleek, themeable UI powered by Tailwind CSS.
25
+ StrataPlayer represents a shift in how media playback is handled on the web. Instead of tightly coupling playback logic to a specific framework, StrataPlayer operates as a **framework-agnostic engine**.
26
26
 
27
- It supports HLS (HTTP Live Streaming) out of the box via `hls.js`, along with standard MP4/WebM formats, making it suitable for VOD, live streaming, and complex media applications.
27
+ While the UI layer is powered by the high-performance concurrent rendering of React 19, the player itself can be mounted into **any** application—be it Vanilla JS, Vue, Svelte, or Angular. It decouples the "playback state" (time, buffer, quality) from the "view layer," ensuring that high-frequency updates (like progress bars) never cause performance bottlenecks in your host application.
28
28
 
29
- ## Features
30
-
31
- ### Core Playback
32
-
33
- - **Multi-Format Support:** Seamlessly plays HLS (`.m3u8`), MP4, WebM, and DASH (via plugin extension).
34
- - **Robust Error Handling:** Exponential backoff retry logic for network failures and stream interruptions.
35
- - **Adaptive Bitrate:** Automatic quality switching with manual override controls.
36
- - **Audio Engine:** Built-in Web Audio API integration for **Audio Boost** (up to 300% volume).
37
-
38
- ### User Interface & Experience
29
+ ## Core Philosophy
39
30
 
40
- - **Fully Themeable:** Includes 4 built-in themes (Default, Pixel, Game, Hacker) and custom accent color support.
41
- - **Responsive Controls:** Mobile-friendly touch controls and gesture support (double tap to seek).
42
- - **Keyboard Shortcuts:** Full accessibility support with standard hotkeys (`Space`, `F`, `M`, Arrows).
43
- - **Picture-in-Picture:** Native PiP support for multitasking.
44
- - **Chromecast Support:** Built-in Google Cast integration.
31
+ 1. **Universal Compatibility:** Write once, run anywhere. Whether you are building a static HTML site or a complex Next.js application, the implementation remains consistent.
32
+ 2. **State Isolation:** The playback engine runs on a detached state store (`NanoStore`). This allows the player to handle micro-updates (video time, download progress) internally without triggering re-renders in your parent application.
33
+ 3. **Opt-in Complexity:** The core is lightweight. Advanced capabilities like HLS/DASH adaptive streaming, analytics, or casting are treated as plugins, keeping your bundle size strictly minimal unless needed.
45
34
 
46
- ### Advanced Subtitles
35
+ ## Features
47
36
 
48
- - **Custom Rendering:** High-performance canvas/DOM-based subtitle rendering.
49
- - **Full Customization:** Users can adjust font size, color, background opacity, blur, and offsets.
50
- - **Synchronization:** Manual subtitle offset adjustment to fix out-of-sync captions.
51
- - **Local Upload:** Support for drag-and-drop `.vtt` and `.srt` files.
37
+ ### Engine & Performance
52
38
 
53
- ### Developer Experience
39
+ - **Framework Agnostic:** First-class support for React, with a mounting API for Vue, Svelte, and Vanilla JS.
40
+ - **Resilient Network Handling:** Automatic exponential backoff and retry logic for unstable connections.
41
+ - **Adaptive Streaming:** Native support for HLS (`.m3u8`) and DASH via plugin architecture.
42
+ - **Audio Boost Engine:** Integrated Web Audio API nodes allowing volume boosting up to 300%.
54
43
 
55
- - **React 19 Ready:** Built with the latest React patterns (Hooks, `useSyncExternalStore`).
56
- - **State Management:** Lightweight, external store (`NanoStore`) for high-performance updates without re-renders.
57
- - **Plugin System:** Easily extend functionality without bloating the core.
58
- - **TypeScript:** 100% type-safe.
44
+ ### Visuals & Interface
59
45
 
60
- ## 🚀 Getting Started
46
+ - **Themeable System:** 4 built-in distinct themes (Default, Pixel, Game, Hacker) with CSS variable support.
47
+ - **Advanced Subtitles:** DOM-based rendering supporting custom positioning, shadows, and runtime sync adjustment.
48
+ - **Mobile Optimized:** Touch gestures for seeking (double-tap), scrubbing, and volume control.
49
+ - **Google Cast:** Native Chromecast integration.
61
50
 
62
- ### Installation
51
+ ## 🚀 Installation
63
52
 
64
53
  ```bash
65
- # Clone the repository
66
- git clone https://github.com/dev-AshishRanjan/StrataPlayer.git
67
-
68
- # Navigate to project directory
69
- cd StrataPlayer
70
-
71
- # Install dependencies
72
- npm install
73
-
74
- # Start the development server
75
- npm run dev
54
+ npm install strataplayer
76
55
  ```
77
56
 
78
- ### Basic Usage
57
+ ## 💻 Usage
58
+
59
+ ### React
79
60
 
80
61
  ```tsx
81
- import { StrataPlayer } from "./ui/StrataPlayer";
62
+ import { StrataPlayer } from "strataplayer";
63
+ import "strataplayer/style.css";
82
64
 
83
65
  const App = () => {
84
66
  return (
85
- <div className="w-full max-w-4xl mx-auto">
67
+ <div className="player-wrapper">
86
68
  <StrataPlayer
87
69
  src="https://test-streams.mux.dev/x36xhzz/x36xhzz.m3u8"
88
- autoPlay={false}
89
70
  theme="default"
90
71
  themeColor="#6366f1"
91
72
  />
@@ -94,17 +75,57 @@ const App = () => {
94
75
  };
95
76
  ```
96
77
 
97
- ### Advanced Usage (Sources & Tracks)
78
+ ### Vanilla JS / Vue / Svelte / Angular
98
79
 
99
- ```tsx
100
- <StrataPlayer
101
- sources={[
102
- { name: "HLS Master", url: "https://example.com/master.m3u8", type: "hls" },
103
- { name: "MP4 Fallback", url: "https://example.com/video.mp4", type: "mp4" },
104
- ]}
105
- poster="https://example.com/poster.jpg"
106
- thumbnails="https://example.com/thumbnails.vtt"
107
- textTracks={[
80
+ For non-React frameworks, use the `mountStrataPlayer` helper. This mounts the player into a specific DOM node and returns an instance for cleanup and updates.
81
+
82
+ **index.html**
83
+
84
+ ```html
85
+ <div id="player-container" style="width: 100%; aspect-ratio: 16/9;"></div>
86
+ ```
87
+
88
+ **main.js**
89
+
90
+ ```javascript
91
+ import { mountStrataPlayer } from "strataplayer";
92
+ import "strataplayer/style.css";
93
+
94
+ const container = document.getElementById("player-container");
95
+
96
+ const instance = mountStrataPlayer(container, {
97
+ src: "https://test-streams.mux.dev/x36xhzz/x36xhzz.m3u8",
98
+ autoPlay: false,
99
+ theme: "hacker",
100
+ themeColor: "#22c55e",
101
+ sources: [
102
+ { name: "HLS Stream", url: "...", type: "hls" },
103
+ { name: "MP4 Fallback", url: "...", type: "mp4" },
104
+ ],
105
+ });
106
+
107
+ // To update props later (e.g., change video):
108
+ // instance.update({ src: 'new-video.mp4' });
109
+
110
+ // To destroy/cleanup (e.g., in Vue onUnmounted):
111
+ // instance.unmount();
112
+ ```
113
+
114
+ ## ⚙️ Advanced Configuration
115
+
116
+ ### Sources & Tracks
117
+
118
+ StrataPlayer supports complex source arrays and subtitle tracks.
119
+
120
+ ```javascript
121
+ const props = {
122
+ sources: [
123
+ { name: "1080p HLS", url: "master.m3u8", type: "hls" },
124
+ { name: "720p MP4", url: "fallback.mp4", type: "mp4" },
125
+ ],
126
+ poster: "https://example.com/poster.jpg",
127
+ thumbnails: "https://example.com/storyboard.vtt", // For seek preview
128
+ textTracks: [
108
129
  {
109
130
  kind: "subtitles",
110
131
  label: "English",
@@ -112,8 +133,8 @@ const App = () => {
112
133
  srcLang: "en",
113
134
  default: true,
114
135
  },
115
- ]}
116
- />
136
+ ],
137
+ };
117
138
  ```
118
139
 
119
140
  ## ⌨️ Keyboard Shortcuts
@@ -130,16 +151,16 @@ const App = () => {
130
151
 
131
152
  ## 🎨 Themes
132
153
 
133
- StrataPlayer comes with preset themes that can be applied via props or changed at runtime by the user:
154
+ StrataPlayer separates layout from aesthetics. Themes can be switched instantly at runtime via props:
134
155
 
135
- - **Default:** Modern, clean, and professional (Inter font).
136
- - **Pixel:** Retro gaming aesthetic (Press Start 2P font).
137
- - **Game:** Cinematic RPG style (Cinzel font).
138
- - **Hacker:** Terminal/Cyberpunk aesthetic (JetBrains Mono font).
156
+ - **Default:** Professional, clean lines using Inter font.
157
+ - **Pixel:** Retro-gaming aesthetic with sharp edges and 8-bit fonts.
158
+ - **Game:** Cinematic RPG style with serif typography and gold accents.
159
+ - **Hacker:** Terminal-inspired aesthetic with scanlines and monospaced fonts.
139
160
 
140
161
  ## 🤝 Contributing
141
162
 
142
- Contributions are welcome! Please feel free to submit a Pull Request.
163
+ We welcome contributions that align with our philosophy of performance and modularity.
143
164
 
144
165
  1. Fork the project
145
166
  2. Create your feature branch (`git checkout -b feature/AmazingFeature`)