@not_hacker/video-player-sdk
v1.0.0
Published
A lightweight, customizable video player SDK for modern web applications
Maintainers
Readme
Video Player SDK
A lightweight, customizable video player SDK for modern web applications. Framework agnostic - works with React, Angular, Vue, or vanilla JavaScript.
Features
- 🎯 Framework agnostic - works with React, Angular, Vue, or vanilla JS
- 📱 Fully customizable size and position
- ▶️ Auto-play video with no pause controls
- 📱 Responsive design for mobile and desktop
- 🔗 Easy API integration with extensible data structure
- ❌ Built-in close button and navigation handling
Installation
npm install video-player-sdkQuick Start
Vanilla JavaScript
import { VideoPlayerSDK } from 'video-player-sdk';
const sdk = new VideoPlayerSDK({
uniqueId: 'demo-1',
position: 'bottom-right',
width: '320px',
height: '480px',
onClose: () => console.log('Player closed'),
onNavigate: (url) => window.location.href = url
});
await sdk.init();React Hook
import { useVideoPlayer } from 'video-player-sdk';
function App() {
const { close } = useVideoPlayer({
uniqueId: 'demo-1',
position: 'bottom-right',
width: '320px',
height: '480px',
});
return <button onClick={close}>Close</button>;
}Configuration Options
| Option | Type | Default | Description |
|--------|------|---------|-------------|
| uniqueId | string | - | Unique identifier for the video content |
| apiEndpoint | string | /api/video | API endpoint to fetch video data |
| position | string | bottom-right | Position of the player |
| width | string | 320px | Width of the player |
| height | string | 480px | Height of the player |
| autoPlay | boolean | true | Auto-play the video |
| showCloseButton | boolean | true | Show close button |
| onClose | function | - | Callback when player is closed |
| onNavigate | function | - | Callback when action button is clicked |
API Reference
VideoPlayerSDK Class
Methods
init(): Initialize the playerclose(): Close the playerdestroy(): Destroy the player instanceupdatePosition(position, customPosition?): Update player positionupdateSize(width, height): Update player size
useVideoPlayer Hook
Returns an object with:
sdk: VideoPlayerSDK instanceclose(): Close the playerupdatePosition(): Update positionupdateSize(): Update size
License
MIT
