expo-libvlc-player 2.1.7 → 2.2.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 +9 -8
- package/android/build.gradle +2 -2
- package/android/src/main/java/expo/modules/libvlcplayer/LibVlcPlayerModule.kt +4 -2
- package/android/src/main/java/expo/modules/libvlcplayer/LibVlcPlayerView.kt +11 -3
- package/android/src/main/java/expo/modules/libvlcplayer/MediaPlayerListener.kt +6 -0
- package/build/LibVlcPlayer.types.d.ts +16 -3
- package/build/LibVlcPlayer.types.d.ts.map +1 -1
- package/build/LibVlcPlayer.types.js.map +1 -1
- package/build/LibVlcPlayerView.d.ts.map +1 -1
- package/build/LibVlcPlayerView.js +6 -1
- package/build/LibVlcPlayerView.js.map +1 -1
- package/ios/LibVlcPlayerModule.swift +4 -2
- package/ios/LibVlcPlayerView.swift +8 -3
- package/ios/MediaPlayerDelegate.swift +4 -0
- package/package.json +2 -2
- package/src/LibVlcPlayer.types.ts +16 -3
- package/src/LibVlcPlayerView.tsx +8 -0
package/README.md
CHANGED
|
@@ -111,14 +111,14 @@ See the [Example App](example/components/PlayerView.tsx) for additional usage.
|
|
|
111
111
|
|
|
112
112
|
### Player methods
|
|
113
113
|
|
|
114
|
-
| Method
|
|
115
|
-
|
|
|
116
|
-
| `play()`
|
|
117
|
-
| `pause()`
|
|
118
|
-
| `stop()`
|
|
119
|
-
| `seek(
|
|
120
|
-
| `postAction(action: number)`
|
|
121
|
-
| `dismiss()`
|
|
114
|
+
| Method | Description |
|
|
115
|
+
| -------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------- |
|
|
116
|
+
| `play()` | Starts playback of the current player |
|
|
117
|
+
| `pause()` | Pauses playback of the current player |
|
|
118
|
+
| `stop()` | Stops playback of the current player |
|
|
119
|
+
| `seek(value: number, type?: "position" \| "time")` | Sets the position or time of the current player. Must be a number equal or greater than `0` and type defaults to `"position"` |
|
|
120
|
+
| `postAction(action: number)` | Posts an answer to a [`Dialog`](#dialog). Must be an integer of `1` or `2` |
|
|
121
|
+
| `dismiss()` | Dismisses a [`Dialog`](#dialog) |
|
|
122
122
|
|
|
123
123
|
### Player props
|
|
124
124
|
|
|
@@ -151,6 +151,7 @@ The `LibVlcPlayerView` extends React Native `ViewProps` and implements the follo
|
|
|
151
151
|
| `onStopped` | Called after the `Stopped` player event | |
|
|
152
152
|
| `onEndReached` | Called after the `EndReached` player event | |
|
|
153
153
|
| `onEncounteredError` | Called after the `EncounteredError` player event | `{ error: string }` |
|
|
154
|
+
| `onTimeChanged` | Called after the `TimeChanged` player event | `{ time: number }` |
|
|
154
155
|
| `onPositionChanged` | Called after the `PositionChanged` player event | `{ position: number }` |
|
|
155
156
|
| `onESAdded` | Called after the `ESAdded` player event | [`MediaTracks`](#mediatracks) |
|
|
156
157
|
| `onDialogDisplay` | Called after a `Dialog` needs to be displayed | [`Dialog`](#dialog) |
|
package/android/build.gradle
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
apply plugin: "com.android.library"
|
|
2
2
|
|
|
3
3
|
group = "expo.modules.libvlcplayer"
|
|
4
|
-
version = "2.
|
|
4
|
+
version = "2.2.0"
|
|
5
5
|
|
|
6
6
|
def expoModulesCorePlugin = new File(project(":expo-modules-core").projectDir.absolutePath, "ExpoModulesCorePlugin.gradle")
|
|
7
7
|
apply from: expoModulesCorePlugin
|
|
@@ -27,7 +27,7 @@ android {
|
|
|
27
27
|
namespace "expo.modules.libvlcplayer"
|
|
28
28
|
defaultConfig {
|
|
29
29
|
versionCode 1
|
|
30
|
-
versionName "2.
|
|
30
|
+
versionName "2.2.0"
|
|
31
31
|
consumerProguardFiles("proguard-rules.pro")
|
|
32
32
|
}
|
|
33
33
|
lintOptions {
|
|
@@ -12,6 +12,7 @@ private const val PAUSED_EVENT = "onPaused"
|
|
|
12
12
|
private const val STOPPED_EVENT = "onStopped"
|
|
13
13
|
private const val END_REACHED_EVENT = "onEndReached"
|
|
14
14
|
private const val ENCOUNTERED_ERROR_EVENT = "onEncounteredError"
|
|
15
|
+
private const val TIME_CHANGED_EVENT = "onTimeChanged"
|
|
15
16
|
private const val POSITION_CHANGED_EVENT = "onPositionChanged"
|
|
16
17
|
private const val ES_ADDED_EVENT = "onESAdded"
|
|
17
18
|
private const val DIALOG_DISPLAY_EVENT = "onDialogDisplay"
|
|
@@ -26,6 +27,7 @@ val playerEvents =
|
|
|
26
27
|
STOPPED_EVENT,
|
|
27
28
|
END_REACHED_EVENT,
|
|
28
29
|
ENCOUNTERED_ERROR_EVENT,
|
|
30
|
+
TIME_CHANGED_EVENT,
|
|
29
31
|
POSITION_CHANGED_EVENT,
|
|
30
32
|
ES_ADDED_EVENT,
|
|
31
33
|
DIALOG_DISPLAY_EVENT,
|
|
@@ -126,8 +128,8 @@ class LibVlcPlayerModule : Module() {
|
|
|
126
128
|
view.stop()
|
|
127
129
|
}
|
|
128
130
|
|
|
129
|
-
AsyncFunction("seek") { view: LibVlcPlayerView,
|
|
130
|
-
view.seek(position)
|
|
131
|
+
AsyncFunction("seek") { view: LibVlcPlayerView, value: Double, type: String? ->
|
|
132
|
+
view.seek(value, type ?: "position")
|
|
131
133
|
}
|
|
132
134
|
|
|
133
135
|
AsyncFunction("postAction") { view: LibVlcPlayerView, action: Int ->
|
|
@@ -59,6 +59,7 @@ class LibVlcPlayerView(
|
|
|
59
59
|
internal val onStopped by EventDispatcher<Unit>()
|
|
60
60
|
internal val onEndReached by EventDispatcher<Unit>()
|
|
61
61
|
internal val onEncounteredError by EventDispatcher()
|
|
62
|
+
internal val onTimeChanged by EventDispatcher()
|
|
62
63
|
internal val onPositionChanged by EventDispatcher()
|
|
63
64
|
internal val onESAdded by EventDispatcher<MediaTracks>()
|
|
64
65
|
internal val onDialogDisplay by EventDispatcher<Dialog>()
|
|
@@ -428,12 +429,19 @@ class LibVlcPlayerView(
|
|
|
428
429
|
mediaPlayer?.stop()
|
|
429
430
|
}
|
|
430
431
|
|
|
431
|
-
fun seek(
|
|
432
|
+
fun seek(
|
|
433
|
+
value: Double,
|
|
434
|
+
type: String,
|
|
435
|
+
) {
|
|
432
436
|
mediaPlayer?.let { player ->
|
|
433
437
|
if (player.isSeekable()) {
|
|
434
|
-
|
|
438
|
+
if (type == "position") {
|
|
439
|
+
player.setPosition(value.toFloat())
|
|
440
|
+
} else {
|
|
441
|
+
player.setTime(value.toLong())
|
|
442
|
+
}
|
|
435
443
|
} else {
|
|
436
|
-
time = (
|
|
444
|
+
time = (value * mediaLength.toDouble()).toInt()
|
|
437
445
|
}
|
|
438
446
|
}
|
|
439
447
|
}
|
|
@@ -64,6 +64,12 @@ fun LibVlcPlayerView.setMediaPlayerListener() {
|
|
|
64
64
|
firstPlay = true
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
+
Event.TimeChanged -> {
|
|
68
|
+
val time = mapOf("time" to player.getTime().toInt())
|
|
69
|
+
|
|
70
|
+
onTimeChanged(time)
|
|
71
|
+
}
|
|
72
|
+
|
|
67
73
|
Event.PositionChanged -> {
|
|
68
74
|
val position = mapOf("position" to player.getPosition())
|
|
69
75
|
|
|
@@ -19,13 +19,14 @@ export interface LibVlcPlayerViewRef {
|
|
|
19
19
|
*/
|
|
20
20
|
readonly stop: () => Promise<void>;
|
|
21
21
|
/**
|
|
22
|
-
* Sets the position of the current player
|
|
22
|
+
* Sets the position or time of the current player
|
|
23
23
|
*
|
|
24
|
-
* @param
|
|
24
|
+
* @param value - Must be a number equal or greater than `0`
|
|
25
|
+
* @param type - Defaults to `"position"`
|
|
25
26
|
*
|
|
26
27
|
* @returns A promise which resolves to `void`
|
|
27
28
|
*/
|
|
28
|
-
readonly seek: (
|
|
29
|
+
readonly seek: (value: number, type?: "position" | "time") => Promise<void>;
|
|
29
30
|
/**
|
|
30
31
|
* Posts an answer to a `Dialog`
|
|
31
32
|
*
|
|
@@ -106,6 +107,13 @@ type EncounteredErrorListener = (event: NativeEvent<Error>) => void;
|
|
|
106
107
|
export type Error = {
|
|
107
108
|
error: string;
|
|
108
109
|
};
|
|
110
|
+
/**
|
|
111
|
+
* @hidden
|
|
112
|
+
*/
|
|
113
|
+
type TimeChangedListener = (event: NativeEvent<Time>) => void;
|
|
114
|
+
export type Time = {
|
|
115
|
+
time: number;
|
|
116
|
+
};
|
|
109
117
|
/**
|
|
110
118
|
* @hidden
|
|
111
119
|
*/
|
|
@@ -154,6 +162,7 @@ export interface LibVlcPlayerViewNativeProps {
|
|
|
154
162
|
onStopped?: StoppedListener;
|
|
155
163
|
onEndReached?: EndReachedListener;
|
|
156
164
|
onEncounteredError?: EncounteredErrorListener;
|
|
165
|
+
onTimeChanged?: TimeChangedListener;
|
|
157
166
|
onPositionChanged?: PositionChangedListener;
|
|
158
167
|
onESAdded?: ESAddedListener;
|
|
159
168
|
onDialogDisplay?: DialogDisplayListener;
|
|
@@ -297,6 +306,10 @@ export interface LibVlcPlayerViewProps extends ViewProps {
|
|
|
297
306
|
* Called after the `EncounteredError` player event
|
|
298
307
|
*/
|
|
299
308
|
onEncounteredError?: (event: Error) => void;
|
|
309
|
+
/**
|
|
310
|
+
* Called after the `TimeChanged` player event
|
|
311
|
+
*/
|
|
312
|
+
onTimeChanged?: (event: Time) => void;
|
|
300
313
|
/**
|
|
301
314
|
* Called after the `PositionChanged` player event
|
|
302
315
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LibVlcPlayer.types.d.ts","sourceRoot":"","sources":["../src/LibVlcPlayer.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAE9C,MAAM,WAAW,mBAAmB;IAClC;;;;OAIG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IACnC;;;;OAIG;IACH,QAAQ,CAAC,KAAK,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IACpC;;;;OAIG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,OAAO,CAAC,IAAI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OAIG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,IAAI,CAAC;IACzB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;IACvB;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;IACtB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;IACvB;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,IAAI,CAAC;IAC1B;;OAEG;IACH,kBAAkB,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IAC5C;;OAEG;IACH,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,IAAI,KAAK,IAAI,CAAC;IACtC;;OAEG;IACH,iBAAiB,CAAC,EAAE,CAAC,KAAK,EAAE,QAAQ,KAAK,IAAI,CAAC;IAC9C;;OAEG;IACH,SAAS,CAAC,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,IAAI,CAAC;IACzC;;OAEG;IACH,eAAe,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAC1C;;OAEG;IACH,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,SAAS,KAAK,IAAI,CAAC;IACzC;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,IAAI,CAAC;CAC3B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LibVlcPlayer.types.js","sourceRoot":"","sources":["../src/LibVlcPlayer.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { ViewProps } from \"react-native\";\n\nexport interface LibVlcPlayerViewRef {\n /**\n * Starts playback of the current player\n *\n * @returns A promise which resolves to `void`\n */\n readonly play: () => Promise<void>;\n /**\n * Pauses playback of the current player\n *\n * @returns A promise which resolves to `void`\n */\n readonly pause: () => Promise<void>;\n /**\n * Stops playback of the current player\n *\n * @returns A promise which resolves to `void`\n */\n readonly stop: () => Promise<void>;\n /**\n * Sets the position of the current player\n *\n * @param
|
|
1
|
+
{"version":3,"file":"LibVlcPlayer.types.js","sourceRoot":"","sources":["../src/LibVlcPlayer.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { ViewProps } from \"react-native\";\n\nexport interface LibVlcPlayerViewRef {\n /**\n * Starts playback of the current player\n *\n * @returns A promise which resolves to `void`\n */\n readonly play: () => Promise<void>;\n /**\n * Pauses playback of the current player\n *\n * @returns A promise which resolves to `void`\n */\n readonly pause: () => Promise<void>;\n /**\n * Stops playback of the current player\n *\n * @returns A promise which resolves to `void`\n */\n readonly stop: () => Promise<void>;\n /**\n * Sets the position or time of the current player\n *\n * @param value - Must be a number equal or greater than `0`\n * @param type - Defaults to `\"position\"`\n *\n * @returns A promise which resolves to `void`\n */\n readonly seek: (value: number, type?: \"position\" | \"time\") => Promise<void>;\n /**\n * Posts an answer to a `Dialog`\n *\n * @param action - Must be an integer of `1` or `2`\n *\n * @returns A promise which resolves to `void`\n */\n readonly postAction: (action: 1 | 2) => Promise<void>;\n /**\n * Dismisses a `Dialog`\n *\n * @returns A promise which resolves to `void`\n */\n readonly dismiss: () => Promise<void>;\n}\n\nexport type LibVlcSource = string | number | null;\n\nexport interface Tracks {\n audio?: number;\n video?: number;\n subtitle?: number;\n}\n\nexport interface Slave {\n source: NonNullable<LibVlcSource>;\n type: \"audio\" | \"subtitle\";\n selected?: boolean;\n}\n\nexport type AudioMixingMode =\n | \"mixWithOthers\"\n | \"duckOthers\"\n | \"auto\"\n | \"doNotMix\";\n\nexport interface NativeEvent<T> {\n nativeEvent: T;\n}\n\nexport interface Track {\n id: number;\n name: string;\n}\n\nexport interface MediaTracks {\n audio: Track[];\n video: Track[];\n subtitle: Track[];\n}\n\nexport interface MediaInfo {\n width: number;\n height: number;\n length: number;\n seekable: boolean;\n tracks: MediaTracks;\n}\n\nexport interface Dialog {\n title: string;\n text: string;\n cancelText?: string;\n action1Text?: string;\n action2Text?: string;\n}\n\n/**\n * @hidden\n */\ntype BufferingListener = () => void;\n\n/**\n * @hidden\n */\ntype PlayingListener = () => void;\n\n/**\n * @hidden\n */\ntype PausedListener = () => void;\n\n/**\n * @hidden\n */\ntype StoppedListener = () => void;\n\n/**\n * @hidden\n */\ntype EndReachedListener = () => void;\n\n/**\n * @hidden\n */\ntype EncounteredErrorListener = (event: NativeEvent<Error>) => void;\n\nexport type Error = { error: string };\n\n/**\n * @hidden\n */\ntype TimeChangedListener = (event: NativeEvent<Time>) => void;\n\nexport type Time = { time: number };\n\n/**\n * @hidden\n */\ntype PositionChangedListener = (event: NativeEvent<Position>) => void;\n\nexport type Position = { position: number };\n\n/**\n * @hidden\n */\ntype ESAddedListener = (event: NativeEvent<MediaTracks>) => void;\n\n/**\n * @hidden\n */\ntype DialogDisplayListener = (event: NativeEvent<Dialog>) => void;\n\n/**\n * @hidden\n */\ntype FirstPlayListener = (event: NativeEvent<MediaInfo>) => void;\n\n/**\n * @hidden\n */\ntype BackgroundListener = () => void;\n\n/**\n * @hidden\n */\nexport interface LibVlcPlayerViewNativeProps {\n ref?: React.Ref<LibVlcPlayerViewRef>;\n source?: LibVlcSource;\n options?: string[];\n tracks?: Tracks;\n slaves?: Slave[];\n scale?: number;\n aspectRatio?: string | null;\n rate?: number;\n time?: number;\n volume?: number;\n mute?: boolean;\n audioMixingMode?: AudioMixingMode;\n repeat?: boolean;\n playInBackground?: boolean;\n autoplay?: boolean;\n onBuffering?: BufferingListener;\n onPlaying?: PlayingListener;\n onPaused?: PausedListener;\n onStopped?: StoppedListener;\n onEndReached?: EndReachedListener;\n onEncounteredError?: EncounteredErrorListener;\n onTimeChanged?: TimeChangedListener;\n onPositionChanged?: PositionChangedListener;\n onESAdded?: ESAddedListener;\n onDialogDisplay?: DialogDisplayListener;\n onFirstPlay?: FirstPlayListener;\n onBackground?: BackgroundListener;\n}\n\nexport interface LibVlcPlayerViewProps extends ViewProps {\n /**\n * Sets the source of the media to be played. Set to `null` to release the player\n */\n source: LibVlcSource;\n /**\n * Sets the VLC options to initialize the player with\n *\n * https://wiki.videolan.org/VLC_command-line_help/\n *\n * @example [\"--network-caching=1000\"]\n *\n * @default []\n */\n options?: string[];\n /**\n * Sets the player audio, video and subtitle tracks\n *\n * @example\n * ```tsx\n * <LibVlcPlayerView\n * tracks={{\n * audio: 0,\n * video: 1,\n * subtitle: 2,\n * }}\n * />\n * ```\n *\n * @default undefined\n */\n tracks?: Tracks;\n /**\n * Sets the player audio and subtitle slaves\n *\n * @example\n * ```tsx\n * <LibVlcPlayerView\n * slaves={[\n * {\n * source: \"file://path/to/subtitle.srt\",\n * type: \"subtitle\",\n * selected: true\n * },\n * ]}\n * />\n * ```\n *\n * @default []\n */\n slaves?: Slave[];\n /**\n * Sets the player scaling factor. Must be a float equal or greater than `0`\n *\n * @default 0\n */\n scale?: number;\n /**\n * Sets the player aspect ratio. Must be a valid string or `null` for default\n *\n * @example \"16:9\"\n *\n * @default undefined\n */\n aspectRatio?: string | null;\n /**\n * Sets the player rate. Must be a float equal or greater than `1`\n *\n * @default 1\n */\n rate?: number;\n /**\n * Sets the initial player time. Must be an integer in milliseconds\n *\n * @default 0\n */\n time?: number;\n /**\n * Sets the player volume. Must be an integer between `0` and `100`\n *\n * @default 100\n */\n volume?: number;\n /**\n * Sets the player volume to `0` when `true`. Previous value is set when `false`\n *\n * @default false\n */\n mute?: boolean;\n /**\n * Determines how the player will interact with other audio playing in the system\n *\n * @default \"auto\"\n */\n audioMixingMode?: AudioMixingMode;\n /**\n * Determines whether the media should repeat once ended\n *\n * @default false\n */\n repeat?: boolean;\n /**\n * Determines whether the media should continue playing in the background\n *\n * @default false\n */\n playInBackground?: boolean;\n /**\n * Determines whether the media should autoplay once created\n *\n * @default true\n */\n autoplay?: boolean;\n /**\n * Called after the `Buffering` player event\n */\n onBuffering?: () => void;\n /**\n * Called after the `Playing` player event\n */\n onPlaying?: () => void;\n /**\n * Called after the `Paused` player event\n */\n onPaused?: () => void;\n /**\n * Called after the `Stopped` player event\n */\n onStopped?: () => void;\n /**\n * Called after the `EndReached` player event\n */\n onEndReached?: () => void;\n /**\n * Called after the `EncounteredError` player event\n */\n onEncounteredError?: (event: Error) => void;\n /**\n * Called after the `TimeChanged` player event\n */\n onTimeChanged?: (event: Time) => void;\n /**\n * Called after the `PositionChanged` player event\n */\n onPositionChanged?: (event: Position) => void;\n /**\n * Called after the `ESAdded` player event\n */\n onESAdded?: (event: MediaTracks) => void;\n /**\n * Called after a `Dialog` needs to be displayed\n */\n onDialogDisplay?: (event: Dialog) => void;\n /**\n * Called after the player first playing event\n */\n onFirstPlay?: (event: MediaInfo) => void;\n /**\n * Called after the player enters the background\n */\n onBackground?: () => void;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LibVlcPlayerView.d.ts","sourceRoot":"","sources":["../src/LibVlcPlayerView.tsx"],"names":[],"mappings":"AAGA,OAAO,EAEL,qBAAqB,EACrB,mBAAmB,
|
|
1
|
+
{"version":3,"file":"LibVlcPlayerView.d.ts","sourceRoot":"","sources":["../src/LibVlcPlayerView.tsx"],"names":[],"mappings":"AAGA,OAAO,EAEL,qBAAqB,EACrB,mBAAmB,EAQpB,MAAM,sBAAsB,CAAC;AAS9B,QAAA,MAAM,gBAAgB,uHAkErB,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
|
|
@@ -16,6 +16,11 @@ const LibVlcPlayerView = forwardRef((props, ref) => {
|
|
|
16
16
|
props.onEncounteredError(nativeEvent);
|
|
17
17
|
}
|
|
18
18
|
};
|
|
19
|
+
const onTimeChanged = ({ nativeEvent }) => {
|
|
20
|
+
if (props.onTimeChanged) {
|
|
21
|
+
props.onTimeChanged(nativeEvent);
|
|
22
|
+
}
|
|
23
|
+
};
|
|
19
24
|
const onPositionChanged = ({ nativeEvent }) => {
|
|
20
25
|
if (props.onPositionChanged) {
|
|
21
26
|
props.onPositionChanged(nativeEvent);
|
|
@@ -39,7 +44,7 @@ const LibVlcPlayerView = forwardRef((props, ref) => {
|
|
|
39
44
|
return (<NativeView {...nativeProps} ref={ref} source={parseSource(props.source)} slaves={props.slaves?.map((slave) => ({
|
|
40
45
|
...slave,
|
|
41
46
|
source: parseSource(slave.source),
|
|
42
|
-
}))} onEncounteredError={onEncounteredError} onPositionChanged={onPositionChanged} onESAdded={onESAdded} onDialogDisplay={onDialogDisplay} onFirstPlay={onFirstPlay}/>);
|
|
47
|
+
}))} onEncounteredError={onEncounteredError} onTimeChanged={onTimeChanged} onPositionChanged={onPositionChanged} onESAdded={onESAdded} onDialogDisplay={onDialogDisplay} onFirstPlay={onFirstPlay}/>);
|
|
43
48
|
});
|
|
44
49
|
export default LibVlcPlayerView;
|
|
45
50
|
//# sourceMappingURL=LibVlcPlayerView.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LibVlcPlayerView.js","sourceRoot":"","sources":["../src/LibVlcPlayerView.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,MAAM,CAAC;AACzC,OAAO,EAAE,UAAU,EAAsB,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"LibVlcPlayerView.js","sourceRoot":"","sources":["../src/LibVlcPlayerView.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,MAAM,CAAC;AACzC,OAAO,EAAE,UAAU,EAAsB,MAAM,OAAO,CAAC;AAcvD,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAEnD,MAAM,UAAU,GACd,iBAAiB,CAAC,kBAAkB,CAAC,CAAC;AAExC,IAAI,8BAA8B,GAAY,KAAK,CAAC;AAEpD,MAAM,gBAAgB,GAAG,UAAU,CACjC,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;IACb,MAAM,WAAW,GAAG,kBAAkB,CAAC,KAAK,CAAC,CAAC;IAE9C,mBAAmB;IACnB,IAAI,WAAW,CAAC,QAAQ,I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AEF,OAAO,CACL,CAAC,UAAU,CACT,IAAI,WAAW,CAAC,CAChB,GAAG,CAAC,CAAC,GAAG,CAAC,CACT,MAAM,CAAC,CAAC,WAAW,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAClC,MAAM,CAAC,CAAC,KAAK,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;YACpC,GAAG,KAAK;YACR,MAAM,EAAE,WAAW,CAAC,KAAK,CAAC,MAAM,CAAE;SACnC,CAAC,CAAC,CAAC,CACJ,kBAAkB,CAAC,CAAC,kBAAkB,CAAC,CACvC,aAAa,CAAC,CAAC,aAAa,CAAC,CAC7B,iBAAiB,CAAC,CAAC,iBAAiB,CAAC,CACrC,SAAS,CAAC,CAAC,SAAS,CAAC,CACrB,eAAe,CAAC,CAAC,eAAe,CAAC,CACjC,WAAW,CAAC,CAAC,WAAW,CAAC,EACzB,CACH,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,gBAAgB,CAAC","sourcesContent":["import { requireNativeView } from \"expo\";\nimport { forwardRef, type ComponentType } from \"react\";\n\nimport {\n LibVlcPlayerViewNativeProps,\n LibVlcPlayerViewProps,\n LibVlcPlayerViewRef,\n type NativeEvent,\n type Error,\n type Time,\n type Position,\n type MediaTracks,\n type MediaInfo,\n type Dialog,\n} from \"./LibVlcPlayer.types\";\nimport { parseSource } from \"./utils/assets\";\nimport { convertNativeProps } from \"./utils/props\";\n\nconst NativeView: ComponentType<LibVlcPlayerViewNativeProps> =\n requireNativeView(\"ExpoLibVlcPlayer\");\n\nlet loggedRenderingChildrenWarning: boolean = false;\n\nconst LibVlcPlayerView = forwardRef<LibVlcPlayerViewRef, LibVlcPlayerViewProps>(\n (props, ref) => {\n const nativeProps = convertNativeProps(props);\n\n // @ts-expect-error\n if (nativeProps.children && !loggedRenderingChildrenWarning) {\n console.warn(\n \"The <LibVlcPlayerView> component does not support children. This may lead to inconsistent behaviour or crashes. If you want to render content on top of the LibVlcPlayer, consider using absolute positioning.\",\n );\n loggedRenderingChildrenWarning = true;\n }\n\n const onEncounteredError = ({ nativeEvent }: NativeEvent<Error>) => {\n if (props.onEncounteredError) {\n props.onEncounteredError(nativeEvent);\n }\n };\n\n const onTimeChanged = ({ nativeEvent }: NativeEvent<Time>) => {\n if (props.onTimeChanged) {\n props.onTimeChanged(nativeEvent);\n }\n };\n\n const onPositionChanged = ({ nativeEvent }: NativeEvent<Position>) => {\n if (props.onPositionChanged) {\n props.onPositionChanged(nativeEvent);\n }\n };\n\n const onESAdded = ({ nativeEvent }: NativeEvent<MediaTracks>) => {\n if (props.onESAdded) {\n props.onESAdded(nativeEvent);\n }\n };\n\n const onDialogDisplay = ({ nativeEvent }: NativeEvent<Dialog>) => {\n if (props.onDialogDisplay) {\n props.onDialogDisplay(nativeEvent);\n }\n };\n\n const onFirstPlay = ({ nativeEvent }: NativeEvent<MediaInfo>) => {\n if (props.onFirstPlay) {\n props.onFirstPlay(nativeEvent);\n }\n };\n\n return (\n <NativeView\n {...nativeProps}\n ref={ref}\n source={parseSource(props.source)}\n slaves={props.slaves?.map((slave) => ({\n ...slave,\n source: parseSource(slave.source)!,\n }))}\n onEncounteredError={onEncounteredError}\n onTimeChanged={onTimeChanged}\n onPositionChanged={onPositionChanged}\n onESAdded={onESAdded}\n onDialogDisplay={onDialogDisplay}\n onFirstPlay={onFirstPlay}\n />\n );\n },\n);\n\nexport default LibVlcPlayerView;\n"]}
|
|
@@ -6,6 +6,7 @@ private let pausedEvent = "onPaused"
|
|
|
6
6
|
private let stoppedEvent = "onStopped"
|
|
7
7
|
private let endReachedEvent = "onEndReached"
|
|
8
8
|
private let encounteredErrorEvent = "onEncounteredError"
|
|
9
|
+
private let timeChangedEvent = "onTimeChanged"
|
|
9
10
|
private let positionChangedEvent = "onPositionChanged"
|
|
10
11
|
private let esAddedEvent = "onESAdded"
|
|
11
12
|
private let dialogDisplayEvent = "onDialogDisplay"
|
|
@@ -19,6 +20,7 @@ let playerEvents = [
|
|
|
19
20
|
stoppedEvent,
|
|
20
21
|
endReachedEvent,
|
|
21
22
|
encounteredErrorEvent,
|
|
23
|
+
timeChangedEvent,
|
|
22
24
|
positionChangedEvent,
|
|
23
25
|
esAddedEvent,
|
|
24
26
|
dialogDisplayEvent,
|
|
@@ -109,8 +111,8 @@ public class LibVlcPlayerModule: Module {
|
|
|
109
111
|
view.stop()
|
|
110
112
|
}
|
|
111
113
|
|
|
112
|
-
AsyncFunction("seek") { (view: LibVlcPlayerView,
|
|
113
|
-
view.seek(position)
|
|
114
|
+
AsyncFunction("seek") { (view: LibVlcPlayerView, value: Double, type: String?) in
|
|
115
|
+
view.seek(value, type ?? "position")
|
|
114
116
|
}
|
|
115
117
|
|
|
116
118
|
AsyncFunction("postAction") { (view: LibVlcPlayerView, action: Int) in
|
|
@@ -31,6 +31,7 @@ class LibVlcPlayerView: ExpoView {
|
|
|
31
31
|
let onStopped = EventDispatcher()
|
|
32
32
|
let onEndReached = EventDispatcher()
|
|
33
33
|
let onEncounteredError = EventDispatcher()
|
|
34
|
+
let onTimeChanged = EventDispatcher()
|
|
34
35
|
let onPositionChanged = EventDispatcher()
|
|
35
36
|
let onESAdded = EventDispatcher()
|
|
36
37
|
let onDialogDisplay = EventDispatcher()
|
|
@@ -380,12 +381,16 @@ class LibVlcPlayerView: ExpoView {
|
|
|
380
381
|
mediaPlayer?.stop()
|
|
381
382
|
}
|
|
382
383
|
|
|
383
|
-
func seek(_
|
|
384
|
+
func seek(_ value: Double, _ type: String) {
|
|
384
385
|
if let player = mediaPlayer {
|
|
385
386
|
if player.isSeekable {
|
|
386
|
-
|
|
387
|
+
if type == "position" {
|
|
388
|
+
player.position = Float(value)
|
|
389
|
+
} else {
|
|
390
|
+
player.time = VLCTime(int: Int32(value))
|
|
391
|
+
}
|
|
387
392
|
} else {
|
|
388
|
-
time = Int(
|
|
393
|
+
time = Int(value * Double(mediaLength))
|
|
389
394
|
}
|
|
390
395
|
}
|
|
391
396
|
}
|
|
@@ -57,6 +57,10 @@ extension LibVlcPlayerView: VLCMediaPlayerDelegate {
|
|
|
57
57
|
|
|
58
58
|
func mediaPlayerTimeChanged(_: Notification) {
|
|
59
59
|
if let player = mediaPlayer {
|
|
60
|
+
let time = ["time": player.time.intValue]
|
|
61
|
+
|
|
62
|
+
onTimeChanged(time)
|
|
63
|
+
|
|
60
64
|
let position = ["position": player.position]
|
|
61
65
|
|
|
62
66
|
onPositionChanged(position)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "expo-libvlc-player",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.2.0",
|
|
4
4
|
"description": "LibVLC Player for Expo",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"types": "build/index.d.ts",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"@eslint/js": "^9.30.0",
|
|
36
36
|
"@types/react": "~19.0.0",
|
|
37
37
|
"eslint": "^9.30.0",
|
|
38
|
-
"expo": "53.0.
|
|
38
|
+
"expo": "~53.0.23",
|
|
39
39
|
"expo-module-scripts": "^4.1.6",
|
|
40
40
|
"globals": "^16.2.0",
|
|
41
41
|
"husky": "^9.1.7",
|
|
@@ -20,13 +20,14 @@ export interface LibVlcPlayerViewRef {
|
|
|
20
20
|
*/
|
|
21
21
|
readonly stop: () => Promise<void>;
|
|
22
22
|
/**
|
|
23
|
-
* Sets the position of the current player
|
|
23
|
+
* Sets the position or time of the current player
|
|
24
24
|
*
|
|
25
|
-
* @param
|
|
25
|
+
* @param value - Must be a number equal or greater than `0`
|
|
26
|
+
* @param type - Defaults to `"position"`
|
|
26
27
|
*
|
|
27
28
|
* @returns A promise which resolves to `void`
|
|
28
29
|
*/
|
|
29
|
-
readonly seek: (
|
|
30
|
+
readonly seek: (value: number, type?: "position" | "time") => Promise<void>;
|
|
30
31
|
/**
|
|
31
32
|
* Posts an answer to a `Dialog`
|
|
32
33
|
*
|
|
@@ -126,6 +127,13 @@ type EncounteredErrorListener = (event: NativeEvent<Error>) => void;
|
|
|
126
127
|
|
|
127
128
|
export type Error = { error: string };
|
|
128
129
|
|
|
130
|
+
/**
|
|
131
|
+
* @hidden
|
|
132
|
+
*/
|
|
133
|
+
type TimeChangedListener = (event: NativeEvent<Time>) => void;
|
|
134
|
+
|
|
135
|
+
export type Time = { time: number };
|
|
136
|
+
|
|
129
137
|
/**
|
|
130
138
|
* @hidden
|
|
131
139
|
*/
|
|
@@ -178,6 +186,7 @@ export interface LibVlcPlayerViewNativeProps {
|
|
|
178
186
|
onStopped?: StoppedListener;
|
|
179
187
|
onEndReached?: EndReachedListener;
|
|
180
188
|
onEncounteredError?: EncounteredErrorListener;
|
|
189
|
+
onTimeChanged?: TimeChangedListener;
|
|
181
190
|
onPositionChanged?: PositionChangedListener;
|
|
182
191
|
onESAdded?: ESAddedListener;
|
|
183
192
|
onDialogDisplay?: DialogDisplayListener;
|
|
@@ -322,6 +331,10 @@ export interface LibVlcPlayerViewProps extends ViewProps {
|
|
|
322
331
|
* Called after the `EncounteredError` player event
|
|
323
332
|
*/
|
|
324
333
|
onEncounteredError?: (event: Error) => void;
|
|
334
|
+
/**
|
|
335
|
+
* Called after the `TimeChanged` player event
|
|
336
|
+
*/
|
|
337
|
+
onTimeChanged?: (event: Time) => void;
|
|
325
338
|
/**
|
|
326
339
|
* Called after the `PositionChanged` player event
|
|
327
340
|
*/
|
package/src/LibVlcPlayerView.tsx
CHANGED
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
LibVlcPlayerViewRef,
|
|
8
8
|
type NativeEvent,
|
|
9
9
|
type Error,
|
|
10
|
+
type Time,
|
|
10
11
|
type Position,
|
|
11
12
|
type MediaTracks,
|
|
12
13
|
type MediaInfo,
|
|
@@ -38,6 +39,12 @@ const LibVlcPlayerView = forwardRef<LibVlcPlayerViewRef, LibVlcPlayerViewProps>(
|
|
|
38
39
|
}
|
|
39
40
|
};
|
|
40
41
|
|
|
42
|
+
const onTimeChanged = ({ nativeEvent }: NativeEvent<Time>) => {
|
|
43
|
+
if (props.onTimeChanged) {
|
|
44
|
+
props.onTimeChanged(nativeEvent);
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
|
|
41
48
|
const onPositionChanged = ({ nativeEvent }: NativeEvent<Position>) => {
|
|
42
49
|
if (props.onPositionChanged) {
|
|
43
50
|
props.onPositionChanged(nativeEvent);
|
|
@@ -72,6 +79,7 @@ const LibVlcPlayerView = forwardRef<LibVlcPlayerViewRef, LibVlcPlayerViewProps>(
|
|
|
72
79
|
source: parseSource(slave.source)!,
|
|
73
80
|
}))}
|
|
74
81
|
onEncounteredError={onEncounteredError}
|
|
82
|
+
onTimeChanged={onTimeChanged}
|
|
75
83
|
onPositionChanged={onPositionChanged}
|
|
76
84
|
onESAdded={onESAdded}
|
|
77
85
|
onDialogDisplay={onDialogDisplay}
|