expo-libvlc-player 3.4.10 → 3.4.12
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/android/build.gradle +17 -17
- package/android/proguard-rules.pro +0 -18
- package/build/LibVlcPlayerView.d.ts.map +1 -1
- package/build/LibVlcPlayerView.js +8 -5
- package/build/LibVlcPlayerView.js.map +1 -1
- package/ios/Enums/AudioMixingMode.swift +8 -8
- package/ios/ExpoLibVlcPlayer.podspec +1 -1
- package/ios/LibVlcPlayerView.swift +6 -6
- package/package.json +1 -1
- package/src/LibVlcPlayerView.tsx +12 -7
package/android/build.gradle
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
apply plugin:
|
|
1
|
+
apply plugin: 'com.android.library'
|
|
2
2
|
|
|
3
|
-
group =
|
|
4
|
-
version =
|
|
3
|
+
group = 'expo.modules.libvlcplayer'
|
|
4
|
+
version = '3.4.12'
|
|
5
5
|
|
|
6
|
-
def expoModulesCorePlugin = new File(project(
|
|
6
|
+
def expoModulesCorePlugin = new File(project(':expo-modules-core').projectDir.absolutePath, 'ExpoModulesCorePlugin.gradle')
|
|
7
7
|
apply from: expoModulesCorePlugin
|
|
8
8
|
applyKotlinExpoModulesCorePlugin()
|
|
9
9
|
useCoreDependencies()
|
|
@@ -15,21 +15,21 @@ buildscript {
|
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
project.android {
|
|
19
|
-
compileSdkVersion safeExtGet("compileSdkVersion", 35)
|
|
20
|
-
defaultConfig {
|
|
21
|
-
minSdkVersion safeExtGet("minSdkVersion", 25)
|
|
22
|
-
targetSdkVersion safeExtGet("targetSdkVersion", 35)
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
18
|
android {
|
|
27
|
-
namespace
|
|
19
|
+
namespace 'expo.modules.libvlcplayer'
|
|
20
|
+
|
|
21
|
+
compileSdkVersion safeExtGet('compileSdkVersion', 35)
|
|
22
|
+
|
|
28
23
|
defaultConfig {
|
|
24
|
+
minSdkVersion safeExtGet('minSdkVersion', 24)
|
|
25
|
+
targetSdkVersion safeExtGet('targetSdkVersion', 35)
|
|
26
|
+
|
|
29
27
|
versionCode 1
|
|
30
|
-
versionName
|
|
31
|
-
|
|
28
|
+
versionName '3.4.12'
|
|
29
|
+
|
|
30
|
+
consumerProguardFiles('proguard-rules.pro')
|
|
32
31
|
}
|
|
32
|
+
|
|
33
33
|
lintOptions {
|
|
34
34
|
abortOnError false
|
|
35
35
|
}
|
|
@@ -40,6 +40,6 @@ repositories {
|
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
dependencies {
|
|
43
|
-
implementation
|
|
44
|
-
implementation
|
|
43
|
+
implementation 'com.facebook.react:react-android'
|
|
44
|
+
implementation 'org.videolan.android:libvlc-all:3.6.5'
|
|
45
45
|
}
|
|
@@ -1,19 +1 @@
|
|
|
1
|
-
# Add project specific ProGuard rules here.
|
|
2
|
-
# By default, the flags in this file are appended to flags specified
|
|
3
|
-
# in /home/tom/work/android/sdk/tools/proguard/proguard-android.txt
|
|
4
|
-
# You can edit the include path and order by changing the proguardFiles
|
|
5
|
-
# directive in build.gradle.
|
|
6
|
-
#
|
|
7
|
-
# For more details, see
|
|
8
|
-
# http://developer.android.com/guide/developing/tools/proguard.html
|
|
9
|
-
|
|
10
|
-
# Add any project specific keep options here:
|
|
11
|
-
|
|
12
|
-
# If your project uses WebView with JS, uncomment the following
|
|
13
|
-
# and specify the fully qualified class name to the JavaScript interface
|
|
14
|
-
# class:
|
|
15
|
-
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
|
16
|
-
# public *;
|
|
17
|
-
#}
|
|
18
|
-
|
|
19
1
|
-keep class org.videolan.libvlc.** { *; }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LibVlcPlayerView.d.ts","sourceRoot":"","sources":["../src/LibVlcPlayerView.tsx"],"names":[],"mappings":"AAIA,OAAO,EAEL,qBAAqB,EACrB,mBAAmB,
|
|
1
|
+
{"version":3,"file":"LibVlcPlayerView.d.ts","sourceRoot":"","sources":["../src/LibVlcPlayerView.tsx"],"names":[],"mappings":"AAIA,OAAO,EAEL,qBAAqB,EACrB,mBAAmB,EAWpB,MAAM,sBAAsB,CAAC;AAe9B,QAAA,MAAM,gBAAgB,uHAsGrB,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
|
|
@@ -5,11 +5,13 @@ import { convertAspectRatio } from "./utils/aspect";
|
|
|
5
5
|
import { parseSource } from "./utils/assets";
|
|
6
6
|
import { convertNativeEvent } from "./utils/events";
|
|
7
7
|
const NativeView = requireNativeView("ExpoLibVlcPlayer");
|
|
8
|
+
const RENDERING_CHILDREN_WARNING = "The <LibVlcPlayerView> component does not support children. This may lead to inconsistent behaviour or crashes. If you want to render content on top of the LibVlcPlayer, consider using absolute positioning.";
|
|
8
9
|
let loggedRenderingChildrenWarning = false;
|
|
10
|
+
const DEFAULT_ASPECT_RATIO = 16 / 9;
|
|
9
11
|
const LibVlcPlayerView = forwardRef((props, ref) => {
|
|
10
|
-
const
|
|
12
|
+
const fallbackRatio = useRef(DEFAULT_ASPECT_RATIO);
|
|
11
13
|
if (props.children && !loggedRenderingChildrenWarning) {
|
|
12
|
-
console.warn(
|
|
14
|
+
console.warn(RENDERING_CHILDREN_WARNING);
|
|
13
15
|
loggedRenderingChildrenWarning = true;
|
|
14
16
|
}
|
|
15
17
|
const onEncounteredError = (event) => {
|
|
@@ -59,10 +61,11 @@ const LibVlcPlayerView = forwardRef((props, ref) => {
|
|
|
59
61
|
if (props.onFirstPlay) {
|
|
60
62
|
props.onFirstPlay(nativeEvent);
|
|
61
63
|
}
|
|
62
|
-
|
|
64
|
+
fallbackRatio.current =
|
|
65
|
+
nativeEvent.width / nativeEvent.height || DEFAULT_ASPECT_RATIO;
|
|
63
66
|
};
|
|
64
|
-
const
|
|
65
|
-
const nativeRatio = convertAspectRatio(
|
|
67
|
+
const aspectRatio = props.aspectRatio || fallbackRatio.current;
|
|
68
|
+
const nativeRatio = convertAspectRatio(aspectRatio);
|
|
66
69
|
return (<View style={{ aspectRatio: nativeRatio }}>
|
|
67
70
|
<NativeView {...props} ref={ref} style={[props.style, { height: "100%" }]} source={parseSource(props.source)} slaves={props.slaves?.map((slave) => ({
|
|
68
71
|
...slave,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LibVlcPlayerView.js","sourceRoot":"","sources":["../src/LibVlcPlayerView.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,MAAM,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,EAAsB,MAAM,OAAO,CAAC;AAC/D,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"LibVlcPlayerView.js","sourceRoot":"","sources":["../src/LibVlcPlayerView.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,MAAM,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,EAAsB,MAAM,OAAO,CAAC;AAC/D,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAiBpC,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAEpD,MAAM,UAAU,GACd,iBAAiB,CAAC,kBAAkB,CAAC,CAAC;AAExC,MAAM,0BAA0B,GAC9B,gNAAgN,CAAC;AAEnN,IAAI,8BAA8B,GAAY,KAAK,CAAC;AAEpD,MAAM,oBAAoB,GAAG,EAAE,GAAG,CAAC,CAAC;AAEpC,MAAM,gBAAgB,GAAG,UAAU,CACjC,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;IACb,MAAM,aAAa,GAAG,MAAM,CAAmB,oBAAoB,CAAC,CAAC;IAErE,IAAI,KAA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ACzC,MAAM,CAAC,CAAC,WAAW,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAClC,MAAM,CAAC,CAAC,KAAK,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;YACpC,GAAG,KAAK;YACR,MAAM,EAAE,WAAW,CAAC,KAAK,CAAC,MAAM,CAAE;SACnC,CAAC,CAAC,CAAC,CACJ,kBAAkB,CAAC,CAAC,kBAAkB,CAAC,CACvC,eAAe,CAAC,CAAC,eAAe,CAAC,CACjC,aAAa,CAAC,CAAC,aAAa,CAAC,CAC7B,iBAAiB,CAAC,CAAC,iBAAiB,CAAC,CACrC,SAAS,CAAC,CAAC,SAAS,CAAC,CACrB,eAAe,CAAC,CAAC,eAAe,CAAC,CACjC,eAAe,CAAC,CAAC,eAAe,CAAC,CACjC,WAAW,CAAC,CAAC,WAAW,CAAC,EAE7B;MAAA,EAAE,IAAI,CAAC,CACR,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,gBAAgB,CAAC","sourcesContent":["import { requireNativeView } from \"expo\";\nimport { forwardRef, useRef, type ComponentType } from \"react\";\nimport { View } from \"react-native\";\n\nimport {\n LibVlcPlayerViewNativeProps,\n LibVlcPlayerViewProps,\n LibVlcPlayerViewRef,\n type Dialog,\n type Error,\n type MediaInfo,\n type MediaTracks,\n type NativeEvent,\n type Position,\n type Recording,\n type Snapshot,\n type Time,\n type VideoAspectRatio,\n} from \"./LibVlcPlayer.types\";\nimport { convertAspectRatio } from \"./utils/aspect\";\nimport { parseSource } from \"./utils/assets\";\nimport { convertNativeEvent } from \"./utils/events\";\n\nconst NativeView: ComponentType<LibVlcPlayerViewNativeProps> =\n requireNativeView(\"ExpoLibVlcPlayer\");\n\nconst RENDERING_CHILDREN_WARNING =\n \"The <LibVlcPlayerView> component does not support children. This may lead to inconsistent behaviour or crashes. If you want to render content on top of the LibVlcPlayer, consider using absolute positioning.\";\n\nlet loggedRenderingChildrenWarning: boolean = false;\n\nconst DEFAULT_ASPECT_RATIO = 16 / 9;\n\nconst LibVlcPlayerView = forwardRef<LibVlcPlayerViewRef, LibVlcPlayerViewProps>(\n (props, ref) => {\n const fallbackRatio = useRef<VideoAspectRatio>(DEFAULT_ASPECT_RATIO);\n\n if (props.children && !loggedRenderingChildrenWarning) {\n console.warn(RENDERING_CHILDREN_WARNING);\n loggedRenderingChildrenWarning = true;\n }\n\n const onEncounteredError = (event: NativeEvent<Error>) => {\n const nativeEvent = convertNativeEvent(event);\n\n if (props.onEncounteredError) {\n props.onEncounteredError(nativeEvent);\n }\n };\n\n const onDialogDisplay = (event: NativeEvent<Dialog>) => {\n const nativeEvent = convertNativeEvent(event);\n\n if (props.onDialogDisplay) {\n props.onDialogDisplay(nativeEvent);\n }\n };\n\n const onTimeChanged = (event: NativeEvent<Time>) => {\n const nativeEvent = convertNativeEvent(event);\n\n if (props.onTimeChanged) {\n props.onTimeChanged(nativeEvent);\n }\n };\n\n const onPositionChanged = (event: NativeEvent<Position>) => {\n const nativeEvent = convertNativeEvent(event);\n\n if (props.onPositionChanged) {\n props.onPositionChanged(nativeEvent);\n }\n };\n\n const onESAdded = (event: NativeEvent<MediaTracks>) => {\n const nativeEvent = convertNativeEvent(event);\n\n if (props.onESAdded) {\n props.onESAdded(nativeEvent);\n }\n };\n\n const onRecordChanged = (event: NativeEvent<Recording>) => {\n const nativeEvent = convertNativeEvent(event);\n\n if (props.onRecordChanged) {\n props.onRecordChanged(nativeEvent);\n }\n };\n\n const onSnapshotTaken = (event: NativeEvent<Snapshot>) => {\n const nativeEvent = convertNativeEvent(event);\n\n if (props.onSnapshotTaken) {\n props.onSnapshotTaken(nativeEvent);\n }\n };\n\n const onFirstPlay = (event: NativeEvent<MediaInfo>) => {\n const nativeEvent = convertNativeEvent(event);\n\n if (props.onFirstPlay) {\n props.onFirstPlay(nativeEvent);\n }\n\n fallbackRatio.current =\n nativeEvent.width / nativeEvent.height || DEFAULT_ASPECT_RATIO;\n };\n\n const aspectRatio = props.aspectRatio || fallbackRatio.current;\n const nativeRatio = convertAspectRatio(aspectRatio);\n\n return (\n <View style={{ aspectRatio: nativeRatio }}>\n <NativeView\n {...props}\n ref={ref}\n style={[props.style, { height: \"100%\" }]}\n source={parseSource(props.source)}\n slaves={props.slaves?.map((slave) => ({\n ...slave,\n source: parseSource(slave.source)!,\n }))}\n onEncounteredError={onEncounteredError}\n onDialogDisplay={onDialogDisplay}\n onTimeChanged={onTimeChanged}\n onPositionChanged={onPositionChanged}\n onESAdded={onESAdded}\n onRecordChanged={onRecordChanged}\n onSnapshotTaken={onSnapshotTaken}\n onFirstPlay={onFirstPlay}\n />\n </View>\n );\n },\n);\n\nexport default LibVlcPlayerView;\n"]}
|
|
@@ -10,26 +10,26 @@ enum AudioMixingMode: String, Enumerable {
|
|
|
10
10
|
func priority() -> Int {
|
|
11
11
|
switch self {
|
|
12
12
|
case .doNotMix:
|
|
13
|
-
|
|
13
|
+
3
|
|
14
14
|
case .auto:
|
|
15
|
-
|
|
15
|
+
2
|
|
16
16
|
case .duckOthers:
|
|
17
|
-
|
|
17
|
+
1
|
|
18
18
|
case .mixWithOthers:
|
|
19
|
-
|
|
19
|
+
0
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
func toSessionCategoryOption() -> AVAudioSession.CategoryOptions? {
|
|
24
24
|
switch self {
|
|
25
25
|
case .duckOthers:
|
|
26
|
-
|
|
26
|
+
.duckOthers
|
|
27
27
|
case .mixWithOthers:
|
|
28
|
-
|
|
28
|
+
.mixWithOthers
|
|
29
29
|
case .doNotMix:
|
|
30
|
-
|
|
30
|
+
nil
|
|
31
31
|
case .auto:
|
|
32
|
-
|
|
32
|
+
nil
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
35
|
}
|
|
@@ -76,7 +76,7 @@ class LibVlcPlayerView: ExpoView {
|
|
|
76
76
|
|
|
77
77
|
destroyPlayer()
|
|
78
78
|
|
|
79
|
-
guard let source
|
|
79
|
+
guard let source else { return }
|
|
80
80
|
|
|
81
81
|
options.toggleStartPausedOption(autoplay)
|
|
82
82
|
|
|
@@ -428,7 +428,7 @@ class LibVlcPlayerView: ExpoView {
|
|
|
428
428
|
|
|
429
429
|
func record(_ path: String?) {
|
|
430
430
|
if let player = mediaPlayer, player.isPlaying {
|
|
431
|
-
if let path
|
|
431
|
+
if let path {
|
|
432
432
|
// https://code.videolan.org/videolan/VLCKit/-/issues/394
|
|
433
433
|
let success = !player.startRecording(atPath: path)
|
|
434
434
|
|
|
@@ -476,7 +476,7 @@ class LibVlcPlayerView: ExpoView {
|
|
|
476
476
|
}
|
|
477
477
|
}
|
|
478
478
|
|
|
479
|
-
private extension
|
|
479
|
+
private extension [String] {
|
|
480
480
|
func hasAudioOption() -> Bool {
|
|
481
481
|
let options = [
|
|
482
482
|
"--no-audio",
|
|
@@ -488,7 +488,7 @@ private extension Array where Element == String {
|
|
|
488
488
|
}
|
|
489
489
|
}
|
|
490
490
|
|
|
491
|
-
extension
|
|
491
|
+
extension [String] {
|
|
492
492
|
func hasRepeatOption() -> Bool {
|
|
493
493
|
let options = [
|
|
494
494
|
"--input-repeat=",
|
|
@@ -504,7 +504,7 @@ extension Array where Element == String {
|
|
|
504
504
|
}
|
|
505
505
|
}
|
|
506
506
|
|
|
507
|
-
private extension
|
|
507
|
+
private extension [String] {
|
|
508
508
|
func hasStartPausedOption() -> Bool {
|
|
509
509
|
let options = [
|
|
510
510
|
"--start-paused",
|
|
@@ -516,7 +516,7 @@ private extension Array where Element == String {
|
|
|
516
516
|
}
|
|
517
517
|
}
|
|
518
518
|
|
|
519
|
-
private extension
|
|
519
|
+
private extension [String] {
|
|
520
520
|
mutating func toggleStartPausedOption(_ autoplay: Bool) {
|
|
521
521
|
let options = [
|
|
522
522
|
"--start-paused",
|
package/package.json
CHANGED
package/src/LibVlcPlayerView.tsx
CHANGED
|
@@ -15,6 +15,7 @@ import {
|
|
|
15
15
|
type Recording,
|
|
16
16
|
type Snapshot,
|
|
17
17
|
type Time,
|
|
18
|
+
type VideoAspectRatio,
|
|
18
19
|
} from "./LibVlcPlayer.types";
|
|
19
20
|
import { convertAspectRatio } from "./utils/aspect";
|
|
20
21
|
import { parseSource } from "./utils/assets";
|
|
@@ -23,16 +24,19 @@ import { convertNativeEvent } from "./utils/events";
|
|
|
23
24
|
const NativeView: ComponentType<LibVlcPlayerViewNativeProps> =
|
|
24
25
|
requireNativeView("ExpoLibVlcPlayer");
|
|
25
26
|
|
|
27
|
+
const RENDERING_CHILDREN_WARNING =
|
|
28
|
+
"The <LibVlcPlayerView> component does not support children. This may lead to inconsistent behaviour or crashes. If you want to render content on top of the LibVlcPlayer, consider using absolute positioning.";
|
|
29
|
+
|
|
26
30
|
let loggedRenderingChildrenWarning: boolean = false;
|
|
27
31
|
|
|
32
|
+
const DEFAULT_ASPECT_RATIO = 16 / 9;
|
|
33
|
+
|
|
28
34
|
const LibVlcPlayerView = forwardRef<LibVlcPlayerViewRef, LibVlcPlayerViewProps>(
|
|
29
35
|
(props, ref) => {
|
|
30
|
-
const
|
|
36
|
+
const fallbackRatio = useRef<VideoAspectRatio>(DEFAULT_ASPECT_RATIO);
|
|
31
37
|
|
|
32
38
|
if (props.children && !loggedRenderingChildrenWarning) {
|
|
33
|
-
console.warn(
|
|
34
|
-
"The <LibVlcPlayerView> component does not support children. This may lead to inconsistent behaviour or crashes. If you want to render content on top of the LibVlcPlayer, consider using absolute positioning.",
|
|
35
|
-
);
|
|
39
|
+
console.warn(RENDERING_CHILDREN_WARNING);
|
|
36
40
|
loggedRenderingChildrenWarning = true;
|
|
37
41
|
}
|
|
38
42
|
|
|
@@ -99,11 +103,12 @@ const LibVlcPlayerView = forwardRef<LibVlcPlayerViewRef, LibVlcPlayerViewProps>(
|
|
|
99
103
|
props.onFirstPlay(nativeEvent);
|
|
100
104
|
}
|
|
101
105
|
|
|
102
|
-
|
|
106
|
+
fallbackRatio.current =
|
|
107
|
+
nativeEvent.width / nativeEvent.height || DEFAULT_ASPECT_RATIO;
|
|
103
108
|
};
|
|
104
109
|
|
|
105
|
-
const
|
|
106
|
-
const nativeRatio = convertAspectRatio(
|
|
110
|
+
const aspectRatio = props.aspectRatio || fallbackRatio.current;
|
|
111
|
+
const nativeRatio = convertAspectRatio(aspectRatio);
|
|
107
112
|
|
|
108
113
|
return (
|
|
109
114
|
<View style={{ aspectRatio: nativeRatio }}>
|