str-native-video-player
v1.0.0
Published
Allows for native video player functionality, fetching and storing videos from a CDN, switching between the playback of these videos with cross fade and preloading functionality
Maintainers
Readme
str-native-video-player
Allows for native video player functionality, fetching and storing videos from a CDN, switching between the playback of these videos with cross fade and preloading functionality
Install
npm install str-native-video-player
npx cap syncAPI
echo(...)play_video(...)pause_video(...)resume_video(...)stop_video(...)seek_video(...)is_video_playing()preload_video(...)list_cached_videos()evict_videos(...)get_storage_stats()set_max_cache_size(...)
echo(...)
echo(options: { value: string; }) => Promise<{ value: string; }>Simple echo for testing connectivity.
| Param | Type |
| ------------- | ------------------------------- |
| options | { value: string; } |
Returns: Promise<{ value: string; }>
play_video(...)
play_video(options: { uuid: string; url?: string; loop?: boolean; video_player?: any; }) => Promise<{ success: boolean; }>Core video playback method.
Plays a video identified by uuid. If it is not cached locally, it will stream from url
while simultaneously caching it for future playback.
| Param | Type |
| ------------- | -------------------------------------------------------------------------------- |
| options | { uuid: string; url?: string; loop?: boolean; video_player?: any; } |
Returns: Promise<{ success: boolean; }>
pause_video(...)
pause_video(options: { video_player?: any; }) => Promise<{ success: boolean; }>Pauses the currently playing video.
| Param | Type |
| ------------- | ------------------------------------ |
| options | { video_player?: any; } |
Returns: Promise<{ success: boolean; }>
resume_video(...)
resume_video(options: { video_player?: any; }) => Promise<{ success: boolean; }>Resumes the currently playing video.
| Param | Type |
| ------------- | ------------------------------------ |
| options | { video_player?: any; } |
Returns: Promise<{ success: boolean; }>
stop_video(...)
stop_video(options: { video_player?: any; }) => Promise<{ success: boolean; }>Stops the currently playing video.
| Param | Type |
| ------------- | ------------------------------------ |
| options | { video_player?: any; } |
Returns: Promise<{ success: boolean; }>
seek_video(...)
seek_video(options: { position_ms: number; video_player?: any; }) => Promise<{ success: boolean; }>Seeks the currently playing video to a specific position in milliseconds.
| Param | Type |
| ------------- | --------------------------------------------------------- |
| options | { position_ms: number; video_player?: any; } |
Returns: Promise<{ success: boolean; }>
is_video_playing()
is_video_playing() => Promise<{ playing: boolean; }>Returns whether a video is currently playing.
Returns: Promise<{ playing: boolean; }>
preload_video(...)
preload_video(options: { uuid: string; url: string; }) => Promise<{ success: boolean; }>Preload a video into local storage (without playing). Will fetch and cache the video to speed up future playback.
Optional: should respect max cache size and apply LRU eviction.
| Param | Type |
| ------------- | ------------------------------------------- |
| options | { uuid: string; url: string; } |
Returns: Promise<{ success: boolean; }>
list_cached_videos()
list_cached_videos() => Promise<{ value: { uuid: string; url: string; size_bytes: number; last_accessed: number; }[]; }>List all currently cached videos with metadata.
Returns: Promise<{ value: { uuid: string; url: string; size_bytes: number; last_accessed: number; }[]; }>
evict_videos(...)
evict_videos(options: { uuids: string[]; }) => Promise<{ success: boolean; }>Evict specific videos from cache manually.
| Param | Type |
| ------------- | --------------------------------- |
| options | { uuids: string[]; } |
Returns: Promise<{ success: boolean; }>
get_storage_stats()
get_storage_stats() => Promise<{ available_bytes: number; total_bytes: number; used_bytes_videos: number; used_bytes_app: number; }>Get cache/storage statistics.
Returns: Promise<{ available_bytes: number; total_bytes: number; used_bytes_videos: number; used_bytes_app: number; }>
set_max_cache_size(...)
set_max_cache_size(options: { max_bytes: number; }) => Promise<{ success: boolean; }>Set maximum cache size for videos. When exceeded, LRU eviction should occur automatically.
| Param | Type |
| ------------- | ----------------------------------- |
| options | { max_bytes: number; } |
Returns: Promise<{ success: boolean; }>
