unified-video-framework
Version:
Cross-platform video player framework supporting iOS, Android, Web, Smart TVs (Samsung/LG), Roku, and more
337 lines (270 loc) โข 8.64 kB
Markdown
# Unified Video Player Framework ( ๐ง Don't use this Package this is Under Developement ๐๏ธ )
<!--
A comprehensive cross-platform video player framework that provides a unified API for building video applications across all major platforms.
## ๐ฏ Supported Platforms
- **Mobile**: iOS, Android
- **Web**: All modern browsers
- **Smart TVs**:
- Samsung Tizen (using Enact)
- LG webOS (using Enact)
- **Streaming Devices**:
- Roku
- Android TV
- Apple TV
- **Desktop**: Windows, macOS, Linux (via web)
## โจ Features
- **Unified API**: Single API across all platforms
- **DRM Support**: FairPlay, Widevine, PlayReady
- **Adaptive Streaming**: HLS, DASH support
- **Analytics**: Built-in analytics integration
- **Offline Playback**: Download and play offline
- **Casting**: Chromecast and AirPlay support
- **Picture-in-Picture**: Supported platforms
- **4K/8K & HDR**: High-quality video support
- **Subtitles & Multiple Audio Tracks**
- **Ad Integration**: Pre-roll, mid-roll, post-roll ads
- **Remote Control**: Full TV remote support
## ๐ฆ Installation
### Using npm
```bash
npm install unified-video-framework
```
### Using yarn
```bash
yarn add unified-video-framework
```
### Using pnpm
```bash
pnpm add unified-video-framework
```
### From GitHub (latest development version)
```bash
npm install github:flicknexs/unified-video-framework
```
### Using npm link (for development)
```bash
# In the framework directory
npm link
# In your project
npm link unified-video-framework
```
๐ **For detailed installation instructions and troubleshooting, see [INSTALLATION.md](./INSTALLATION.md)**
## ๐ Quick Start
### Basic Usage
```typescript
import { UnifiedVideoPlayer } from '@flicknexs/unified-video-framework';
function App() {
return (
<UnifiedVideoPlayer
source={{
url: 'https://example.com/video.m3u8',
type: 'application/x-mpegURL'
}}
config={{
autoPlay: true,
controls: true
}}
onReady={() => console.log('Player ready')}
onError={(error) => console.error('Player error:', error)}
/>
);
}
```
### With DRM
```typescript
import { UnifiedVideoPlayer, DRMType } from '@flicknexs/unified-video-framework';
function SecureVideoApp() {
return (
<UnifiedVideoPlayer
source={{
url: 'https://example.com/encrypted-video.mpd',
type: 'application/dash+xml',
drm: {
type: DRMType.WIDEVINE,
licenseUrl: 'https://license.example.com/widevine',
headers: {
'X-Auth-Token': 'your-auth-token'
}
}
}}
config={{
autoPlay: false,
adaptiveBitrate: {
autoLevelEnabled: true,
startLevel: -1
}
}}
/>
);
}
```
## ๐๏ธ Framework Architecture
```
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Application Layer (Your App) โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ Unified Video Framework API (TypeScript) โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ Platform Bridge Layer โ
โโโโโโโโฌโโโโโโโฌโโโโโโโโโโโฌโโโโโโโฌโโโโโโโโโโโฌโโโโโค
โ iOS โAndroidโ Enact โ Roku โ Web โWin โ
โNativeโNative โ(Tizen/LG)โBridgeโ Browser โUWP โ
โโโโโโโโดโโโโโโโดโโโโโโโโโโโดโโโโโโโดโโโโโโโโโโโดโโโโโ
```
## ๐ฑ Platform-Specific Setup
### iOS
```bash
cd ios && pod install
```
### Android
Add to `android/app/build.gradle`:
```gradle
dependencies {
implementation 'com.google.android.exoplayer:exoplayer:2.18.0'
}
```
### Samsung Tizen TV
```bash
npm run build:tizen
tizen install -n dist/tizen/app.wgt
```
### LG webOS TV
```bash
npm run build:webos
ares-install dist/webos/app.ipk
```
### Roku
```bash
npm run build:roku
# Upload via Roku Developer Dashboard
```
## ๐ ๏ธ Development
### Setup
```bash
# Install dependencies
npm install
# Bootstrap monorepo
npm run bootstrap
# Build all packages
npm run build
```
### Running Examples
```bash
# Run mobile demo
cd apps/mobile-demo
npm run ios
# or
npm run android
# Run TV demo
cd apps/tv-demo
npm run serve
# Run web demo
cd apps/web-demo
npm start
```
## ๐ API Documentation
### VideoPlayer Methods
| Method | Description | Returns |
|--------|-------------|---------|
| `load(source)` | Load a video source | `Promise<void>` |
| `play()` | Start playback | `Promise<void>` |
| `pause()` | Pause playback | `void` |
| `seek(time)` | Seek to position | `void` |
| `setVolume(level)` | Set volume (0-1) | `void` |
| `setQuality(quality)` | Set video quality | `void` |
| `setSubtitle(track)` | Set subtitle track | `void` |
| `destroy()` | Clean up player | `void` |
### Events
| Event | Description | Payload |
|-------|-------------|---------|
| `ready` | Player initialized | - |
| `play` | Playback started | - |
| `pause` | Playback paused | - |
| `ended` | Playback ended | - |
| `error` | Error occurred | `{error: Error}` |
| `timeupdate` | Position updated | `{currentTime: number}` |
| `progress` | Buffer progress | `{buffered: number}` |
| `qualitychange` | Quality changed | `{quality: Quality}` |
## ๐ฎ Remote Control Support
The framework automatically handles remote control inputs on TV platforms:
- **Play/Pause**: Media play/pause keys
- **Seek**: Left/Right arrow keys
- **Volume**: Up/Down arrow keys
- **Back**: Return/Back button
- **Select**: OK/Enter button
## ๐ Analytics Integration
```typescript
import { GoogleAnalytics, MixPanel } from '@flicknexs/analytics';
<UnifiedVideoPlayer
source={videoSource}
config={{
analytics: {
enabled: true,
providers: [
new GoogleAnalytics({ trackingId: 'UA-XXXXX' }),
new MixPanel({ token: 'your-token' })
]
}
}}
/>
```
## ๐ DRM Configuration
### FairPlay (iOS/Apple TV)
```typescript
{
type: DRMType.FAIRPLAY,
certificateUrl: 'https://example.com/certificate',
licenseUrl: 'https://example.com/license'
}
```
### Widevine (Android/Chrome/Smart TVs)
```typescript
{
type: DRMType.WIDEVINE,
licenseUrl: 'https://example.com/widevine/license'
}
```
### PlayReady (Windows/Xbox/Smart TVs)
```typescript
{
type: DRMType.PLAYREADY,
licenseUrl: 'https://example.com/playready/license'
}
```
## ๐งช Testing
```bash
# Run unit tests
npm test
# Run E2E tests
npm run test:e2e
# Platform-specific tests
npm run test:ios
npm run test:android
npm run test:tizen
```
## ๐ Performance Optimization
- **Lazy Loading**: Platform-specific code is loaded on demand
- **Code Splitting**: Automatic code splitting for web builds
- **Memory Management**: Automatic cleanup and resource management
- **Adaptive Bitrate**: Automatic quality adjustment based on network
## ๐ณ Paywall Rentals (Stripe, Pesapal, Google Pay)
- For per-video rentals (no subscriptions), follow our step-by-step implementation guide:
- See PAYWALL_RENTAL_FLOW.md: [PAYWALL_RENTAL_FLOW.md](./PAYWALL_RENTAL_FLOW.md)
- Documentation index: [docs/](./docs/README.md)
## ๐ค Contributing
Please read [CONTRIBUTING.md](CONTRIBUTING.md) for details on our code of conduct and the process for submitting pull requests.
## ๐ License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
## ๐ Support
- **Documentation**: [https://docs.example.com](https://docs.example.com)
- **Issues**: [GitHub Issues](https://github.com/flicknexs/unified-video-framework/issues)
- **Discord**: [Join our Discord](https://discord.gg/example)
- **Email**: support@example.com
## ๐ Acknowledgments
- React Native team for the mobile framework
- Enact team for the Smart TV framework
- ExoPlayer team for Android video engine
- AVPlayer team for iOS video engine
---
-->
Built with โค๏ธ by flicknexs