expo-libvlc-player 0.1.3 → 0.1.5
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 +7 -6
- package/android/.idea/workspace.xml +21 -16
- package/android/build.gradle +5 -5
- package/android/src/main/java/expo/modules/libvlcplayer/VlcPlayerManager.kt +12 -10
- package/android/src/main/java/expo/modules/libvlcplayer/VlcPlayerModule.kt +8 -4
- package/android/src/main/java/expo/modules/libvlcplayer/VlcPlayerView.kt +59 -18
- package/build/VlcPlayer.types.d.ts +28 -9
- package/build/VlcPlayer.types.d.ts.map +1 -1
- package/build/VlcPlayer.types.js.map +1 -1
- package/build/VlcPlayerView.d.ts.map +1 -1
- package/build/VlcPlayerView.js +6 -1
- package/build/VlcPlayerView.js.map +1 -1
- package/ios/VlcPlayerManager.swift +3 -0
- package/ios/VlcPlayerModule.swift +7 -3
- package/ios/VlcPlayerView.swift +65 -31
- package/package.json +2 -2
- package/src/VlcPlayer.types.ts +25 -9
- package/src/VlcPlayerView.tsx +8 -0
package/README.md
CHANGED
|
@@ -30,7 +30,7 @@ Run `npx pod-install` after installing the npm package.
|
|
|
30
30
|
import { VLCPLayerView } from "expo-libvlc-player";
|
|
31
31
|
|
|
32
32
|
return (
|
|
33
|
-
<View styles={{ height:
|
|
33
|
+
<View styles={{ height: videoHeight }}>
|
|
34
34
|
<VLCPlayerView
|
|
35
35
|
style={{ height: "100%" }}
|
|
36
36
|
uri="http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4"
|
|
@@ -52,19 +52,20 @@ See the [example app](example/App.tsx) for additional usage.
|
|
|
52
52
|
|
|
53
53
|
### Player props
|
|
54
54
|
|
|
55
|
-
The `VLCPlayerView` extends React Native `ViewProps` and implements
|
|
55
|
+
The `VLCPlayerView` extends React Native `ViewProps` and implements its own:
|
|
56
56
|
|
|
57
57
|
| Prop | Description | Default |
|
|
58
58
|
| ------------------ | ----------------------------------------------------------------------------------------- | -------- |
|
|
59
59
|
| `uri` | Sets the URI of the media to be played | |
|
|
60
60
|
| `subtitle` | Sets subtitle URI and enabled state | |
|
|
61
61
|
| `options` | Sets the VLC options to initialize the player with | `[]` |
|
|
62
|
-
| `volume` | Controls the player volume
|
|
62
|
+
| `volume` | Controls the player volume. Must be an integer number between `0` and `100` | `100` |
|
|
63
63
|
| `mute` | Sets the player volume to `0` | `false` |
|
|
64
|
-
| `rate` | Controls the player rate
|
|
64
|
+
| `rate` | Controls the player rate. Must be a float number between `0` and `1` | `1` |
|
|
65
65
|
| `tracks` | Sets the player audio and subtitle tracks | |
|
|
66
|
+
| `time` | Controls the player time once created. Must be an integer number in milliseconds | `0` |
|
|
66
67
|
| `repeat` | Repeats the media once playback is ended | `false` |
|
|
67
|
-
| `aspectRatio` | Sets the player aspect ratio
|
|
68
|
+
| `aspectRatio` | Sets the player aspect ratio. Must be a valid `string` | |
|
|
68
69
|
| `audioMixingMode` | Determines how the player will interact with other audio playing in the system | `"auto"` |
|
|
69
70
|
| `playInBackground` | Determines whether the player should continue playing after the app enters the background | `false` |
|
|
70
71
|
| `autoplay` | Autoplays media once player is created | `true` |
|
|
@@ -83,7 +84,7 @@ The `VLCPlayerView` extends React Native `ViewProps` and implements it's own:
|
|
|
83
84
|
| `onWarn` | Called after the player encounters a conflict | `{ warn: string }` |
|
|
84
85
|
| `onError` | Called after the `EncounteredError` player event | `{ error: string }` |
|
|
85
86
|
| `onLoad` | Called after the `Buffering` player event | `{ width: number, height: number, aspectRatio: string, duration: number, tracks: object, seekable: boolean }` |
|
|
86
|
-
| `onBackground` | Called after the player enters the background |
|
|
87
|
+
| `onBackground` | Called after the player enters the background | `{ background: boolean }` |
|
|
87
88
|
|
|
88
89
|
## Disclaimer
|
|
89
90
|
|
|
@@ -5,9 +5,14 @@
|
|
|
5
5
|
</component>
|
|
6
6
|
<component name="ChangeListManager">
|
|
7
7
|
<list default="true" id="ce1cf2d7-3e2c-41b3-ae06-62438ddceca7" name="Changes" comment="">
|
|
8
|
+
<change beforePath="$PROJECT_DIR$/../README.md" beforeDir="false" afterPath="$PROJECT_DIR$/../README.md" afterDir="false" />
|
|
9
|
+
<change beforePath="$PROJECT_DIR$/src/main/java/expo/modules/libvlcplayer/VlcPlayerManager.kt" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/expo/modules/libvlcplayer/VlcPlayerManager.kt" afterDir="false" />
|
|
10
|
+
<change beforePath="$PROJECT_DIR$/src/main/java/expo/modules/libvlcplayer/VlcPlayerModule.kt" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/expo/modules/libvlcplayer/VlcPlayerModule.kt" afterDir="false" />
|
|
8
11
|
<change beforePath="$PROJECT_DIR$/src/main/java/expo/modules/libvlcplayer/VlcPlayerView.kt" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/expo/modules/libvlcplayer/VlcPlayerView.kt" afterDir="false" />
|
|
9
12
|
<change beforePath="$PROJECT_DIR$/../example/App.tsx" beforeDir="false" afterPath="$PROJECT_DIR$/../example/App.tsx" afterDir="false" />
|
|
13
|
+
<change beforePath="$PROJECT_DIR$/../ios/VlcPlayerModule.swift" beforeDir="false" afterPath="$PROJECT_DIR$/../ios/VlcPlayerModule.swift" afterDir="false" />
|
|
10
14
|
<change beforePath="$PROJECT_DIR$/../ios/VlcPlayerView.swift" beforeDir="false" afterPath="$PROJECT_DIR$/../ios/VlcPlayerView.swift" afterDir="false" />
|
|
15
|
+
<change beforePath="$PROJECT_DIR$/../src/VlcPlayer.types.ts" beforeDir="false" afterPath="$PROJECT_DIR$/../src/VlcPlayer.types.ts" afterDir="false" />
|
|
11
16
|
</list>
|
|
12
17
|
<option name="SHOW_DIALOG" value="false" />
|
|
13
18
|
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
|
@@ -46,23 +51,23 @@
|
|
|
46
51
|
<option name="hideEmptyMiddlePackages" value="true" />
|
|
47
52
|
<option name="showLibraryContents" value="true" />
|
|
48
53
|
</component>
|
|
49
|
-
<component name="PropertiesComponent"
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
54
|
+
<component name="PropertiesComponent">{
|
|
55
|
+
"keyToString": {
|
|
56
|
+
"ModuleVcsDetector.initialDetectionPerformed": "true",
|
|
57
|
+
"RunOnceActivity.ShowReadmeOnStart": "true",
|
|
58
|
+
"RunOnceActivity.cidr.known.project.marker": "true",
|
|
59
|
+
"RunOnceActivity.git.unshallow": "true",
|
|
60
|
+
"RunOnceActivity.readMode.enableVisualFormatting": "true",
|
|
61
|
+
"android.gradle.sync.needed": "true",
|
|
62
|
+
"cf.first.check.clang-format": "false",
|
|
63
|
+
"cidr.known.project.marker": "true",
|
|
64
|
+
"git-widget-placeholder": "master",
|
|
65
|
+
"ignore.virus.scanning.warn.message": "true",
|
|
66
|
+
"kotlin-language-version-configured": "true",
|
|
67
|
+
"last_opened_file_path": "//wsl.localhost/Ubuntu/home/rarbit/dev/expo-libvlc-player/android",
|
|
68
|
+
"settings.editor.selected.configurable": "preferences.sourceCode"
|
|
64
69
|
}
|
|
65
|
-
}
|
|
70
|
+
}</component>
|
|
66
71
|
<component name="TaskManager">
|
|
67
72
|
<task active="true" id="Default" summary="Default task">
|
|
68
73
|
<changelist id="ce1cf2d7-3e2c-41b3-ae06-62438ddceca7" name="Changes" comment="" />
|
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.5'
|
|
5
5
|
|
|
6
6
|
def expoModulesCorePlugin = new File(project(":expo-modules-core").projectDir.absolutePath, "ExpoModulesCorePlugin.gradle")
|
|
7
7
|
apply from: expoModulesCorePlugin
|
|
@@ -23,10 +23,10 @@ if (useManagedAndroidSdkVersions) {
|
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
25
|
project.android {
|
|
26
|
-
compileSdkVersion safeExtGet("compileSdkVersion",
|
|
26
|
+
compileSdkVersion safeExtGet("compileSdkVersion", 35)
|
|
27
27
|
defaultConfig {
|
|
28
|
-
minSdkVersion safeExtGet("minSdkVersion",
|
|
29
|
-
targetSdkVersion safeExtGet("targetSdkVersion",
|
|
28
|
+
minSdkVersion safeExtGet("minSdkVersion", 25)
|
|
29
|
+
targetSdkVersion safeExtGet("targetSdkVersion", 35)
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
32
|
}
|
|
@@ -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.5"
|
|
39
39
|
consumerProguardFiles("proguard-rules.pro")
|
|
40
40
|
}
|
|
41
41
|
lintOptions {
|
|
@@ -41,11 +41,11 @@ object VlcPlayerManager {
|
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
fun onAppForegrounded() {
|
|
44
|
-
views.forEach {
|
|
45
|
-
|
|
46
|
-
|
|
44
|
+
views.forEach { playerView ->
|
|
45
|
+
playerView.get()?.let { view ->
|
|
46
|
+
view.mediaPlayer?.let { player ->
|
|
47
47
|
player.attachViews(
|
|
48
|
-
|
|
48
|
+
view.videoLayout,
|
|
49
49
|
null,
|
|
50
50
|
ENABLE_SUBTITLES,
|
|
51
51
|
USE_TEXTURE_VIEW
|
|
@@ -65,12 +65,14 @@ object VlcPlayerManager {
|
|
|
65
65
|
}
|
|
66
66
|
|
|
67
67
|
fun onAppBackgrounded() {
|
|
68
|
-
views.forEach {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
68
|
+
views.forEach { playerView ->
|
|
69
|
+
playerView.get()?.let { view ->
|
|
70
|
+
view.isBackgrounded = true
|
|
71
|
+
val background = mapOf("background" to view.isBackgrounded)
|
|
72
|
+
view.onBackground(background)
|
|
73
|
+
|
|
74
|
+
view.mediaPlayer?.let { player ->
|
|
75
|
+
if (view.playInBackground != true && player.isPlaying()) {
|
|
74
76
|
player.pause()
|
|
75
77
|
}
|
|
76
78
|
|
|
@@ -57,7 +57,7 @@ class VlcPlayerModule : Module() {
|
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
Prop("options") { view: VlcPlayerView, options: ArrayList<String>? ->
|
|
60
|
-
view.options = options
|
|
60
|
+
view.options = options
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
Prop("volume") { view: VlcPlayerView, volume: Int? ->
|
|
@@ -76,6 +76,10 @@ class VlcPlayerModule : Module() {
|
|
|
76
76
|
view.setTracks(tracks)
|
|
77
77
|
}
|
|
78
78
|
|
|
79
|
+
Prop("time") { view: VlcPlayerView, time: Int? ->
|
|
80
|
+
view.time = time ?: DEFAULT_PLAYER_START
|
|
81
|
+
}
|
|
82
|
+
|
|
79
83
|
Prop("repeat") { view: VlcPlayerView, repeat: Boolean? ->
|
|
80
84
|
view.setRepeat(repeat ?: false)
|
|
81
85
|
}
|
|
@@ -84,12 +88,12 @@ class VlcPlayerModule : Module() {
|
|
|
84
88
|
view.setAspectRatio(aspectRatio)
|
|
85
89
|
}
|
|
86
90
|
|
|
87
|
-
Prop("audioMixingMode") { view: VlcPlayerView, audioMixingMode: AudioMixingMode ->
|
|
91
|
+
Prop("audioMixingMode") { view: VlcPlayerView, audioMixingMode: AudioMixingMode? ->
|
|
88
92
|
view.audioMixingMode = audioMixingMode
|
|
89
93
|
}
|
|
90
94
|
|
|
91
95
|
Prop("playInBackground") { view: VlcPlayerView, playInBackground: Boolean? ->
|
|
92
|
-
view.playInBackground = playInBackground
|
|
96
|
+
view.playInBackground = playInBackground
|
|
93
97
|
}
|
|
94
98
|
|
|
95
99
|
Prop("autoplay") { view: VlcPlayerView, autoplay: Boolean? ->
|
|
@@ -97,7 +101,7 @@ class VlcPlayerModule : Module() {
|
|
|
97
101
|
}
|
|
98
102
|
|
|
99
103
|
OnViewDidUpdateProps { view: VlcPlayerView ->
|
|
100
|
-
view.
|
|
104
|
+
view.initPlayer()
|
|
101
105
|
}
|
|
102
106
|
|
|
103
107
|
OnViewDestroys { view: VlcPlayerView ->
|
|
@@ -25,6 +25,7 @@ import org.videolan.libvlc.interfaces.IMedia
|
|
|
25
25
|
import java.util.UUID
|
|
26
26
|
|
|
27
27
|
const val DEFAULT_PLAYER_RATE: Float = 1f
|
|
28
|
+
const val DEFAULT_PLAYER_START: Int = 0
|
|
28
29
|
const val MIN_PLAYER_VOLUME: Int = 0
|
|
29
30
|
const val MAX_PLAYER_VOLUME: Int = 100
|
|
30
31
|
const val PLAYER_VOLUME_STEP: Int = 10
|
|
@@ -42,7 +43,10 @@ class VlcPlayerView(context: Context, appContext: AppContext) : ExpoView(context
|
|
|
42
43
|
|
|
43
44
|
private var libVLC: LibVLC? = null
|
|
44
45
|
internal var mediaPlayer: MediaPlayer? = null
|
|
45
|
-
|
|
46
|
+
private var shouldInit: Boolean = true
|
|
47
|
+
private var shouldCreate: Boolean = true
|
|
48
|
+
private var hasLoaded: Boolean = false
|
|
49
|
+
internal var isBackgrounded: Boolean = false
|
|
46
50
|
|
|
47
51
|
private var userVolume: Int = MAX_PLAYER_VOLUME
|
|
48
52
|
private var repeat: Boolean = false
|
|
@@ -67,21 +71,34 @@ class VlcPlayerView(context: Context, appContext: AppContext) : ExpoView(context
|
|
|
67
71
|
audioFocusManager = VlcPlayerManager.audioFocusManager
|
|
68
72
|
}
|
|
69
73
|
|
|
70
|
-
fun
|
|
71
|
-
if (!
|
|
74
|
+
fun initPlayer() {
|
|
75
|
+
if (!shouldInit) return
|
|
76
|
+
|
|
77
|
+
if (shouldCreate) {
|
|
78
|
+
destroyPlayer()
|
|
79
|
+
createPlayer()
|
|
80
|
+
}
|
|
72
81
|
|
|
73
|
-
|
|
82
|
+
startPlayer()
|
|
74
83
|
|
|
84
|
+
shouldInit = false
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
fun createPlayer() {
|
|
75
88
|
libVLC = LibVLC(context, options)
|
|
76
89
|
mediaPlayer = MediaPlayer(libVLC)
|
|
77
90
|
|
|
78
|
-
mediaPlayer
|
|
91
|
+
mediaPlayer!!.let { player ->
|
|
79
92
|
player.setEventListener(EventListener { event ->
|
|
80
93
|
when (event.type) {
|
|
81
94
|
Event.Buffering -> {
|
|
82
|
-
|
|
95
|
+
if (!isBackgrounded) {
|
|
96
|
+
onBuffering(mapOf())
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
val video = player.getCurrentVideoTrack()
|
|
83
100
|
|
|
84
|
-
if (
|
|
101
|
+
if (video != null && !hasLoaded) {
|
|
85
102
|
val audioTracks = Arguments.createArray()
|
|
86
103
|
|
|
87
104
|
if (player.getAudioTracksCount() > 0) {
|
|
@@ -109,7 +126,6 @@ class VlcPlayerView(context: Context, appContext: AppContext) : ExpoView(context
|
|
|
109
126
|
}
|
|
110
127
|
}
|
|
111
128
|
|
|
112
|
-
val video = player.getCurrentVideoTrack()
|
|
113
129
|
val ratio = player.getAspectRatio()
|
|
114
130
|
val length = player.getLength()
|
|
115
131
|
val tracks = Arguments.createMap().apply {
|
|
@@ -128,12 +144,22 @@ class VlcPlayerView(context: Context, appContext: AppContext) : ExpoView(context
|
|
|
128
144
|
}
|
|
129
145
|
|
|
130
146
|
onLoad(videoInfo)
|
|
147
|
+
hasLoaded = true
|
|
131
148
|
}
|
|
132
149
|
}
|
|
133
150
|
|
|
134
151
|
Event.Playing -> {
|
|
135
152
|
onPlaying(mapOf())
|
|
136
153
|
audioFocusManager.updateAudioFocus()
|
|
154
|
+
|
|
155
|
+
if (player.isSeekable()) {
|
|
156
|
+
val timestamp = time ?: DEFAULT_PLAYER_START
|
|
157
|
+
|
|
158
|
+
if (timestamp != DEFAULT_PLAYER_START) {
|
|
159
|
+
player.setTime(timestamp.toLong())
|
|
160
|
+
time = DEFAULT_PLAYER_START
|
|
161
|
+
}
|
|
162
|
+
}
|
|
137
163
|
}
|
|
138
164
|
|
|
139
165
|
Event.Paused -> {
|
|
@@ -156,13 +182,13 @@ class VlcPlayerView(context: Context, appContext: AppContext) : ExpoView(context
|
|
|
156
182
|
|
|
157
183
|
Event.EndReached -> {
|
|
158
184
|
onEnded(mapOf())
|
|
185
|
+
player.stop()
|
|
159
186
|
|
|
160
|
-
val manualRepeat =
|
|
187
|
+
val manualRepeat = options?.hasRepeatOptions() == false && repeat
|
|
161
188
|
|
|
162
189
|
if (manualRepeat) {
|
|
163
|
-
player.stop()
|
|
164
|
-
player.play()
|
|
165
190
|
onRepeat(mapOf())
|
|
191
|
+
player.play()
|
|
166
192
|
}
|
|
167
193
|
}
|
|
168
194
|
|
|
@@ -174,10 +200,18 @@ class VlcPlayerView(context: Context, appContext: AppContext) : ExpoView(context
|
|
|
174
200
|
})
|
|
175
201
|
|
|
176
202
|
player.attachViews(videoLayout, null, ENABLE_SUBTITLES, USE_TEXTURE_VIEW)
|
|
203
|
+
}
|
|
177
204
|
|
|
205
|
+
shouldCreate = false
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
|
|
209
|
+
fun startPlayer() {
|
|
210
|
+
mediaPlayer?.let { player ->
|
|
178
211
|
try {
|
|
179
212
|
val media = Media(libVLC, Uri.parse(uri))
|
|
180
213
|
player.setMedia(media)
|
|
214
|
+
hasLoaded = false
|
|
181
215
|
} catch (_: Exception) {
|
|
182
216
|
val error = mapOf("error" to "Invalid URI, media could not be set")
|
|
183
217
|
onError(error)
|
|
@@ -187,8 +221,6 @@ class VlcPlayerView(context: Context, appContext: AppContext) : ExpoView(context
|
|
|
187
221
|
player.play()
|
|
188
222
|
}
|
|
189
223
|
}
|
|
190
|
-
|
|
191
|
-
shouldCreate = false
|
|
192
224
|
}
|
|
193
225
|
|
|
194
226
|
fun destroyPlayer() {
|
|
@@ -205,7 +237,7 @@ class VlcPlayerView(context: Context, appContext: AppContext) : ExpoView(context
|
|
|
205
237
|
val old = field
|
|
206
238
|
field = value
|
|
207
239
|
|
|
208
|
-
|
|
240
|
+
shouldInit = value != old
|
|
209
241
|
}
|
|
210
242
|
|
|
211
243
|
fun setSubtitle(subtitle: ReadableMap?) {
|
|
@@ -224,11 +256,12 @@ class VlcPlayerView(context: Context, appContext: AppContext) : ExpoView(context
|
|
|
224
256
|
}
|
|
225
257
|
}
|
|
226
258
|
|
|
227
|
-
var options: ArrayList<String
|
|
259
|
+
var options: ArrayList<String>? = ArrayList<String>()
|
|
228
260
|
set(value) {
|
|
229
261
|
val old = field
|
|
230
262
|
field = value
|
|
231
263
|
|
|
264
|
+
shouldInit = value != old
|
|
232
265
|
shouldCreate = value != old
|
|
233
266
|
}
|
|
234
267
|
|
|
@@ -265,8 +298,13 @@ class VlcPlayerView(context: Context, appContext: AppContext) : ExpoView(context
|
|
|
265
298
|
}
|
|
266
299
|
}
|
|
267
300
|
|
|
301
|
+
var time: Int? = DEFAULT_PLAYER_START
|
|
302
|
+
set(value) {
|
|
303
|
+
field = value
|
|
304
|
+
}
|
|
305
|
+
|
|
268
306
|
fun setRepeat(repeat: Boolean) {
|
|
269
|
-
if (repeat && options
|
|
307
|
+
if (repeat && options?.hasRepeatOptions() == true) {
|
|
270
308
|
val warn = mapOf("warn" to "Repeat already enabled in options")
|
|
271
309
|
return onWarn(warn)
|
|
272
310
|
}
|
|
@@ -278,13 +316,13 @@ class VlcPlayerView(context: Context, appContext: AppContext) : ExpoView(context
|
|
|
278
316
|
mediaPlayer?.setAspectRatio(aspectRatio)
|
|
279
317
|
}
|
|
280
318
|
|
|
281
|
-
var audioMixingMode: AudioMixingMode = AudioMixingMode.AUTO
|
|
319
|
+
var audioMixingMode: AudioMixingMode? = AudioMixingMode.AUTO
|
|
282
320
|
set(value) {
|
|
283
321
|
field = value
|
|
284
322
|
audioFocusManager.updateAudioFocus()
|
|
285
323
|
}
|
|
286
324
|
|
|
287
|
-
var playInBackground: Boolean = false
|
|
325
|
+
var playInBackground: Boolean? = false
|
|
288
326
|
set(value) {
|
|
289
327
|
field = value
|
|
290
328
|
audioFocusManager.updateAudioFocus()
|
|
@@ -295,6 +333,9 @@ class VlcPlayerView(context: Context, appContext: AppContext) : ExpoView(context
|
|
|
295
333
|
}
|
|
296
334
|
|
|
297
335
|
fun play() {
|
|
336
|
+
isBackgrounded = false
|
|
337
|
+
val background = mapOf("background" to isBackgrounded)
|
|
338
|
+
onBackground(background)
|
|
298
339
|
mediaPlayer?.play()
|
|
299
340
|
}
|
|
300
341
|
|
|
@@ -4,19 +4,19 @@ export interface VLCPlayerViewRef {
|
|
|
4
4
|
/**
|
|
5
5
|
* Starts playback for the current player
|
|
6
6
|
*
|
|
7
|
-
* @returns void
|
|
7
|
+
* @returns A promise which resolves to `void`
|
|
8
8
|
*/
|
|
9
9
|
readonly play: () => Promise<void>;
|
|
10
10
|
/**
|
|
11
11
|
* Pauses playback for the current player
|
|
12
12
|
*
|
|
13
|
-
* @returns void
|
|
13
|
+
* @returns A promise which resolves to `void`
|
|
14
14
|
*/
|
|
15
15
|
readonly pause: () => Promise<void>;
|
|
16
16
|
/**
|
|
17
17
|
* Stops playback for the current player
|
|
18
18
|
*
|
|
19
|
-
* @returns void
|
|
19
|
+
* @returns A promise which resolves to `void`
|
|
20
20
|
*/
|
|
21
21
|
readonly stop: () => Promise<void>;
|
|
22
22
|
/**
|
|
@@ -84,7 +84,12 @@ export type LoadListener = (event: {
|
|
|
84
84
|
/**
|
|
85
85
|
* @hidden
|
|
86
86
|
*/
|
|
87
|
-
export type BackgroundListener = (
|
|
87
|
+
export type BackgroundListener = (event: {
|
|
88
|
+
nativeEvent: Background;
|
|
89
|
+
}) => void;
|
|
90
|
+
export type Background = {
|
|
91
|
+
background: boolean;
|
|
92
|
+
};
|
|
88
93
|
export interface Track {
|
|
89
94
|
id: number;
|
|
90
95
|
name: string;
|
|
@@ -121,6 +126,7 @@ export interface VlcPlayerViewNativeProps {
|
|
|
121
126
|
mute?: boolean;
|
|
122
127
|
rate?: number;
|
|
123
128
|
tracks?: TracksOptions;
|
|
129
|
+
time?: number;
|
|
124
130
|
repeat?: boolean;
|
|
125
131
|
aspectRatio?: string;
|
|
126
132
|
audioMixingMode?: AudioMixingMode;
|
|
@@ -170,7 +176,7 @@ export interface VlcPlayerViewProps extends ViewProps {
|
|
|
170
176
|
*/
|
|
171
177
|
options?: string[];
|
|
172
178
|
/**
|
|
173
|
-
* Controls the player volume
|
|
179
|
+
* Controls the player volume. Must be an integer number between `0` and `100`
|
|
174
180
|
*
|
|
175
181
|
* @default 100
|
|
176
182
|
*
|
|
@@ -178,10 +184,13 @@ export interface VlcPlayerViewProps extends ViewProps {
|
|
|
178
184
|
volume?: number;
|
|
179
185
|
/**
|
|
180
186
|
* Sets the player volume to `0`
|
|
187
|
+
*
|
|
188
|
+
* @default false
|
|
189
|
+
*
|
|
181
190
|
*/
|
|
182
191
|
mute?: boolean;
|
|
183
192
|
/**
|
|
184
|
-
* Controls the player rate
|
|
193
|
+
* Controls the player rate. Must be a float number
|
|
185
194
|
*
|
|
186
195
|
* @default 1
|
|
187
196
|
*
|
|
@@ -201,12 +210,22 @@ export interface VlcPlayerViewProps extends ViewProps {
|
|
|
201
210
|
* ```
|
|
202
211
|
*/
|
|
203
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;
|
|
204
220
|
/**
|
|
205
221
|
* Repeats media once playback is ended
|
|
222
|
+
*
|
|
223
|
+
* @default false
|
|
224
|
+
*
|
|
206
225
|
*/
|
|
207
226
|
repeat?: boolean;
|
|
208
227
|
/**
|
|
209
|
-
* Sets the player aspect ratio
|
|
228
|
+
* Sets the player aspect ratio. Must be a valid string
|
|
210
229
|
*
|
|
211
230
|
* @example "16:9"
|
|
212
231
|
*/
|
|
@@ -214,7 +233,7 @@ export interface VlcPlayerViewProps extends ViewProps {
|
|
|
214
233
|
/**
|
|
215
234
|
* Determines how the player will interact with other audio playing in the system
|
|
216
235
|
*
|
|
217
|
-
* @default
|
|
236
|
+
* @default "auto"
|
|
218
237
|
*/
|
|
219
238
|
audioMixingMode?: AudioMixingMode;
|
|
220
239
|
/**
|
|
@@ -273,6 +292,6 @@ export interface VlcPlayerViewProps extends ViewProps {
|
|
|
273
292
|
/**
|
|
274
293
|
* Event that fires when player enters the background
|
|
275
294
|
*/
|
|
276
|
-
onBackground?: () => void;
|
|
295
|
+
onBackground?: (event: Background) => void;
|
|
277
296
|
}
|
|
278
297
|
//# sourceMappingURL=VlcPlayer.types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
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,OAAO,CAAC,IAAI,CAAC,CAAC;IACpC;;;;OAIG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IACnC;;;;;;OAMG;IACH,QAAQ,CAAC,IAAI,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CACpD;AAED;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG,MAAM,IAAI,CAAC;AAE3C;;GAEG;AACH,MAAM,MAAM,qBAAqB,GAAG,MAAM,IAAI,CAAC;AAE/C;;GAEG;AACH,MAAM,MAAM,eAAe,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eAAe,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"}
|
|
@@ -1 +1 @@
|
|
|
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 void
|
|
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 +1 @@
|
|
|
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,
|
|
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
CHANGED
|
@@ -30,7 +30,12 @@ const VlcPlayerView = React.forwardRef((props, ref) => {
|
|
|
30
30
|
props.onLoad(nativeEvent);
|
|
31
31
|
}
|
|
32
32
|
};
|
|
33
|
-
|
|
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}/>);
|
|
34
39
|
});
|
|
35
40
|
export default VlcPlayerView;
|
|
36
41
|
//# sourceMappingURL=VlcPlayerView.js.map
|
|
@@ -1 +1 @@
|
|
|
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;
|
|
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,CAC3M,CAAC;QACF,8BAA8B,GAAG,IAAI,CAAC;IACxC,CAAC;IAED,MAAM,MAAM,GAAG,CAA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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"]}
|
|
@@ -24,6 +24,9 @@ class VlcPlayerManager {
|
|
|
24
24
|
|
|
25
25
|
func onAppBackgrounded() {
|
|
26
26
|
for view in views.allObjects {
|
|
27
|
+
view.isBackgrounded = true
|
|
28
|
+
let background = ["background": view.isBackgrounded]
|
|
29
|
+
view.onBackground(background)
|
|
27
30
|
view.onBackground([:])
|
|
28
31
|
|
|
29
32
|
guard let player = view.mediaPlayer else { continue }
|
|
@@ -66,6 +66,10 @@ public class VlcPlayerModule: Module {
|
|
|
66
66
|
view.setTracks(tracks)
|
|
67
67
|
}
|
|
68
68
|
|
|
69
|
+
Prop("time") { (view: VlcPlayerView, time: Int?) in
|
|
70
|
+
view.setTime(time ?? defaultPlayerStart)
|
|
71
|
+
}
|
|
72
|
+
|
|
69
73
|
Prop("repeat") { (view: VlcPlayerView, shouldRepeat: Bool?) in
|
|
70
74
|
view.setRepeat(shouldRepeat ?? false)
|
|
71
75
|
}
|
|
@@ -74,8 +78,8 @@ public class VlcPlayerModule: Module {
|
|
|
74
78
|
view.setAspectRatio(aspectRatio)
|
|
75
79
|
}
|
|
76
80
|
|
|
77
|
-
Prop("audioMixingMode") { (view: VlcPlayerView, audioMixingMode: AudioMixingMode) in
|
|
78
|
-
view.setAudioMixingMode(audioMixingMode)
|
|
81
|
+
Prop("audioMixingMode") { (view: VlcPlayerView, audioMixingMode: AudioMixingMode?) in
|
|
82
|
+
view.setAudioMixingMode(audioMixingMode ?? .auto)
|
|
79
83
|
}
|
|
80
84
|
|
|
81
85
|
Prop("playInBackground") { (view: VlcPlayerView, playInBackground: Bool?) in
|
|
@@ -87,7 +91,7 @@ public class VlcPlayerModule: Module {
|
|
|
87
91
|
}
|
|
88
92
|
|
|
89
93
|
OnViewDidUpdateProps { (view: VlcPlayerView) in
|
|
90
|
-
view.
|
|
94
|
+
view.initPlayer()
|
|
91
95
|
}
|
|
92
96
|
|
|
93
97
|
AsyncFunction("play") { (view: VlcPlayerView) in
|
package/ios/VlcPlayerView.swift
CHANGED
|
@@ -3,6 +3,7 @@ import ExpoModulesCore
|
|
|
3
3
|
import MobileVLCKit
|
|
4
4
|
|
|
5
5
|
let defaultPlayerRate: Float = 1.0
|
|
6
|
+
let defaultPlayerStart: Int = 0
|
|
6
7
|
let minPlayerVolume: Int = 0
|
|
7
8
|
let maxPlayerVolume: Int = 100
|
|
8
9
|
let playerVolumeStep: Int = 10
|
|
@@ -12,11 +13,15 @@ private let enableSubtitles = true
|
|
|
12
13
|
|
|
13
14
|
class VlcPlayerView: ExpoView, VLCMediaPlayerDelegate {
|
|
14
15
|
var mediaPlayer: VLCMediaPlayer?
|
|
15
|
-
var
|
|
16
|
+
private var shouldInit: Bool = true
|
|
17
|
+
private var shouldCreate: Bool = true
|
|
18
|
+
private var hasLoaded: Bool = false
|
|
19
|
+
var isBackgrounded: Bool = false
|
|
16
20
|
|
|
17
21
|
private var uri: String = ""
|
|
18
22
|
private var options: [String] = []
|
|
19
23
|
private var userVolume: Int = maxPlayerVolume
|
|
24
|
+
private var time: Int? = defaultPlayerStart
|
|
20
25
|
private var shouldRepeat: Bool = false
|
|
21
26
|
var audioMixingMode: AudioMixingMode = .auto
|
|
22
27
|
var playInBackground: Bool = false
|
|
@@ -44,31 +49,46 @@ class VlcPlayerView: ExpoView, VLCMediaPlayerDelegate {
|
|
|
44
49
|
clipsToBounds = true
|
|
45
50
|
}
|
|
46
51
|
|
|
47
|
-
func
|
|
48
|
-
if !
|
|
52
|
+
func initPlayer() {
|
|
53
|
+
if !shouldInit return
|
|
49
54
|
|
|
50
|
-
|
|
55
|
+
if shouldCreate {
|
|
56
|
+
destroyPlayer()
|
|
57
|
+
createPlayer()
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
startPlayer()
|
|
61
|
+
|
|
62
|
+
shouldInit = false
|
|
63
|
+
}
|
|
51
64
|
|
|
65
|
+
func createPlayer() {
|
|
52
66
|
mediaPlayer = VLCMediaPlayer(options: options)
|
|
67
|
+
mediaPlayer.delegate = self
|
|
68
|
+
mediaPlayer.drawable = self
|
|
69
|
+
shouldCreate = false
|
|
70
|
+
}
|
|
53
71
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
player.drawable = self
|
|
72
|
+
func startPlayer() {
|
|
73
|
+
guard let player = mediaPlayer else { return }
|
|
57
74
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
75
|
+
guard let url = URL(string: uri) else {
|
|
76
|
+
let error = ["error": "Invalid URI, media could not be set"]
|
|
77
|
+
onError(error)
|
|
78
|
+
return
|
|
79
|
+
}
|
|
63
80
|
|
|
64
|
-
|
|
81
|
+
player.media = VLCMedia(url: url)
|
|
82
|
+
hasLoaded = false
|
|
65
83
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
}
|
|
84
|
+
if autoplay {
|
|
85
|
+
player.play()
|
|
69
86
|
}
|
|
87
|
+
}
|
|
70
88
|
|
|
71
|
-
|
|
89
|
+
func destroyPlayer() {
|
|
90
|
+
mediaPlayer?.stop()
|
|
91
|
+
mediaPlayer = nil
|
|
72
92
|
}
|
|
73
93
|
|
|
74
94
|
func mediaPlayerStateChanged(_: Notification) {
|
|
@@ -76,9 +96,13 @@ class VlcPlayerView: ExpoView, VLCMediaPlayerDelegate {
|
|
|
76
96
|
|
|
77
97
|
switch player.state {
|
|
78
98
|
case .buffering:
|
|
79
|
-
|
|
99
|
+
if !isBackgrounded {
|
|
100
|
+
onBuffering([:])
|
|
101
|
+
}
|
|
80
102
|
|
|
81
|
-
|
|
103
|
+
let video = player.videoSize
|
|
104
|
+
|
|
105
|
+
if video != CGSizeZero && !hasLoaded {
|
|
82
106
|
var audioTracks: [[String: Any]] = []
|
|
83
107
|
|
|
84
108
|
if let audios = player.audioTrackNames as? [String] {
|
|
@@ -109,7 +133,6 @@ class VlcPlayerView: ExpoView, VLCMediaPlayerDelegate {
|
|
|
109
133
|
}
|
|
110
134
|
}
|
|
111
135
|
|
|
112
|
-
let video = player.videoSize
|
|
113
136
|
let ratio = player.videoAspectRatio
|
|
114
137
|
var length = 0
|
|
115
138
|
if let media = player.media {
|
|
@@ -131,10 +154,20 @@ class VlcPlayerView: ExpoView, VLCMediaPlayerDelegate {
|
|
|
131
154
|
]
|
|
132
155
|
|
|
133
156
|
onLoad(videoInfo)
|
|
157
|
+
hasLoaded = true
|
|
134
158
|
}
|
|
135
159
|
case .playing:
|
|
136
160
|
onPlaying([:])
|
|
137
161
|
VlcPlayerManager.shared.setAppropriateAudioSessionOrWarn()
|
|
162
|
+
|
|
163
|
+
if player.isSeekable {
|
|
164
|
+
let timestamp = time ?? defaultPlayerStart
|
|
165
|
+
|
|
166
|
+
if timestamp != defaultPlayerStart {
|
|
167
|
+
player.time = VLCTime(int: Int32(timestamp))
|
|
168
|
+
time = defaultPlayerStart
|
|
169
|
+
}
|
|
170
|
+
}
|
|
138
171
|
case .paused:
|
|
139
172
|
onPaused([:])
|
|
140
173
|
VlcPlayerManager.shared.setAppropriateAudioSessionOrWarn()
|
|
@@ -146,13 +179,13 @@ class VlcPlayerView: ExpoView, VLCMediaPlayerDelegate {
|
|
|
146
179
|
onPositionChanged(["position": position])
|
|
147
180
|
case .ended:
|
|
148
181
|
onEnded([:])
|
|
182
|
+
player.stop()
|
|
149
183
|
|
|
150
184
|
let manualRepeat = !options.hasRepeatOptions() && shouldRepeat
|
|
151
185
|
|
|
152
186
|
if manualRepeat {
|
|
153
|
-
player.stop()
|
|
154
|
-
player.play()
|
|
155
187
|
onRepeat([:])
|
|
188
|
+
player.play()
|
|
156
189
|
}
|
|
157
190
|
case .error:
|
|
158
191
|
let error = ["error": "Player encountered an error"]
|
|
@@ -162,25 +195,18 @@ class VlcPlayerView: ExpoView, VLCMediaPlayerDelegate {
|
|
|
162
195
|
}
|
|
163
196
|
}
|
|
164
197
|
|
|
165
|
-
func
|
|
198
|
+
func mediaPlayerTimeChanged(_: Notification) {
|
|
166
199
|
guard let player = mediaPlayer else { return }
|
|
167
200
|
|
|
168
201
|
let position = ["position": player.position]
|
|
169
202
|
onPositionChanged(position)
|
|
170
203
|
}
|
|
171
204
|
|
|
172
|
-
func destroyPlayer() {
|
|
173
|
-
if let player = mediaPlayer {
|
|
174
|
-
player.stop()
|
|
175
|
-
mediaPlayer = nil
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
|
|
179
205
|
func setUri(_ uri: String) {
|
|
180
206
|
let old = self.uri
|
|
181
207
|
self.uri = uri
|
|
182
208
|
|
|
183
|
-
|
|
209
|
+
shouldInit = uri != old
|
|
184
210
|
}
|
|
185
211
|
|
|
186
212
|
func setSubtitle(_ subtitle: [String: Any]?) {
|
|
@@ -205,6 +231,7 @@ class VlcPlayerView: ExpoView, VLCMediaPlayerDelegate {
|
|
|
205
231
|
let old = self.options
|
|
206
232
|
self.options = options
|
|
207
233
|
|
|
234
|
+
shouldInit = options != old
|
|
208
235
|
shouldCreate = options != old
|
|
209
236
|
}
|
|
210
237
|
|
|
@@ -247,6 +274,10 @@ class VlcPlayerView: ExpoView, VLCMediaPlayerDelegate {
|
|
|
247
274
|
player.currentVideoSubTitleIndex = Int32(subtitleTrack)
|
|
248
275
|
}
|
|
249
276
|
|
|
277
|
+
func setTime(_ time: Int?) {
|
|
278
|
+
self.time = time
|
|
279
|
+
}
|
|
280
|
+
|
|
250
281
|
func setRepeat(_ shouldRepeat: Bool) {
|
|
251
282
|
if shouldRepeat && options.hasRepeatOptions() {
|
|
252
283
|
let warn = ["warn": "Repeat already enabled in options"]
|
|
@@ -281,6 +312,9 @@ class VlcPlayerView: ExpoView, VLCMediaPlayerDelegate {
|
|
|
281
312
|
}
|
|
282
313
|
|
|
283
314
|
func play() {
|
|
315
|
+
isBackgrounded = false
|
|
316
|
+
let background = ["background": isBackgrounded]
|
|
317
|
+
onBackground(background)
|
|
284
318
|
mediaPlayer?.play()
|
|
285
319
|
}
|
|
286
320
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "expo-libvlc-player",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.5",
|
|
4
4
|
"description": "LibVLC Player for Expo",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"types": "build/index.d.ts",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"@eslint/js": "^9.30.0",
|
|
38
38
|
"@types/react": "~19.0.0",
|
|
39
39
|
"eslint": "^9.30.0",
|
|
40
|
-
"expo": "53.0.
|
|
40
|
+
"expo": "53.0.17",
|
|
41
41
|
"expo-module-scripts": "^4.1.6",
|
|
42
42
|
"globals": "^16.2.0",
|
|
43
43
|
"react-native": "0.79.5"
|
package/src/VlcPlayer.types.ts
CHANGED
|
@@ -5,19 +5,19 @@ export interface VLCPlayerViewRef {
|
|
|
5
5
|
/**
|
|
6
6
|
* Starts playback for the current player
|
|
7
7
|
*
|
|
8
|
-
* @returns void
|
|
8
|
+
* @returns A promise which resolves to `void`
|
|
9
9
|
*/
|
|
10
10
|
readonly play: () => Promise<void>;
|
|
11
11
|
/**
|
|
12
12
|
* Pauses playback for the current player
|
|
13
13
|
*
|
|
14
|
-
* @returns void
|
|
14
|
+
* @returns A promise which resolves to `void`
|
|
15
15
|
*/
|
|
16
16
|
readonly pause: () => Promise<void>;
|
|
17
17
|
/**
|
|
18
18
|
* Stops playback for the current player
|
|
19
19
|
*
|
|
20
|
-
* @returns void
|
|
20
|
+
* @returns A promise which resolves to `void`
|
|
21
21
|
*/
|
|
22
22
|
readonly stop: () => Promise<void>;
|
|
23
23
|
/**
|
|
@@ -86,7 +86,9 @@ export type LoadListener = (event: { nativeEvent: VideoInfo }) => void;
|
|
|
86
86
|
/**
|
|
87
87
|
* @hidden
|
|
88
88
|
*/
|
|
89
|
-
export type BackgroundListener = () => void;
|
|
89
|
+
export type BackgroundListener = (event: { nativeEvent: Background }) => void;
|
|
90
|
+
|
|
91
|
+
export type Background = { background: boolean };
|
|
90
92
|
|
|
91
93
|
export interface Track {
|
|
92
94
|
id: number;
|
|
@@ -129,6 +131,7 @@ export interface VlcPlayerViewNativeProps {
|
|
|
129
131
|
mute?: boolean;
|
|
130
132
|
rate?: number;
|
|
131
133
|
tracks?: TracksOptions;
|
|
134
|
+
time?: number;
|
|
132
135
|
repeat?: boolean;
|
|
133
136
|
aspectRatio?: string;
|
|
134
137
|
audioMixingMode?: AudioMixingMode;
|
|
@@ -184,7 +187,7 @@ export interface VlcPlayerViewProps extends ViewProps {
|
|
|
184
187
|
*/
|
|
185
188
|
options?: string[];
|
|
186
189
|
/**
|
|
187
|
-
* Controls the player volume
|
|
190
|
+
* Controls the player volume. Must be an integer number between `0` and `100`
|
|
188
191
|
*
|
|
189
192
|
* @default 100
|
|
190
193
|
*
|
|
@@ -192,10 +195,13 @@ export interface VlcPlayerViewProps extends ViewProps {
|
|
|
192
195
|
volume?: number;
|
|
193
196
|
/**
|
|
194
197
|
* Sets the player volume to `0`
|
|
198
|
+
*
|
|
199
|
+
* @default false
|
|
200
|
+
*
|
|
195
201
|
*/
|
|
196
202
|
mute?: boolean;
|
|
197
203
|
/**
|
|
198
|
-
* Controls the player rate
|
|
204
|
+
* Controls the player rate. Must be a float number
|
|
199
205
|
*
|
|
200
206
|
* @default 1
|
|
201
207
|
*
|
|
@@ -215,12 +221,22 @@ export interface VlcPlayerViewProps extends ViewProps {
|
|
|
215
221
|
* ```
|
|
216
222
|
*/
|
|
217
223
|
tracks?: TracksOptions;
|
|
224
|
+
/**
|
|
225
|
+
* Controls the player time once created. Must be an integer number in milliseconds
|
|
226
|
+
*
|
|
227
|
+
* @default 0
|
|
228
|
+
*
|
|
229
|
+
*/
|
|
230
|
+
time?: number;
|
|
218
231
|
/**
|
|
219
232
|
* Repeats media once playback is ended
|
|
233
|
+
*
|
|
234
|
+
* @default false
|
|
235
|
+
*
|
|
220
236
|
*/
|
|
221
237
|
repeat?: boolean;
|
|
222
238
|
/**
|
|
223
|
-
* Sets the player aspect ratio
|
|
239
|
+
* Sets the player aspect ratio. Must be a valid string
|
|
224
240
|
*
|
|
225
241
|
* @example "16:9"
|
|
226
242
|
*/
|
|
@@ -228,7 +244,7 @@ export interface VlcPlayerViewProps extends ViewProps {
|
|
|
228
244
|
/**
|
|
229
245
|
* Determines how the player will interact with other audio playing in the system
|
|
230
246
|
*
|
|
231
|
-
* @default
|
|
247
|
+
* @default "auto"
|
|
232
248
|
*/
|
|
233
249
|
audioMixingMode?: AudioMixingMode;
|
|
234
250
|
/**
|
|
@@ -287,5 +303,5 @@ export interface VlcPlayerViewProps extends ViewProps {
|
|
|
287
303
|
/**
|
|
288
304
|
* Event that fires when player enters the background
|
|
289
305
|
*/
|
|
290
|
-
onBackground?: () => void;
|
|
306
|
+
onBackground?: (event: Background) => void;
|
|
291
307
|
}
|
package/src/VlcPlayerView.tsx
CHANGED
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
type Error,
|
|
10
10
|
type PositionChanged,
|
|
11
11
|
type VideoInfo,
|
|
12
|
+
type Background,
|
|
12
13
|
} from "./VlcPlayer.types";
|
|
13
14
|
import { convertNativeProps } from "./utils/props";
|
|
14
15
|
|
|
@@ -57,6 +58,12 @@ const VlcPlayerView = React.forwardRef<VLCPlayerViewRef, VlcPlayerViewProps>(
|
|
|
57
58
|
}
|
|
58
59
|
};
|
|
59
60
|
|
|
61
|
+
const onBackground = ({ nativeEvent }: { nativeEvent: Background }) => {
|
|
62
|
+
if (props.onBackground) {
|
|
63
|
+
props.onBackground(nativeEvent);
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
|
|
60
67
|
return (
|
|
61
68
|
<NativeView
|
|
62
69
|
{...nativeProps}
|
|
@@ -65,6 +72,7 @@ const VlcPlayerView = React.forwardRef<VLCPlayerViewRef, VlcPlayerViewProps>(
|
|
|
65
72
|
onError={onError}
|
|
66
73
|
onPositionChanged={onPositionChanged}
|
|
67
74
|
onLoad={onLoad}
|
|
75
|
+
onBackground={onBackground}
|
|
68
76
|
/>
|
|
69
77
|
);
|
|
70
78
|
},
|