@openwebf/vue-video-player 1.0.0
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 +191 -0
- package/index.d.ts +158 -0
- package/package.json +19 -0
package/README.md
ADDED
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
# WebF Video Player
|
|
2
|
+
|
|
3
|
+
HTML5-compatible video player for WebF applications. Wraps Flutter's `video_player` package with a familiar HTML5 video element API.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
Add this package to your `pubspec.yaml`:
|
|
8
|
+
|
|
9
|
+
```yaml
|
|
10
|
+
dependencies:
|
|
11
|
+
webf_video_player: ^1.0.0
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## Setup
|
|
15
|
+
|
|
16
|
+
Register the custom element in your Flutter app's main function:
|
|
17
|
+
|
|
18
|
+
```dart
|
|
19
|
+
import 'package:webf_video_player/webf_video_player.dart';
|
|
20
|
+
|
|
21
|
+
void main() {
|
|
22
|
+
installWebFVideoPlayer();
|
|
23
|
+
runApp(MyApp());
|
|
24
|
+
}
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Usage
|
|
28
|
+
|
|
29
|
+
### Basic Example
|
|
30
|
+
|
|
31
|
+
```html
|
|
32
|
+
<webf-video-player
|
|
33
|
+
src="https://example.com/video.mp4"
|
|
34
|
+
controls
|
|
35
|
+
></webf-video-player>
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### With All Options
|
|
39
|
+
|
|
40
|
+
```html
|
|
41
|
+
<webf-video-player
|
|
42
|
+
src="https://example.com/video.mp4"
|
|
43
|
+
poster="https://example.com/poster.jpg"
|
|
44
|
+
controls
|
|
45
|
+
autoplay
|
|
46
|
+
muted
|
|
47
|
+
loop
|
|
48
|
+
volume="0.8"
|
|
49
|
+
playback-rate="1.0"
|
|
50
|
+
object-fit="contain"
|
|
51
|
+
></webf-video-player>
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### JavaScript Control
|
|
55
|
+
|
|
56
|
+
```javascript
|
|
57
|
+
const video = document.querySelector('webf-video-player');
|
|
58
|
+
|
|
59
|
+
// Play/Pause
|
|
60
|
+
video.play();
|
|
61
|
+
video.pause();
|
|
62
|
+
|
|
63
|
+
// Seek to 30 seconds
|
|
64
|
+
video.currentTime = 30;
|
|
65
|
+
|
|
66
|
+
// Adjust volume
|
|
67
|
+
video.volume = 0.5;
|
|
68
|
+
video.muted = true;
|
|
69
|
+
|
|
70
|
+
// Change playback speed
|
|
71
|
+
video.playbackRate = 1.5;
|
|
72
|
+
|
|
73
|
+
// Listen to events
|
|
74
|
+
video.addEventListener('play', () => console.log('Playing'));
|
|
75
|
+
video.addEventListener('pause', () => console.log('Paused'));
|
|
76
|
+
video.addEventListener('ended', () => console.log('Ended'));
|
|
77
|
+
video.addEventListener('timeupdate', (e) => {
|
|
78
|
+
console.log('Current time:', e.detail.currentTime);
|
|
79
|
+
});
|
|
80
|
+
video.addEventListener('error', (e) => {
|
|
81
|
+
console.error('Error:', e.detail.message);
|
|
82
|
+
});
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
## Properties
|
|
86
|
+
|
|
87
|
+
| Property | Type | Default | Description |
|
|
88
|
+
|----------|------|---------|-------------|
|
|
89
|
+
| `src` | string | - | Video source URL. Supports `http://`, `https://`, `asset://`, `file://` |
|
|
90
|
+
| `poster` | string | - | Poster image URL displayed before playback |
|
|
91
|
+
| `autoplay` | boolean | false | Auto-start playback when loaded |
|
|
92
|
+
| `controls` | boolean | true | Show playback controls |
|
|
93
|
+
| `loop` | boolean | false | Loop video continuously |
|
|
94
|
+
| `muted` | boolean | false | Mute audio |
|
|
95
|
+
| `volume` | number | 1.0 | Volume level (0.0 to 1.0) |
|
|
96
|
+
| `playbackRate` | number | 1.0 | Playback speed (0.25 to 2.0) |
|
|
97
|
+
| `currentTime` | number | 0 | Current position in seconds (read/write) |
|
|
98
|
+
| `objectFit` | string | 'contain' | Video sizing: 'contain', 'cover', 'fill', 'none' |
|
|
99
|
+
| `preload` | string | 'metadata' | Preload hint: 'none', 'metadata', 'auto' |
|
|
100
|
+
| `playsInline` | boolean | true | Play inline on iOS (vs fullscreen) |
|
|
101
|
+
|
|
102
|
+
### Read-only Properties
|
|
103
|
+
|
|
104
|
+
| Property | Type | Description |
|
|
105
|
+
|----------|------|-------------|
|
|
106
|
+
| `duration` | number | Total duration in seconds |
|
|
107
|
+
| `paused` | boolean | Whether playback is paused |
|
|
108
|
+
| `ended` | boolean | Whether playback has ended |
|
|
109
|
+
| `seeking` | boolean | Whether currently seeking |
|
|
110
|
+
| `readyState` | number | Loading ready state (0-4) |
|
|
111
|
+
| `networkState` | number | Network state (0-3) |
|
|
112
|
+
| `videoWidth` | number | Natural video width in pixels |
|
|
113
|
+
| `videoHeight` | number | Natural video height in pixels |
|
|
114
|
+
| `buffering` | boolean | Whether currently buffering |
|
|
115
|
+
|
|
116
|
+
## Events
|
|
117
|
+
|
|
118
|
+
| Event | Detail | Description |
|
|
119
|
+
|-------|--------|-------------|
|
|
120
|
+
| `loadstart` | - | Browser starts loading |
|
|
121
|
+
| `loadedmetadata` | `{duration, videoWidth, videoHeight}` | Metadata loaded |
|
|
122
|
+
| `loadeddata` | - | First frame loaded |
|
|
123
|
+
| `canplay` | - | Ready to play |
|
|
124
|
+
| `canplaythrough` | - | Can play without buffering |
|
|
125
|
+
| `play` | - | Playback started |
|
|
126
|
+
| `playing` | - | Playback ready after pause/buffer |
|
|
127
|
+
| `pause` | - | Playback paused |
|
|
128
|
+
| `ended` | - | Playback ended |
|
|
129
|
+
| `waiting` | - | Buffering/stalled |
|
|
130
|
+
| `seeking` | - | Seek operation started |
|
|
131
|
+
| `seeked` | - | Seek operation completed |
|
|
132
|
+
| `timeupdate` | `{currentTime, duration}` | Position update (~4x/sec) |
|
|
133
|
+
| `durationchange` | `{duration}` | Duration changed |
|
|
134
|
+
| `volumechange` | `{volume, muted}` | Volume/mute changed |
|
|
135
|
+
| `ratechange` | `{playbackRate}` | Playback rate changed |
|
|
136
|
+
| `progress` | - | Download progress |
|
|
137
|
+
| `error` | `{code, message}` | Error occurred |
|
|
138
|
+
|
|
139
|
+
## Methods
|
|
140
|
+
|
|
141
|
+
| Method | Returns | Description |
|
|
142
|
+
|--------|---------|-------------|
|
|
143
|
+
| `play()` | void | Start playback |
|
|
144
|
+
| `pause()` | void | Pause playback |
|
|
145
|
+
| `load()` | void | Reload video source |
|
|
146
|
+
| `canPlayType(mimeType)` | string | Check MIME support ('', 'maybe', 'probably') |
|
|
147
|
+
|
|
148
|
+
## Source URL Protocols
|
|
149
|
+
|
|
150
|
+
| Protocol | Example | Description |
|
|
151
|
+
|----------|---------|-------------|
|
|
152
|
+
| `http://` | `http://example.com/video.mp4` | HTTP URL |
|
|
153
|
+
| `https://` | `https://example.com/video.mp4` | HTTPS URL |
|
|
154
|
+
| `asset://` | `asset://videos/intro.mp4` | Flutter asset |
|
|
155
|
+
| `file://` | `file:///path/to/video.mp4` | Local file |
|
|
156
|
+
|
|
157
|
+
## Supported Formats
|
|
158
|
+
|
|
159
|
+
The supported video formats depend on the platform:
|
|
160
|
+
|
|
161
|
+
| Format | iOS | Android | Description |
|
|
162
|
+
|--------|-----|---------|-------------|
|
|
163
|
+
| MP4 (H.264) | Yes | Yes | Most compatible |
|
|
164
|
+
| WebM | No | Yes | Android only |
|
|
165
|
+
| HLS | Yes | Yes | Streaming format |
|
|
166
|
+
|
|
167
|
+
## Platform Configuration
|
|
168
|
+
|
|
169
|
+
### iOS
|
|
170
|
+
|
|
171
|
+
Add to `ios/Runner/Info.plist` for network video playback:
|
|
172
|
+
|
|
173
|
+
```xml
|
|
174
|
+
<key>NSAppTransportSecurity</key>
|
|
175
|
+
<dict>
|
|
176
|
+
<key>NSAllowsArbitraryLoads</key>
|
|
177
|
+
<true/>
|
|
178
|
+
</dict>
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
### Android
|
|
182
|
+
|
|
183
|
+
Add to `android/app/src/main/AndroidManifest.xml`:
|
|
184
|
+
|
|
185
|
+
```xml
|
|
186
|
+
<uses-permission android:name="android.permission.INTERNET"/>
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
## License
|
|
190
|
+
|
|
191
|
+
Apache License 2.0
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Generated by TSDL, don't edit this file directly.
|
|
3
|
+
*/
|
|
4
|
+
// Based on the Vue 3 documentation for defining custom elements:
|
|
5
|
+
// https://vuejs.org/guide/extras/web-components
|
|
6
|
+
import type { EmitFn, PublicProps, StyleValue, ClassValue } from 'vue';
|
|
7
|
+
import '@openwebf/vue-core-ui';
|
|
8
|
+
type EventMap = {
|
|
9
|
+
[event: string]: Event
|
|
10
|
+
}
|
|
11
|
+
// This maps an EventMap to the format that Vue's $emit type expects.
|
|
12
|
+
type VueEmit<T extends EventMap> = EmitFn<{
|
|
13
|
+
[K in keyof T]: (event: NonNullable<T[K]>) => void
|
|
14
|
+
}>
|
|
15
|
+
// Vue 3 event listener properties for template usage
|
|
16
|
+
type VueEventListeners<T extends EventMap> = {
|
|
17
|
+
[K in keyof T as `on${Capitalize<string & K>}`]?: (event: NonNullable<T[K]>) => any
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Time range information for buffered/seekable regions.
|
|
21
|
+
*/
|
|
22
|
+
export interface TimeRangeInfo {
|
|
23
|
+
/**
|
|
24
|
+
* Number of ranges.
|
|
25
|
+
*/
|
|
26
|
+
length: number;
|
|
27
|
+
/**
|
|
28
|
+
* Array of range objects with start and end times in seconds.
|
|
29
|
+
*/
|
|
30
|
+
ranges: any[];
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Video error information matching HTML5 MediaError.
|
|
34
|
+
*/
|
|
35
|
+
export interface VideoError {
|
|
36
|
+
/**
|
|
37
|
+
* Error code:
|
|
38
|
+
* - 1: MEDIA_ERR_ABORTED
|
|
39
|
+
* - 2: MEDIA_ERR_NETWORK
|
|
40
|
+
* - 3: MEDIA_ERR_DECODE
|
|
41
|
+
* - 4: MEDIA_ERR_SRC_NOT_SUPPORTED
|
|
42
|
+
*/
|
|
43
|
+
code: number;
|
|
44
|
+
/**
|
|
45
|
+
* Human-readable error message.
|
|
46
|
+
*/
|
|
47
|
+
message: string;
|
|
48
|
+
}
|
|
49
|
+
type DefineCustomElement<
|
|
50
|
+
ElementType,
|
|
51
|
+
Props,
|
|
52
|
+
Events extends EventMap = {},
|
|
53
|
+
> = new () => ElementType & VueEventListeners<Events> & {
|
|
54
|
+
// Use $props to define the properties exposed to template type checking. Vue
|
|
55
|
+
// specifically reads prop definitions from the `$props` type. Note that we
|
|
56
|
+
// combine the element's props with Vue's special props.
|
|
57
|
+
/** @deprecated Do not use the $props property on a Custom Element ref,
|
|
58
|
+
this is for template prop types only. */
|
|
59
|
+
$props: Props & PublicProps & VueEventListeners<Events>
|
|
60
|
+
// Use $emit to specifically define event types. Vue specifically reads event
|
|
61
|
+
// types from the `$emit` type. Note that `$emit` expects a particular format
|
|
62
|
+
// that we map `Events` to.
|
|
63
|
+
/** @deprecated Do not use the $emit property on a Custom Element ref,
|
|
64
|
+
this is for template prop types only. */
|
|
65
|
+
$emit: VueEmit<Events>
|
|
66
|
+
}
|
|
67
|
+
export type WebFVideoPlayerProps = {
|
|
68
|
+
'src'?: string;
|
|
69
|
+
'poster'?: string;
|
|
70
|
+
'autoplay'?: boolean;
|
|
71
|
+
'controls'?: boolean;
|
|
72
|
+
'loop'?: boolean;
|
|
73
|
+
'muted'?: boolean;
|
|
74
|
+
'volume'?: number;
|
|
75
|
+
'playback-rate'?: number;
|
|
76
|
+
'current-time'?: number;
|
|
77
|
+
'object-fit'?: string;
|
|
78
|
+
'preload'?: string;
|
|
79
|
+
'plays-inline'?: boolean;
|
|
80
|
+
'duration'?: number;
|
|
81
|
+
'paused'?: boolean;
|
|
82
|
+
'ended'?: boolean;
|
|
83
|
+
'seeking'?: boolean;
|
|
84
|
+
'ready-state'?: number;
|
|
85
|
+
'network-state'?: number;
|
|
86
|
+
'video-width'?: number;
|
|
87
|
+
'video-height'?: number;
|
|
88
|
+
'buffering'?: boolean;
|
|
89
|
+
'id'?: string;
|
|
90
|
+
'class'?: ClassValue;
|
|
91
|
+
'style'?: StyleValue;
|
|
92
|
+
}
|
|
93
|
+
export interface WebFVideoPlayerElement {
|
|
94
|
+
src?: string;
|
|
95
|
+
poster?: string;
|
|
96
|
+
autoplay?: boolean;
|
|
97
|
+
controls?: boolean;
|
|
98
|
+
loop?: boolean;
|
|
99
|
+
muted?: boolean;
|
|
100
|
+
volume?: number;
|
|
101
|
+
playbackRate?: number;
|
|
102
|
+
currentTime?: number;
|
|
103
|
+
objectFit?: string;
|
|
104
|
+
preload?: string;
|
|
105
|
+
playsInline?: boolean;
|
|
106
|
+
duration?: number;
|
|
107
|
+
paused?: boolean;
|
|
108
|
+
ended?: boolean;
|
|
109
|
+
seeking?: boolean;
|
|
110
|
+
readyState?: number;
|
|
111
|
+
networkState?: number;
|
|
112
|
+
videoWidth?: number;
|
|
113
|
+
videoHeight?: number;
|
|
114
|
+
buffering?: boolean;
|
|
115
|
+
play(): void;
|
|
116
|
+
pause(): void;
|
|
117
|
+
load(): void;
|
|
118
|
+
canPlayType(type: string): string;
|
|
119
|
+
}
|
|
120
|
+
export type WebFVideoPlayerEvents = {
|
|
121
|
+
loadstart: Event;
|
|
122
|
+
error: CustomEvent<VideoError>;
|
|
123
|
+
loadedmetadata: CustomEvent<{ duration: number; videoWidth: number; videoHeight: number }>;
|
|
124
|
+
loadeddata: Event;
|
|
125
|
+
canplay: Event;
|
|
126
|
+
canplaythrough: Event;
|
|
127
|
+
playing: Event;
|
|
128
|
+
waiting: Event;
|
|
129
|
+
seeking: Event;
|
|
130
|
+
seeked: Event;
|
|
131
|
+
ended: Event;
|
|
132
|
+
durationchange: CustomEvent<{ duration: number }>;
|
|
133
|
+
timeupdate: CustomEvent<{ currentTime: number; duration: number }>;
|
|
134
|
+
play: Event;
|
|
135
|
+
pause: Event;
|
|
136
|
+
ratechange: CustomEvent<{ playbackRate: number }>;
|
|
137
|
+
volumechange: CustomEvent<{ volume: number; muted: boolean }>;
|
|
138
|
+
progress: Event;
|
|
139
|
+
}
|
|
140
|
+
declare const flutterAttached: (typeof import('@openwebf/vue-core-ui')) extends { flutterAttached: infer T } ? T : any;
|
|
141
|
+
declare module '@vue/runtime-core' {
|
|
142
|
+
interface GlobalDirectives {
|
|
143
|
+
vFlutterAttached: typeof flutterAttached;
|
|
144
|
+
}
|
|
145
|
+
interface GlobalComponents {
|
|
146
|
+
'webf-video-player': DefineCustomElement<
|
|
147
|
+
WebFVideoPlayerElement,
|
|
148
|
+
WebFVideoPlayerProps,
|
|
149
|
+
WebFVideoPlayerEvents
|
|
150
|
+
>
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
// Some tooling (older IDE integrations) look for global directive/component typing
|
|
154
|
+
// augmentations on the `vue` module name instead of `@vue/runtime-core`.
|
|
155
|
+
declare module 'vue' {
|
|
156
|
+
interface GlobalDirectives extends import('@vue/runtime-core').GlobalDirectives {}
|
|
157
|
+
interface GlobalComponents extends import('@vue/runtime-core').GlobalComponents {}
|
|
158
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@openwebf/vue-video-player",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "HTML5-compatible video player for WebF applications. Wraps Flutter's video_player package with a familiar HTML5 video element API.",
|
|
5
|
+
"main": "",
|
|
6
|
+
"types": "index.d.ts",
|
|
7
|
+
"files": ["index.d.ts", "README.md"],
|
|
8
|
+
"keywords": [],
|
|
9
|
+
"author": "",
|
|
10
|
+
"license": "ISC",
|
|
11
|
+
"peerDependencies": {
|
|
12
|
+
"vue": "^3.0.0",
|
|
13
|
+
"@openwebf/vue-core-ui": "^0.24.0"
|
|
14
|
+
},
|
|
15
|
+
"devDependencies": {
|
|
16
|
+
"@openwebf/vue-core-ui": "^0.24.0",
|
|
17
|
+
"vue": "^3.0.0"
|
|
18
|
+
}
|
|
19
|
+
}
|