expo-libvlc-player 0.1.6 → 0.1.8
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 +14 -5
- package/android/build.gradle +2 -2
- package/android/src/main/java/expo/modules/libvlcplayer/VlcPlayerManager.kt +2 -2
- package/android/src/main/java/expo/modules/libvlcplayer/VlcPlayerModule.kt +1 -3
- package/android/src/main/java/expo/modules/libvlcplayer/VlcPlayerView.kt +2 -5
- package/ios/VlcPlayerManager.swift +6 -3
- package/ios/VlcPlayerModule.swift +5 -3
- package/ios/VlcPlayerView.swift +2 -5
- package/lint-staged.config.js +4 -0
- package/package.json +1 -7
- package/plugin/build/withExpoLibVlcPlayer.d.ts +1 -0
- package/plugin/build/withExpoLibVlcPlayer.js +15 -5
- package/plugin/src/withExpoLibVlcPlayer.ts +16 -2
- package/src/VlcPlayer.types.ts +11 -17
- package/src/VlcPlayerView.tsx +11 -11
- package/src/index.ts +1 -1
- package/src/utils/props.ts +3 -1
- package/build/VlcPlayer.types.d.ts +0 -297
- package/build/VlcPlayer.types.d.ts.map +0 -1
- package/build/VlcPlayer.types.js +0 -2
- package/build/VlcPlayer.types.js.map +0 -1
- package/build/VlcPlayerModule.d.ts +0 -6
- package/build/VlcPlayerModule.d.ts.map +0 -1
- package/build/VlcPlayerModule.js +0 -4
- package/build/VlcPlayerModule.js.map +0 -1
- package/build/VlcPlayerView.d.ts +0 -5
- package/build/VlcPlayerView.d.ts.map +0 -1
- package/build/VlcPlayerView.js +0 -41
- package/build/VlcPlayerView.js.map +0 -1
- package/build/index.d.ts +0 -4
- package/build/index.d.ts.map +0 -1
- package/build/index.js +0 -5
- package/build/index.js.map +0 -1
- package/build/utils/props.d.ts +0 -3
- package/build/utils/props.d.ts.map +0 -1
- package/build/utils/props.js +0 -11
- package/build/utils/props.js.map +0 -1
package/README.md
CHANGED
|
@@ -24,6 +24,14 @@ No additional configuration necessary.
|
|
|
24
24
|
|
|
25
25
|
Run `npx pod-install` after installing the npm package.
|
|
26
26
|
|
|
27
|
+
#### NSLocalNetworkUsageDescription
|
|
28
|
+
|
|
29
|
+
Starting from iOS 14, you are required to provide a message for the `NSLocalNetworkUsageDescription` key in Info.plist if your app uses the local network directly or indirectly.
|
|
30
|
+
|
|
31
|
+
It seems the `MobileVLCKit` library powering the VLC Player on iOS makes use of this feature when playing external media from sources such as RTSP streams.
|
|
32
|
+
|
|
33
|
+
Provide a custom message specifying how your app will make use of the network so your App Store submission is not rejected for this reason, read more about this [here](https://developer.apple.com/documentation/technotes/tn3179-understanding-local-network-privacy).
|
|
34
|
+
|
|
27
35
|
### Configuration in app config
|
|
28
36
|
|
|
29
37
|
You can configure `expo-libvlc-player` using its built-in config plugin if you use config plugins in your project.
|
|
@@ -37,6 +45,7 @@ You can configure `expo-libvlc-player` using its built-in config plugin if you u
|
|
|
37
45
|
[
|
|
38
46
|
"expo-libvlc-player",
|
|
39
47
|
{
|
|
48
|
+
"localNetworkPermission": "Allow $(PRODUCT_NAME) to access your local network",
|
|
40
49
|
"supportsBackgroundPlayback": true
|
|
41
50
|
}
|
|
42
51
|
]
|
|
@@ -47,9 +56,10 @@ You can configure `expo-libvlc-player` using its built-in config plugin if you u
|
|
|
47
56
|
|
|
48
57
|
#### Configurable properties
|
|
49
58
|
|
|
50
|
-
| Name | Description
|
|
51
|
-
| ---------------------------- |
|
|
52
|
-
| `
|
|
59
|
+
| Name | Description | Default |
|
|
60
|
+
| ---------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------ |
|
|
61
|
+
| `localNetworkPermission` | A string to set the `NSLocalNetworkUsageDescription` permission message on iOS | `"Allow $(PRODUCT_NAME) to access your local network"` |
|
|
62
|
+
| `supportsBackgroundPlayback` | A boolean value to enable background playback on iOS. If `true`, the `audio` key is added to the `UIBackgroundModes` array in the Info.plist file. If `false`, the key is removed. When `undefined`, the key is not modified | `undefined` |
|
|
53
63
|
|
|
54
64
|
## Usage
|
|
55
65
|
|
|
@@ -103,7 +113,7 @@ The `VLCPlayerView` extends React Native `ViewProps` and implements its own:
|
|
|
103
113
|
| ------------------- | ------------------------------------------------ | ------------------------------------------------------------------------------------------------------------- |
|
|
104
114
|
| `onBuffering` | Called after the `Buffering` player event | |
|
|
105
115
|
| `onPlaying` | Called after the `Playing` player event | |
|
|
106
|
-
| `onPaused` | Called after the `Paused` player event |
|
|
116
|
+
| `onPaused` | Called after the `Paused` player event | `{ background: boolean }` |
|
|
107
117
|
| `onStopped` | Called after the `Stopped` player event | |
|
|
108
118
|
| `onPositionChanged` | Called after the `PositionChanged` player event | `{ position: number }` |
|
|
109
119
|
| `onEnded` | Called after the `EndReached` player event | |
|
|
@@ -111,7 +121,6 @@ The `VLCPlayerView` extends React Native `ViewProps` and implements its own:
|
|
|
111
121
|
| `onWarn` | Called after the player encounters a conflict | `{ warn: string }` |
|
|
112
122
|
| `onError` | Called after the `EncounteredError` player event | `{ error: string }` |
|
|
113
123
|
| `onLoad` | Called after the `Buffering` player event | `{ width: number, height: number, aspectRatio: string, duration: number, tracks: object, seekable: boolean }` |
|
|
114
|
-
| `onBackground` | Called after the player enters the background | `{ background: boolean }` |
|
|
115
124
|
|
|
116
125
|
## Disclaimer
|
|
117
126
|
|
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 = '0.1.
|
|
4
|
+
version = '0.1.7'
|
|
5
5
|
|
|
6
6
|
def expoModulesCorePlugin = new File(project(":expo-modules-core").projectDir.absolutePath, "ExpoModulesCorePlugin.gradle")
|
|
7
7
|
apply from: expoModulesCorePlugin
|
|
@@ -35,7 +35,7 @@ android {
|
|
|
35
35
|
namespace "expo.modules.libvlcplayer"
|
|
36
36
|
defaultConfig {
|
|
37
37
|
versionCode 1
|
|
38
|
-
versionName "0.1.
|
|
38
|
+
versionName "0.1.7"
|
|
39
39
|
consumerProguardFiles("proguard-rules.pro")
|
|
40
40
|
}
|
|
41
41
|
lintOptions {
|
|
@@ -43,6 +43,8 @@ object VlcPlayerManager {
|
|
|
43
43
|
fun onAppForegrounded() {
|
|
44
44
|
views.forEach { playerView ->
|
|
45
45
|
playerView.get()?.let { view ->
|
|
46
|
+
view.isBackgrounded = false
|
|
47
|
+
|
|
46
48
|
view.mediaPlayer?.let { player ->
|
|
47
49
|
player.attachViews(
|
|
48
50
|
view.videoLayout,
|
|
@@ -68,8 +70,6 @@ object VlcPlayerManager {
|
|
|
68
70
|
views.forEach { playerView ->
|
|
69
71
|
playerView.get()?.let { view ->
|
|
70
72
|
view.isBackgrounded = true
|
|
71
|
-
val background = mapOf("background" to view.isBackgrounded)
|
|
72
|
-
view.onBackground(background)
|
|
73
73
|
|
|
74
74
|
view.mediaPlayer?.let { player ->
|
|
75
75
|
if (view.playInBackground != true && player.isPlaying()) {
|
|
@@ -17,7 +17,6 @@ private const val WARN_EVENT = "onWarn"
|
|
|
17
17
|
private const val ERROR_EVENT = "onError"
|
|
18
18
|
private const val POSITION_CHANGED_EVENT = "onPositionChanged"
|
|
19
19
|
private const val LOAD_EVENT = "onLoad"
|
|
20
|
-
private const val BACKGROUND_EVENT = "onBackground"
|
|
21
20
|
|
|
22
21
|
val playerEvents = arrayOf(
|
|
23
22
|
BUFFERING_EVENT,
|
|
@@ -29,8 +28,7 @@ val playerEvents = arrayOf(
|
|
|
29
28
|
WARN_EVENT,
|
|
30
29
|
ERROR_EVENT,
|
|
31
30
|
POSITION_CHANGED_EVENT,
|
|
32
|
-
LOAD_EVENT
|
|
33
|
-
BACKGROUND_EVENT
|
|
31
|
+
LOAD_EVENT
|
|
34
32
|
)
|
|
35
33
|
|
|
36
34
|
class VlcPlayerModule : Module() {
|
|
@@ -62,7 +62,6 @@ class VlcPlayerView(context: Context, appContext: AppContext) : ExpoView(context
|
|
|
62
62
|
private val onError by EventDispatcher()
|
|
63
63
|
private val onPositionChanged by EventDispatcher()
|
|
64
64
|
private val onLoad by EventDispatcher<WritableMap>()
|
|
65
|
-
internal val onBackground by EventDispatcher()
|
|
66
65
|
|
|
67
66
|
private lateinit var audioFocusManager: AudioFocusManager
|
|
68
67
|
|
|
@@ -163,7 +162,8 @@ class VlcPlayerView(context: Context, appContext: AppContext) : ExpoView(context
|
|
|
163
162
|
}
|
|
164
163
|
|
|
165
164
|
Event.Paused -> {
|
|
166
|
-
|
|
165
|
+
val background = mapOf("background" to isBackgrounded)
|
|
166
|
+
onPaused(background)
|
|
167
167
|
audioFocusManager.updateAudioFocus()
|
|
168
168
|
}
|
|
169
169
|
|
|
@@ -333,9 +333,6 @@ class VlcPlayerView(context: Context, appContext: AppContext) : ExpoView(context
|
|
|
333
333
|
}
|
|
334
334
|
|
|
335
335
|
fun play() {
|
|
336
|
-
isBackgrounded = false
|
|
337
|
-
val background = mapOf("background" to isBackgrounded)
|
|
338
|
-
onBackground(background)
|
|
339
336
|
mediaPlayer?.play()
|
|
340
337
|
}
|
|
341
338
|
|
|
@@ -22,12 +22,15 @@ class VlcPlayerManager {
|
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
+
func onAppForegrounded() {
|
|
26
|
+
for view in views.allObjects {
|
|
27
|
+
view.isBackgrounded = false
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
25
31
|
func onAppBackgrounded() {
|
|
26
32
|
for view in views.allObjects {
|
|
27
33
|
view.isBackgrounded = true
|
|
28
|
-
let background = ["background": view.isBackgrounded]
|
|
29
|
-
view.onBackground(background)
|
|
30
|
-
view.onBackground([:])
|
|
31
34
|
|
|
32
35
|
guard let player = view.mediaPlayer else { continue }
|
|
33
36
|
|
|
@@ -11,7 +11,6 @@ private let warnEvent = "onWarn"
|
|
|
11
11
|
private let errorEvent = "onError"
|
|
12
12
|
private let positionChangedEvent = "onPositionChanged"
|
|
13
13
|
private let loadEvent = "onLoad"
|
|
14
|
-
private let backgroundEvent = "onBackground"
|
|
15
14
|
|
|
16
15
|
let playerEvents = [
|
|
17
16
|
bufferingEvent,
|
|
@@ -23,8 +22,7 @@ let playerEvents = [
|
|
|
23
22
|
warnEvent,
|
|
24
23
|
errorEvent,
|
|
25
24
|
positionChangedEvent,
|
|
26
|
-
loadEvent
|
|
27
|
-
backgroundEvent,
|
|
25
|
+
loadEvent
|
|
28
26
|
]
|
|
29
27
|
|
|
30
28
|
public class VlcPlayerModule: Module {
|
|
@@ -111,6 +109,10 @@ public class VlcPlayerModule: Module {
|
|
|
111
109
|
}
|
|
112
110
|
}
|
|
113
111
|
|
|
112
|
+
OnAppEntersForeground {
|
|
113
|
+
VlcPlayerManager.shared.onAppForegrounded()
|
|
114
|
+
}
|
|
115
|
+
|
|
114
116
|
OnAppEntersBackground {
|
|
115
117
|
VlcPlayerManager.shared.onAppBackgrounded()
|
|
116
118
|
}
|
package/ios/VlcPlayerView.swift
CHANGED
|
@@ -37,7 +37,6 @@ class VlcPlayerView: ExpoView, VLCMediaPlayerDelegate {
|
|
|
37
37
|
private let onError = EventDispatcher()
|
|
38
38
|
private let onPositionChanged = EventDispatcher()
|
|
39
39
|
private let onLoad = EventDispatcher()
|
|
40
|
-
let onBackground = EventDispatcher()
|
|
41
40
|
|
|
42
41
|
required init(appContext: AppContext? = nil) {
|
|
43
42
|
super.init(appContext: appContext)
|
|
@@ -169,7 +168,8 @@ class VlcPlayerView: ExpoView, VLCMediaPlayerDelegate {
|
|
|
169
168
|
}
|
|
170
169
|
}
|
|
171
170
|
case .paused:
|
|
172
|
-
|
|
171
|
+
let background = ["background": isBackgrounded]
|
|
172
|
+
onPaused(background)
|
|
173
173
|
VlcPlayerManager.shared.setAppropriateAudioSessionOrWarn()
|
|
174
174
|
case .stopped:
|
|
175
175
|
onStopped([:])
|
|
@@ -312,9 +312,6 @@ class VlcPlayerView: ExpoView, VLCMediaPlayerDelegate {
|
|
|
312
312
|
}
|
|
313
313
|
|
|
314
314
|
func play() {
|
|
315
|
-
isBackgrounded = false
|
|
316
|
-
let background = ["background": isBackgrounded]
|
|
317
|
-
onBackground(background)
|
|
318
315
|
mediaPlayer?.play()
|
|
319
316
|
}
|
|
320
317
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "expo-libvlc-player",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.8",
|
|
4
4
|
"description": "LibVLC Player for Expo",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"types": "build/index.d.ts",
|
|
@@ -15,12 +15,6 @@
|
|
|
15
15
|
"open:ios": "xed example/ios",
|
|
16
16
|
"open:android": "open -a \"Android Studio\" example/android"
|
|
17
17
|
},
|
|
18
|
-
"lint-staged": {
|
|
19
|
-
"**/*.{ts,tsx,d.ts}": [
|
|
20
|
-
"eslint --fix",
|
|
21
|
-
"tsc --noEmit --skipLibCheck"
|
|
22
|
-
]
|
|
23
|
-
},
|
|
24
18
|
"keywords": [
|
|
25
19
|
"react-native",
|
|
26
20
|
"vlc",
|
|
@@ -1,18 +1,28 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const config_plugins_1 = require("expo/config-plugins");
|
|
4
|
-
const
|
|
4
|
+
const LOCAL_NETWORK_USAGE = "Allow $(PRODUCT_NAME) to access your local network";
|
|
5
|
+
const withExpoLibVlcPlayer = (config, { localNetworkPermission, supportsBackgroundPlayback } = {}) => {
|
|
6
|
+
config_plugins_1.IOSConfig.Permissions.createPermissionsPlugin({
|
|
7
|
+
NSLocalNetworkUsageDescription: LOCAL_NETWORK_USAGE,
|
|
8
|
+
})(config, {
|
|
9
|
+
NSLocalNetworkUsageDescription: localNetworkPermission,
|
|
10
|
+
});
|
|
5
11
|
(0, config_plugins_1.withInfoPlist)(config, (config) => {
|
|
6
12
|
const currentBackgroundModes = config.modResults.UIBackgroundModes ?? [];
|
|
7
13
|
const shouldEnableBackgroundAudio = supportsBackgroundPlayback;
|
|
8
|
-
if (typeof supportsBackgroundPlayback ===
|
|
14
|
+
if (typeof supportsBackgroundPlayback === "undefined") {
|
|
9
15
|
return config;
|
|
10
16
|
}
|
|
11
|
-
if (shouldEnableBackgroundAudio &&
|
|
12
|
-
|
|
17
|
+
if (shouldEnableBackgroundAudio &&
|
|
18
|
+
!currentBackgroundModes.includes("audio")) {
|
|
19
|
+
config.modResults.UIBackgroundModes = [
|
|
20
|
+
...currentBackgroundModes,
|
|
21
|
+
"audio",
|
|
22
|
+
];
|
|
13
23
|
}
|
|
14
24
|
else if (!shouldEnableBackgroundAudio) {
|
|
15
|
-
config.modResults.UIBackgroundModes = currentBackgroundModes.filter((mode) => mode !==
|
|
25
|
+
config.modResults.UIBackgroundModes = currentBackgroundModes.filter((mode) => mode !== "audio");
|
|
16
26
|
}
|
|
17
27
|
return config;
|
|
18
28
|
});
|
|
@@ -1,13 +1,27 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
type ConfigPlugin,
|
|
3
|
+
IOSConfig,
|
|
4
|
+
withInfoPlist,
|
|
5
|
+
} from "expo/config-plugins";
|
|
6
|
+
|
|
7
|
+
const LOCAL_NETWORK_USAGE =
|
|
8
|
+
"Allow $(PRODUCT_NAME) to access your local network";
|
|
2
9
|
|
|
3
10
|
type WithExpoLibVlcPlayerOptions = {
|
|
11
|
+
localNetworkPermission?: string | false;
|
|
4
12
|
supportsBackgroundPlayback?: boolean;
|
|
5
13
|
};
|
|
6
14
|
|
|
7
15
|
const withExpoLibVlcPlayer: ConfigPlugin<WithExpoLibVlcPlayerOptions> = (
|
|
8
16
|
config,
|
|
9
|
-
{ supportsBackgroundPlayback },
|
|
17
|
+
{ localNetworkPermission, supportsBackgroundPlayback } = {},
|
|
10
18
|
) => {
|
|
19
|
+
IOSConfig.Permissions.createPermissionsPlugin({
|
|
20
|
+
NSLocalNetworkUsageDescription: LOCAL_NETWORK_USAGE,
|
|
21
|
+
})(config, {
|
|
22
|
+
NSLocalNetworkUsageDescription: localNetworkPermission,
|
|
23
|
+
});
|
|
24
|
+
|
|
11
25
|
withInfoPlist(config, (config) => {
|
|
12
26
|
const currentBackgroundModes = config.modResults.UIBackgroundModes ?? [];
|
|
13
27
|
const shouldEnableBackgroundAudio = supportsBackgroundPlayback;
|
package/src/VlcPlayer.types.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
1
|
import type { ViewProps } from "react-native";
|
|
3
2
|
|
|
4
3
|
export interface VLCPlayerViewRef {
|
|
@@ -38,7 +37,14 @@ export type BufferingListener = () => void;
|
|
|
38
37
|
/**
|
|
39
38
|
* @hidden
|
|
40
39
|
*/
|
|
41
|
-
export type
|
|
40
|
+
export type PlayingListener = () => void;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* @hidden
|
|
44
|
+
*/
|
|
45
|
+
export type PausedListener = (event: { nativeEvent: Paused }) => void;
|
|
46
|
+
|
|
47
|
+
export type Paused = { background: boolean };
|
|
42
48
|
|
|
43
49
|
/**
|
|
44
50
|
* @hidden
|
|
@@ -83,13 +89,6 @@ export type PositionChanged = { position: number };
|
|
|
83
89
|
*/
|
|
84
90
|
export type LoadListener = (event: { nativeEvent: VideoInfo }) => void;
|
|
85
91
|
|
|
86
|
-
/**
|
|
87
|
-
* @hidden
|
|
88
|
-
*/
|
|
89
|
-
export type BackgroundListener = (event: { nativeEvent: Background }) => void;
|
|
90
|
-
|
|
91
|
-
export type Background = { background: boolean };
|
|
92
|
-
|
|
93
92
|
export interface Track {
|
|
94
93
|
id: number;
|
|
95
94
|
name: string;
|
|
@@ -138,8 +137,8 @@ export interface VlcPlayerViewNativeProps {
|
|
|
138
137
|
playInBackground?: boolean;
|
|
139
138
|
autoplay?: boolean;
|
|
140
139
|
onBuffering?: BufferingListener;
|
|
141
|
-
onPlaying?:
|
|
142
|
-
onPaused?:
|
|
140
|
+
onPlaying?: PlayingListener;
|
|
141
|
+
onPaused?: PausedListener;
|
|
143
142
|
onStopped?: StoppedListener;
|
|
144
143
|
onEnded?: EndedListener;
|
|
145
144
|
onRepeat?: RepeatListener;
|
|
@@ -147,7 +146,6 @@ export interface VlcPlayerViewNativeProps {
|
|
|
147
146
|
onError?: ErrorListener;
|
|
148
147
|
onPositionChanged?: PositionChangedListener;
|
|
149
148
|
onLoad?: LoadListener;
|
|
150
|
-
onBackground?: BackgroundListener;
|
|
151
149
|
}
|
|
152
150
|
|
|
153
151
|
export type AudioMixingMode =
|
|
@@ -271,7 +269,7 @@ export interface VlcPlayerViewProps extends ViewProps {
|
|
|
271
269
|
/**
|
|
272
270
|
* Event that fires when player pauses
|
|
273
271
|
*/
|
|
274
|
-
onPaused?: () => void;
|
|
272
|
+
onPaused?: (event: Paused) => void;
|
|
275
273
|
/**
|
|
276
274
|
* Event that fires when player stops
|
|
277
275
|
*/
|
|
@@ -300,8 +298,4 @@ export interface VlcPlayerViewProps extends ViewProps {
|
|
|
300
298
|
* Event that fires when player loads
|
|
301
299
|
*/
|
|
302
300
|
onLoad?: (event: VideoInfo) => void;
|
|
303
|
-
/**
|
|
304
|
-
* Event that fires when player enters the background
|
|
305
|
-
*/
|
|
306
|
-
onBackground?: (event: Background) => void;
|
|
307
301
|
}
|
package/src/VlcPlayerView.tsx
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
import { requireNativeView } from "expo";
|
|
2
|
-
import
|
|
2
|
+
import { forwardRef, type ComponentType } from "react";
|
|
3
3
|
|
|
4
4
|
import {
|
|
5
5
|
VlcPlayerViewNativeProps,
|
|
6
6
|
VlcPlayerViewProps,
|
|
7
7
|
VLCPlayerViewRef,
|
|
8
|
+
type Paused,
|
|
8
9
|
type Warn,
|
|
9
10
|
type Error,
|
|
10
11
|
type PositionChanged,
|
|
11
12
|
type VideoInfo,
|
|
12
|
-
type Background,
|
|
13
13
|
} from "./VlcPlayer.types";
|
|
14
14
|
import { convertNativeProps } from "./utils/props";
|
|
15
15
|
|
|
16
|
-
const NativeView:
|
|
16
|
+
const NativeView: ComponentType<VlcPlayerViewNativeProps> =
|
|
17
17
|
requireNativeView("ExpoLibVlcPlayer");
|
|
18
18
|
|
|
19
19
|
let loggedRenderingChildrenWarning = false;
|
|
20
20
|
|
|
21
|
-
const VlcPlayerView =
|
|
21
|
+
const VlcPlayerView = forwardRef<VLCPlayerViewRef, VlcPlayerViewProps>(
|
|
22
22
|
(props, ref) => {
|
|
23
23
|
const nativeProps = convertNativeProps(props);
|
|
24
24
|
|
|
@@ -30,6 +30,12 @@ const VlcPlayerView = React.forwardRef<VLCPlayerViewRef, VlcPlayerViewProps>(
|
|
|
30
30
|
loggedRenderingChildrenWarning = true;
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
+
const onPaused = ({ nativeEvent }: { nativeEvent: Paused }) => {
|
|
34
|
+
if (props.onPaused) {
|
|
35
|
+
props.onPaused(nativeEvent);
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
|
|
33
39
|
const onWarn = ({ nativeEvent }: { nativeEvent: Warn }) => {
|
|
34
40
|
if (props.onWarn) {
|
|
35
41
|
props.onWarn(nativeEvent);
|
|
@@ -58,21 +64,15 @@ const VlcPlayerView = React.forwardRef<VLCPlayerViewRef, VlcPlayerViewProps>(
|
|
|
58
64
|
}
|
|
59
65
|
};
|
|
60
66
|
|
|
61
|
-
const onBackground = ({ nativeEvent }: { nativeEvent: Background }) => {
|
|
62
|
-
if (props.onBackground) {
|
|
63
|
-
props.onBackground(nativeEvent);
|
|
64
|
-
}
|
|
65
|
-
};
|
|
66
|
-
|
|
67
67
|
return (
|
|
68
68
|
<NativeView
|
|
69
69
|
{...nativeProps}
|
|
70
70
|
ref={ref}
|
|
71
|
+
onPaused={onPaused}
|
|
71
72
|
onWarn={onWarn}
|
|
72
73
|
onError={onError}
|
|
73
74
|
onPositionChanged={onPositionChanged}
|
|
74
75
|
onLoad={onLoad}
|
|
75
|
-
onBackground={onBackground}
|
|
76
76
|
/>
|
|
77
77
|
);
|
|
78
78
|
},
|
package/src/index.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Reexport the native module. On native platforms, it will be resolved to
|
|
1
|
+
// Reexport the native module. On native platforms, it will be resolved to VlcPlayerModule.ts
|
|
2
2
|
export { default } from "./VlcPlayerModule";
|
|
3
3
|
export { default as VLCPlayerView } from "./VlcPlayerView";
|
|
4
4
|
export * from "./VlcPlayer.types";
|
package/src/utils/props.ts
CHANGED
|
@@ -13,7 +13,9 @@ export function convertNativeProps(
|
|
|
13
13
|
const nativeProps: VlcPlayerViewNativeProps = {};
|
|
14
14
|
|
|
15
15
|
for (const [key, value] of Object.entries(props)) {
|
|
16
|
-
|
|
16
|
+
if (key in ({} as VlcPlayerViewNativeProps)) {
|
|
17
|
+
(nativeProps as any)[key] = value;
|
|
18
|
+
}
|
|
17
19
|
}
|
|
18
20
|
|
|
19
21
|
return nativeProps;
|
|
@@ -1,297 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import type { ViewProps } from "react-native";
|
|
3
|
-
export interface VLCPlayerViewRef {
|
|
4
|
-
/**
|
|
5
|
-
* Starts playback for the current player
|
|
6
|
-
*
|
|
7
|
-
* @returns A promise which resolves to `void`
|
|
8
|
-
*/
|
|
9
|
-
readonly play: () => Promise<void>;
|
|
10
|
-
/**
|
|
11
|
-
* Pauses playback for the current player
|
|
12
|
-
*
|
|
13
|
-
* @returns A promise which resolves to `void`
|
|
14
|
-
*/
|
|
15
|
-
readonly pause: () => Promise<void>;
|
|
16
|
-
/**
|
|
17
|
-
* Stops playback for the current player
|
|
18
|
-
*
|
|
19
|
-
* @returns A promise which resolves to `void`
|
|
20
|
-
*/
|
|
21
|
-
readonly stop: () => Promise<void>;
|
|
22
|
-
/**
|
|
23
|
-
* Sets position of the current player
|
|
24
|
-
*
|
|
25
|
-
* @param position - Must be a float number between `0` and `1`
|
|
26
|
-
*
|
|
27
|
-
* @returns void
|
|
28
|
-
*/
|
|
29
|
-
readonly seek: (position: number) => Promise<void>;
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* @hidden
|
|
33
|
-
*/
|
|
34
|
-
export type BufferingListener = () => void;
|
|
35
|
-
/**
|
|
36
|
-
* @hidden
|
|
37
|
-
*/
|
|
38
|
-
export type PlayingPausedListener = () => void;
|
|
39
|
-
/**
|
|
40
|
-
* @hidden
|
|
41
|
-
*/
|
|
42
|
-
export type StoppedListener = () => void;
|
|
43
|
-
/**
|
|
44
|
-
* @hidden
|
|
45
|
-
*/
|
|
46
|
-
export type EndedListener = () => void;
|
|
47
|
-
/**
|
|
48
|
-
* @hidden
|
|
49
|
-
*/
|
|
50
|
-
export type RepeatListener = () => void;
|
|
51
|
-
/**
|
|
52
|
-
* @hidden
|
|
53
|
-
*/
|
|
54
|
-
export type WarnListener = (event: {
|
|
55
|
-
nativeEvent: Warn;
|
|
56
|
-
}) => void;
|
|
57
|
-
export type Warn = {
|
|
58
|
-
warn: string;
|
|
59
|
-
};
|
|
60
|
-
/**
|
|
61
|
-
* @hidden
|
|
62
|
-
*/
|
|
63
|
-
export type ErrorListener = (event: {
|
|
64
|
-
nativeEvent: Error;
|
|
65
|
-
}) => void;
|
|
66
|
-
export type Error = {
|
|
67
|
-
error: string;
|
|
68
|
-
};
|
|
69
|
-
/**
|
|
70
|
-
* @hidden
|
|
71
|
-
*/
|
|
72
|
-
export type PositionChangedListener = (event: {
|
|
73
|
-
nativeEvent: PositionChanged;
|
|
74
|
-
}) => void;
|
|
75
|
-
export type PositionChanged = {
|
|
76
|
-
position: number;
|
|
77
|
-
};
|
|
78
|
-
/**
|
|
79
|
-
* @hidden
|
|
80
|
-
*/
|
|
81
|
-
export type LoadListener = (event: {
|
|
82
|
-
nativeEvent: VideoInfo;
|
|
83
|
-
}) => void;
|
|
84
|
-
/**
|
|
85
|
-
* @hidden
|
|
86
|
-
*/
|
|
87
|
-
export type BackgroundListener = (event: {
|
|
88
|
-
nativeEvent: Background;
|
|
89
|
-
}) => void;
|
|
90
|
-
export type Background = {
|
|
91
|
-
background: boolean;
|
|
92
|
-
};
|
|
93
|
-
export interface Track {
|
|
94
|
-
id: number;
|
|
95
|
-
name: string;
|
|
96
|
-
}
|
|
97
|
-
export interface VideoTracks {
|
|
98
|
-
audio: Track[];
|
|
99
|
-
subtitle: Track[];
|
|
100
|
-
}
|
|
101
|
-
export interface VideoInfo {
|
|
102
|
-
width: number;
|
|
103
|
-
height: number;
|
|
104
|
-
aspectRatio: string | null;
|
|
105
|
-
duration: number;
|
|
106
|
-
tracks: VideoTracks;
|
|
107
|
-
seekable: boolean;
|
|
108
|
-
}
|
|
109
|
-
export interface Subtitle {
|
|
110
|
-
uri: string;
|
|
111
|
-
enable: boolean;
|
|
112
|
-
}
|
|
113
|
-
export interface TracksOptions {
|
|
114
|
-
audio: number;
|
|
115
|
-
subtitle: number;
|
|
116
|
-
}
|
|
117
|
-
/**
|
|
118
|
-
* @hidden
|
|
119
|
-
*/
|
|
120
|
-
export interface VlcPlayerViewNativeProps {
|
|
121
|
-
ref?: React.Ref<VLCPlayerViewRef>;
|
|
122
|
-
uri?: string;
|
|
123
|
-
subtitle?: Subtitle;
|
|
124
|
-
options?: string[];
|
|
125
|
-
volume?: number;
|
|
126
|
-
mute?: boolean;
|
|
127
|
-
rate?: number;
|
|
128
|
-
tracks?: TracksOptions;
|
|
129
|
-
time?: number;
|
|
130
|
-
repeat?: boolean;
|
|
131
|
-
aspectRatio?: string;
|
|
132
|
-
audioMixingMode?: AudioMixingMode;
|
|
133
|
-
playInBackground?: boolean;
|
|
134
|
-
autoplay?: boolean;
|
|
135
|
-
onBuffering?: BufferingListener;
|
|
136
|
-
onPlaying?: PlayingPausedListener;
|
|
137
|
-
onPaused?: PlayingPausedListener;
|
|
138
|
-
onStopped?: StoppedListener;
|
|
139
|
-
onEnded?: EndedListener;
|
|
140
|
-
onRepeat?: RepeatListener;
|
|
141
|
-
onWarn?: WarnListener;
|
|
142
|
-
onError?: ErrorListener;
|
|
143
|
-
onPositionChanged?: PositionChangedListener;
|
|
144
|
-
onLoad?: LoadListener;
|
|
145
|
-
onBackground?: BackgroundListener;
|
|
146
|
-
}
|
|
147
|
-
export type AudioMixingMode = "mixWithOthers" | "duckOthers" | "auto" | "doNotMix";
|
|
148
|
-
export interface VlcPlayerViewProps extends ViewProps {
|
|
149
|
-
/**
|
|
150
|
-
* Sets the URI of the media to be played
|
|
151
|
-
*/
|
|
152
|
-
uri: string;
|
|
153
|
-
/**
|
|
154
|
-
* Sets subtitle URI and enabled state
|
|
155
|
-
*
|
|
156
|
-
* @example
|
|
157
|
-
* ```tsx
|
|
158
|
-
* <VLCPlayerView
|
|
159
|
-
* subtitle={{
|
|
160
|
-
* uri: "file://",
|
|
161
|
-
* enable: false,
|
|
162
|
-
* }}
|
|
163
|
-
* />
|
|
164
|
-
* ```
|
|
165
|
-
*/
|
|
166
|
-
subtitle?: Subtitle;
|
|
167
|
-
/**
|
|
168
|
-
* https://wiki.videolan.org/VLC_command-line_help/
|
|
169
|
-
*
|
|
170
|
-
* Sets the VLC options to initialize the player with
|
|
171
|
-
*
|
|
172
|
-
* @example ["--network-caching=1000"]
|
|
173
|
-
*
|
|
174
|
-
* @default []
|
|
175
|
-
*
|
|
176
|
-
*/
|
|
177
|
-
options?: string[];
|
|
178
|
-
/**
|
|
179
|
-
* Controls the player volume. Must be an integer number between `0` and `100`
|
|
180
|
-
*
|
|
181
|
-
* @default 100
|
|
182
|
-
*
|
|
183
|
-
*/
|
|
184
|
-
volume?: number;
|
|
185
|
-
/**
|
|
186
|
-
* Sets the player volume to `0`
|
|
187
|
-
*
|
|
188
|
-
* @default false
|
|
189
|
-
*
|
|
190
|
-
*/
|
|
191
|
-
mute?: boolean;
|
|
192
|
-
/**
|
|
193
|
-
* Controls the player rate. Must be a float number
|
|
194
|
-
*
|
|
195
|
-
* @default 1
|
|
196
|
-
*
|
|
197
|
-
*/
|
|
198
|
-
rate?: number;
|
|
199
|
-
/**
|
|
200
|
-
* Sets the player audio and subtitle tracks, see `VideoInfo` for tracks type
|
|
201
|
-
*
|
|
202
|
-
* @example
|
|
203
|
-
* ```tsx
|
|
204
|
-
* <VLCPlayerView
|
|
205
|
-
* tracks={{
|
|
206
|
-
* audio: 1,
|
|
207
|
-
* subtitle: 2,
|
|
208
|
-
* }}
|
|
209
|
-
* />
|
|
210
|
-
* ```
|
|
211
|
-
*/
|
|
212
|
-
tracks?: TracksOptions;
|
|
213
|
-
/**
|
|
214
|
-
* Controls the player time once created. Must be an integer number in milliseconds
|
|
215
|
-
*
|
|
216
|
-
* @default 0
|
|
217
|
-
*
|
|
218
|
-
*/
|
|
219
|
-
time?: number;
|
|
220
|
-
/**
|
|
221
|
-
* Repeats media once playback is ended
|
|
222
|
-
*
|
|
223
|
-
* @default false
|
|
224
|
-
*
|
|
225
|
-
*/
|
|
226
|
-
repeat?: boolean;
|
|
227
|
-
/**
|
|
228
|
-
* Sets the player aspect ratio. Must be a valid string
|
|
229
|
-
*
|
|
230
|
-
* @example "16:9"
|
|
231
|
-
*/
|
|
232
|
-
aspectRatio?: string;
|
|
233
|
-
/**
|
|
234
|
-
* Determines how the player will interact with other audio playing in the system
|
|
235
|
-
*
|
|
236
|
-
* @default "auto"
|
|
237
|
-
*/
|
|
238
|
-
audioMixingMode?: AudioMixingMode;
|
|
239
|
-
/**
|
|
240
|
-
* Determines whether the player should continue playing after the app enters the background
|
|
241
|
-
*
|
|
242
|
-
* @default false
|
|
243
|
-
*/
|
|
244
|
-
playInBackground?: boolean;
|
|
245
|
-
/**
|
|
246
|
-
* Autoplays media once player is created
|
|
247
|
-
*
|
|
248
|
-
* @default true
|
|
249
|
-
*
|
|
250
|
-
*/
|
|
251
|
-
autoplay?: boolean;
|
|
252
|
-
/**
|
|
253
|
-
* Event that fires when player buffers
|
|
254
|
-
*/
|
|
255
|
-
onBuffering?: () => void;
|
|
256
|
-
/**
|
|
257
|
-
* Event that fires when player plays
|
|
258
|
-
*/
|
|
259
|
-
onPlaying?: () => void;
|
|
260
|
-
/**
|
|
261
|
-
* Event that fires when player pauses
|
|
262
|
-
*/
|
|
263
|
-
onPaused?: () => void;
|
|
264
|
-
/**
|
|
265
|
-
* Event that fires when player stops
|
|
266
|
-
*/
|
|
267
|
-
onStopped?: () => void;
|
|
268
|
-
/**
|
|
269
|
-
* Event that fires when player reaches an end
|
|
270
|
-
*/
|
|
271
|
-
onEnded?: () => void;
|
|
272
|
-
/**
|
|
273
|
-
* Event that fires when player repeats
|
|
274
|
-
*/
|
|
275
|
-
onRepeat?: () => void;
|
|
276
|
-
/**
|
|
277
|
-
* Event that fires when player emits a warning
|
|
278
|
-
*/
|
|
279
|
-
onWarn?: (event: Warn) => void;
|
|
280
|
-
/**
|
|
281
|
-
* Event that fires when player encounters an error
|
|
282
|
-
*/
|
|
283
|
-
onError?: (event: Error) => void;
|
|
284
|
-
/**
|
|
285
|
-
* Event that fires when player position changes
|
|
286
|
-
*/
|
|
287
|
-
onPositionChanged?: (event: PositionChanged) => void;
|
|
288
|
-
/**
|
|
289
|
-
* Event that fires when player loads
|
|
290
|
-
*/
|
|
291
|
-
onLoad?: (event: VideoInfo) => void;
|
|
292
|
-
/**
|
|
293
|
-
* Event that fires when player enters the background
|
|
294
|
-
*/
|
|
295
|
-
onBackground?: (event: Background) => void;
|
|
296
|
-
}
|
|
297
|
-
//# sourceMappingURL=VlcPlayer.types.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"VlcPlayer.types.d.ts","sourceRoot":"","sources":["../src/VlcPlayer.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAE9C,MAAM,WAAW,gBAAgB;IAC/B;;;;OAIG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IACnC;;;;OAIG;IACH,QAAQ,CAAC,KAAK,EAAE,MAAM,OAA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AAe,CAAC;IAClC;;;;OAIG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B;;;;;OAKG;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,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;IACtB;;OAEG;IACH,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,IAAI,KAAK,IAAI,CAAC;IAC/B;;OAEG;IACH,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IACjC;;OAEG;IACH,iBAAiB,CAAC,EAAE,CAAC,KAAK,EAAE,eAAe,KAAK,IAAI,CAAC;IACrD;;OAEG;IACH,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,SAAS,KAAK,IAAI,CAAC;IACpC;;OAEG;IACH,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,IAAI,CAAC;CAC5C"}
|
package/build/VlcPlayer.types.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"VlcPlayer.types.js","sourceRoot":"","sources":["../src/VlcPlayer.types.ts"],"names":[],"mappings":"","sourcesContent":["import * as React from \"react\";\nimport type { ViewProps } from \"react-native\";\n\nexport interface VLCPlayerViewRef {\n /**\n * Starts playback for the current player\n *\n * @returns A promise which resolves to `void`\n */\n readonly play: () => Promise<void>;\n /**\n * Pauses playback for the current player\n *\n * @returns A promise which resolves to `void`\n */\n readonly pause: () => Promise<void>;\n /**\n * Stops playback for the current player\n *\n * @returns A promise which resolves to `void`\n */\n readonly stop: () => Promise<void>;\n /**\n * Sets position of the current player\n *\n * @param position - Must be a float number between `0` and `1`\n *\n * @returns void\n */\n readonly seek: (position: number) => Promise<void>;\n}\n\n/**\n * @hidden\n */\nexport type BufferingListener = () => void;\n\n/**\n * @hidden\n */\nexport type PlayingPausedListener = () => void;\n\n/**\n * @hidden\n */\nexport type StoppedListener = () => void;\n\n/**\n * @hidden\n */\nexport type EndedListener = () => void;\n\n/**\n * @hidden\n */\nexport type RepeatListener = () => void;\n\n/**\n * @hidden\n */\nexport type WarnListener = (event: { nativeEvent: Warn }) => void;\n\nexport type Warn = { warn: string };\n\n/**\n * @hidden\n */\nexport type ErrorListener = (event: { nativeEvent: Error }) => void;\n\nexport type Error = { error: string };\n\n/**\n * @hidden\n */\nexport type PositionChangedListener = (event: {\n nativeEvent: PositionChanged;\n}) => void;\n\nexport type PositionChanged = { position: number };\n\n/**\n * @hidden\n */\nexport type LoadListener = (event: { nativeEvent: VideoInfo }) => void;\n\n/**\n * @hidden\n */\nexport type BackgroundListener = (event: { nativeEvent: Background }) => void;\n\nexport type Background = { background: boolean };\n\nexport interface Track {\n id: number;\n name: string;\n}\n\nexport interface VideoTracks {\n audio: Track[];\n subtitle: Track[];\n}\n\nexport interface VideoInfo {\n width: number;\n height: number;\n aspectRatio: string | null;\n duration: number;\n tracks: VideoTracks;\n seekable: boolean;\n}\n\nexport interface Subtitle {\n uri: string;\n enable: boolean;\n}\n\nexport interface TracksOptions {\n audio: number;\n subtitle: number;\n}\n\n/**\n * @hidden\n */\nexport interface VlcPlayerViewNativeProps {\n ref?: React.Ref<VLCPlayerViewRef>;\n uri?: string;\n subtitle?: Subtitle;\n options?: string[];\n volume?: number;\n mute?: boolean;\n rate?: number;\n tracks?: TracksOptions;\n time?: number;\n repeat?: boolean;\n aspectRatio?: string;\n audioMixingMode?: AudioMixingMode;\n playInBackground?: boolean;\n autoplay?: boolean;\n onBuffering?: BufferingListener;\n onPlaying?: PlayingPausedListener;\n onPaused?: PlayingPausedListener;\n onStopped?: StoppedListener;\n onEnded?: EndedListener;\n onRepeat?: RepeatListener;\n onWarn?: WarnListener;\n onError?: ErrorListener;\n onPositionChanged?: PositionChangedListener;\n onLoad?: LoadListener;\n onBackground?: BackgroundListener;\n}\n\nexport type AudioMixingMode =\n | \"mixWithOthers\"\n | \"duckOthers\"\n | \"auto\"\n | \"doNotMix\";\n\nexport interface VlcPlayerViewProps extends ViewProps {\n /**\n * Sets the URI of the media to be played\n */\n uri: string;\n /**\n * Sets subtitle URI and enabled state\n *\n * @example\n * ```tsx\n * <VLCPlayerView\n * subtitle={{\n * uri: \"file://\",\n * enable: false,\n * }}\n * />\n * ```\n */\n subtitle?: Subtitle;\n /**\n * https://wiki.videolan.org/VLC_command-line_help/\n *\n * Sets the VLC options to initialize the player with\n *\n * @example [\"--network-caching=1000\"]\n *\n * @default []\n *\n */\n options?: string[];\n /**\n * Controls the player volume. Must be an integer number between `0` and `100`\n *\n * @default 100\n *\n */\n volume?: number;\n /**\n * Sets the player volume to `0`\n *\n * @default false\n *\n */\n mute?: boolean;\n /**\n * Controls the player rate. Must be a float number\n *\n * @default 1\n *\n */\n rate?: number;\n /**\n * Sets the player audio and subtitle tracks, see `VideoInfo` for tracks type\n *\n * @example\n * ```tsx\n * <VLCPlayerView\n * tracks={{\n * audio: 1,\n * subtitle: 2,\n * }}\n * />\n * ```\n */\n tracks?: TracksOptions;\n /**\n * Controls the player time once created. Must be an integer number in milliseconds\n *\n * @default 0\n *\n */\n time?: number;\n /**\n * Repeats media once playback is ended\n *\n * @default false\n *\n */\n repeat?: boolean;\n /**\n * Sets the player aspect ratio. Must be a valid string\n *\n * @example \"16:9\"\n */\n aspectRatio?: string;\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 player should continue playing after the app enters the background\n *\n * @default false\n */\n playInBackground?: boolean;\n /**\n * Autoplays media once player is created\n *\n * @default true\n *\n */\n autoplay?: boolean;\n /**\n * Event that fires when player buffers\n */\n onBuffering?: () => void;\n /**\n * Event that fires when player plays\n */\n onPlaying?: () => void;\n /**\n * Event that fires when player pauses\n */\n onPaused?: () => void;\n /**\n * Event that fires when player stops\n */\n onStopped?: () => void;\n /**\n * Event that fires when player reaches an end\n */\n onEnded?: () => void;\n /**\n * Event that fires when player repeats\n */\n onRepeat?: () => void;\n /**\n * Event that fires when player emits a warning\n */\n onWarn?: (event: Warn) => void;\n /**\n * Event that fires when player encounters an error\n */\n onError?: (event: Error) => void;\n /**\n * Event that fires when player position changes\n */\n onPositionChanged?: (event: PositionChanged) => void;\n /**\n * Event that fires when player loads\n */\n onLoad?: (event: VideoInfo) => void;\n /**\n * Event that fires when player enters the background\n */\n onBackground?: (event: Background) => void;\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"VlcPlayerModule.d.ts","sourceRoot":"","sources":["../src/VlcPlayerModule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAuB,MAAM,MAAM,CAAC;AAGzD,OAAO,OAAO,eAAgB,SAAQ,YAAY,CAAC,EAAE,CAAC;CAAG;;AAGzD,wBAAwE"}
|
package/build/VlcPlayerModule.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"VlcPlayerModule.js","sourceRoot":"","sources":["../src/VlcPlayerModule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,mBAAmB,EAAE,MAAM,MAAM,CAAC;AAKzD,yDAAyD;AACzD,eAAe,mBAAmB,CAAkB,kBAAkB,CAAC,CAAC","sourcesContent":["import { NativeModule, requireNativeModule } from \"expo\";\n\n// eslint-disable-next-line @typescript-eslint/no-empty-object-type\ndeclare class VlcPlayerModule extends NativeModule<{}> {}\n\n// This call loads the native module object from the JSI.\nexport default requireNativeModule<VlcPlayerModule>(\"ExpoLibVlcPlayer\");\n"]}
|
package/build/VlcPlayerView.d.ts
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import { VlcPlayerViewProps, VLCPlayerViewRef } from "./VlcPlayer.types";
|
|
3
|
-
declare const VlcPlayerView: React.ForwardRefExoticComponent<VlcPlayerViewProps & React.RefAttributes<VLCPlayerViewRef>>;
|
|
4
|
-
export default VlcPlayerView;
|
|
5
|
-
//# sourceMappingURL=VlcPlayerView.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"VlcPlayerView.d.ts","sourceRoot":"","sources":["../src/VlcPlayerView.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAEL,kBAAkB,EAClB,gBAAgB,EAMjB,MAAM,mBAAmB,CAAC;AAQ3B,QAAA,MAAM,aAAa,6FA0DlB,CAAC;AAEF,eAAe,aAAa,CAAC"}
|
package/build/VlcPlayerView.js
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { requireNativeView } from "expo";
|
|
2
|
-
import * as React from "react";
|
|
3
|
-
import { convertNativeProps } from "./utils/props";
|
|
4
|
-
const NativeView = requireNativeView("ExpoLibVlcPlayer");
|
|
5
|
-
let loggedRenderingChildrenWarning = false;
|
|
6
|
-
const VlcPlayerView = React.forwardRef((props, ref) => {
|
|
7
|
-
const nativeProps = convertNativeProps(props);
|
|
8
|
-
// @ts-expect-error
|
|
9
|
-
if (nativeProps.children && !loggedRenderingChildrenWarning) {
|
|
10
|
-
console.warn("The <VLCPlayerView> component does not support children. This may lead to inconsistent behaviour or crashes. If you want to render content on top of the VLCPlayer, consider using absolute positioning.");
|
|
11
|
-
loggedRenderingChildrenWarning = true;
|
|
12
|
-
}
|
|
13
|
-
const onWarn = ({ nativeEvent }) => {
|
|
14
|
-
if (props.onWarn) {
|
|
15
|
-
props.onWarn(nativeEvent);
|
|
16
|
-
}
|
|
17
|
-
};
|
|
18
|
-
const onError = ({ nativeEvent }) => {
|
|
19
|
-
if (props.onError) {
|
|
20
|
-
props.onError(nativeEvent);
|
|
21
|
-
}
|
|
22
|
-
};
|
|
23
|
-
const onPositionChanged = ({ nativeEvent, }) => {
|
|
24
|
-
if (props.onPositionChanged) {
|
|
25
|
-
props.onPositionChanged(nativeEvent);
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
|
-
const onLoad = ({ nativeEvent }) => {
|
|
29
|
-
if (props.onLoad) {
|
|
30
|
-
props.onLoad(nativeEvent);
|
|
31
|
-
}
|
|
32
|
-
};
|
|
33
|
-
const onBackground = ({ nativeEvent }) => {
|
|
34
|
-
if (props.onBackground) {
|
|
35
|
-
props.onBackground(nativeEvent);
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
return (<NativeView {...nativeProps} ref={ref} onWarn={onWarn} onError={onError} onPositionChanged={onPositionChanged} onLoad={onLoad} onBackground={onBackground}/>);
|
|
39
|
-
});
|
|
40
|
-
export default VlcPlayerView;
|
|
41
|
-
//# sourceMappingURL=VlcPlayerView.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"VlcPlayerView.js","sourceRoot":"","sources":["../src/VlcPlayerView.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,MAAM,CAAC;AACzC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAY/B,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAEnD,MAAM,UAAU,GACd,iBAAiB,CAAC,kBAAkB,CAAC,CAAC;AAExC,IAAI,8BAA8B,GAAG,KAAK,CAAC;AAE3C,MAAM,aAAa,GAAG,KAAK,CAAC,UAAU,CACpC,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;IACb,MAAM,WAAW,GAAG,kBAAkB,CAAC,KAAK,CAAC,CAAC;IAE9C,mBAAmB;IACnB,IAAI,WAAW,CAAC,QAAQ,IAAI,CAAC,8BAA8B,EAAE,CAAC;QAC5D,OAAO,CAAC,IAAI,CACV,0MAA0M,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Y,CAAC,EAC3B,CACH,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,aAAa,CAAC","sourcesContent":["import { requireNativeView } from \"expo\";\nimport * as React from \"react\";\n\nimport {\n VlcPlayerViewNativeProps,\n VlcPlayerViewProps,\n VLCPlayerViewRef,\n type Warn,\n type Error,\n type PositionChanged,\n type VideoInfo,\n type Background,\n} from \"./VlcPlayer.types\";\nimport { convertNativeProps } from \"./utils/props\";\n\nconst NativeView: React.ComponentType<VlcPlayerViewNativeProps> =\n requireNativeView(\"ExpoLibVlcPlayer\");\n\nlet loggedRenderingChildrenWarning = false;\n\nconst VlcPlayerView = React.forwardRef<VLCPlayerViewRef, VlcPlayerViewProps>(\n (props, ref) => {\n const nativeProps = convertNativeProps(props);\n\n // @ts-expect-error\n if (nativeProps.children && !loggedRenderingChildrenWarning) {\n console.warn(\n \"The <VLCPlayerView> component does not support children. This may lead to inconsistent behaviour or crashes. If you want to render content on top of the VLCPlayer, consider using absolute positioning.\",\n );\n loggedRenderingChildrenWarning = true;\n }\n\n const onWarn = ({ nativeEvent }: { nativeEvent: Warn }) => {\n if (props.onWarn) {\n props.onWarn(nativeEvent);\n }\n };\n\n const onError = ({ nativeEvent }: { nativeEvent: Error }) => {\n if (props.onError) {\n props.onError(nativeEvent);\n }\n };\n\n const onPositionChanged = ({\n nativeEvent,\n }: {\n nativeEvent: PositionChanged;\n }) => {\n if (props.onPositionChanged) {\n props.onPositionChanged(nativeEvent);\n }\n };\n\n const onLoad = ({ nativeEvent }: { nativeEvent: VideoInfo }) => {\n if (props.onLoad) {\n props.onLoad(nativeEvent);\n }\n };\n\n const onBackground = ({ nativeEvent }: { nativeEvent: Background }) => {\n if (props.onBackground) {\n props.onBackground(nativeEvent);\n }\n };\n\n return (\n <NativeView\n {...nativeProps}\n ref={ref}\n onWarn={onWarn}\n onError={onError}\n onPositionChanged={onPositionChanged}\n onLoad={onLoad}\n onBackground={onBackground}\n />\n );\n },\n);\n\nexport default VlcPlayerView;\n"]}
|
package/build/index.d.ts
DELETED
package/build/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAC3D,cAAc,mBAAmB,CAAC"}
|
package/build/index.js
DELETED
package/build/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,uFAAuF;AACvF,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAC3D,cAAc,mBAAmB,CAAC","sourcesContent":["// Reexport the native module. On native platforms, it will be resolved to VlcPlayer.ts\nexport { default } from \"./VlcPlayerModule\";\nexport { default as VLCPlayerView } from \"./VlcPlayerView\";\nexport * from \"./VlcPlayer.types\";\n"]}
|
package/build/utils/props.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"props.d.ts","sourceRoot":"","sources":["../../src/utils/props.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,wBAAwB,EACxB,kBAAkB,EACnB,MAAM,oBAAoB,CAAC;AAE5B,wBAAgB,kBAAkB,CAChC,KAAK,CAAC,EAAE,kBAAkB,GACzB,wBAAwB,CAY1B"}
|
package/build/utils/props.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export function convertNativeProps(props) {
|
|
2
|
-
if (!props || typeof props !== "object") {
|
|
3
|
-
return {};
|
|
4
|
-
}
|
|
5
|
-
const nativeProps = {};
|
|
6
|
-
for (const [key, value] of Object.entries(props)) {
|
|
7
|
-
nativeProps[key] = value;
|
|
8
|
-
}
|
|
9
|
-
return nativeProps;
|
|
10
|
-
}
|
|
11
|
-
//# sourceMappingURL=props.js.map
|
package/build/utils/props.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"props.js","sourceRoot":"","sources":["../../src/utils/props.ts"],"names":[],"mappings":"AAKA,MAAM,UAAU,kBAAkB,CAChC,KAA0B;IAE1B,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QACxC,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,MAAM,WAAW,GAA6B,EAAE,CAAC;IAEjD,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACjD,WAAW,CAAC,GAAqC,CAAC,GAAG,KAAK,CAAC;IAC7D,CAAC;IAED,OAAO,WAAW,CAAC;AACrB,CAAC","sourcesContent":["import {\n VlcPlayerViewNativeProps,\n VlcPlayerViewProps,\n} from \"../VlcPlayer.types\";\n\nexport function convertNativeProps(\n props?: VlcPlayerViewProps,\n): VlcPlayerViewNativeProps {\n if (!props || typeof props !== \"object\") {\n return {};\n }\n\n const nativeProps: VlcPlayerViewNativeProps = {};\n\n for (const [key, value] of Object.entries(props)) {\n nativeProps[key as keyof VlcPlayerViewNativeProps] = value;\n }\n\n return nativeProps;\n}\n"]}
|