expo-libvlc-player 4.0.4 → 4.0.6
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 +1 -1
- package/android/src/main/java/expo/modules/libvlcplayer/managers/KeepAwakeManager.kt +2 -2
- package/build/LibVlcPlayerView.js +9 -8
- package/build/LibVlcPlayerView.js.map +1 -1
- package/build/utils/assets.d.ts +1 -1
- package/build/utils/assets.d.ts.map +1 -1
- package/build/utils/assets.js +3 -3
- package/build/utils/assets.js.map +1 -1
- package/package.json +11 -11
- package/src/LibVlcPlayerView.tsx +9 -9
- package/src/utils/assets.ts +3 -3
- package/src/declarations/react-native-assets.d.ts +0 -7
package/README.md
CHANGED
|
@@ -2,14 +2,14 @@ package expo.modules.libvlcplayer.managers
|
|
|
2
2
|
|
|
3
3
|
import android.app.Activity
|
|
4
4
|
import android.view.WindowManager
|
|
5
|
-
import expo.modules.core.errors.CurrentActivityNotFoundException
|
|
6
5
|
import expo.modules.kotlin.AppContext
|
|
6
|
+
import expo.modules.kotlin.exception.Exceptions
|
|
7
7
|
|
|
8
8
|
class KeepAwakeManager(
|
|
9
9
|
private val appContext: AppContext?,
|
|
10
10
|
) {
|
|
11
11
|
private val currentActivity: Activity
|
|
12
|
-
get() = appContext?.currentActivity ?: throw
|
|
12
|
+
get() = appContext?.currentActivity ?: throw Exceptions.MissingActivity()
|
|
13
13
|
|
|
14
14
|
fun activateKeepAwake() {
|
|
15
15
|
currentActivity.let { activity ->
|
|
@@ -2,14 +2,14 @@ import { requireNativeView } from "expo";
|
|
|
2
2
|
import { forwardRef, useRef } from "react";
|
|
3
3
|
import { View } from "react-native";
|
|
4
4
|
import { convertAspectRatio } from "./utils/aspect";
|
|
5
|
-
import {
|
|
5
|
+
import { parseNativeSource } from "./utils/assets";
|
|
6
6
|
import { convertNativeEvent } from "./utils/events";
|
|
7
7
|
const NativeView = requireNativeView("ExpoLibVlcPlayer");
|
|
8
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.";
|
|
9
9
|
let loggedRenderingChildrenWarning = false;
|
|
10
|
-
const
|
|
10
|
+
const FALLBACK_RATIO = 16 / 9;
|
|
11
11
|
const LibVlcPlayerView = forwardRef((props, ref) => {
|
|
12
|
-
const
|
|
12
|
+
const defaultRatio = useRef(FALLBACK_RATIO);
|
|
13
13
|
if (props.children && !loggedRenderingChildrenWarning) {
|
|
14
14
|
console.warn(RENDERING_CHILDREN_WARNING);
|
|
15
15
|
loggedRenderingChildrenWarning = true;
|
|
@@ -58,18 +58,19 @@ const LibVlcPlayerView = forwardRef((props, ref) => {
|
|
|
58
58
|
};
|
|
59
59
|
const onFirstPlay = (event) => {
|
|
60
60
|
const nativeEvent = convertNativeEvent(event);
|
|
61
|
+
const mediaRatio = nativeEvent.width / nativeEvent.height;
|
|
61
62
|
if (props.onFirstPlay) {
|
|
62
63
|
props.onFirstPlay(nativeEvent);
|
|
63
64
|
}
|
|
64
|
-
|
|
65
|
-
nativeEvent.width / nativeEvent.height || DEFAULT_ASPECT_RATIO;
|
|
65
|
+
defaultRatio.current = mediaRatio || FALLBACK_RATIO;
|
|
66
66
|
};
|
|
67
|
-
const
|
|
67
|
+
const propRatio = props.aspectRatio;
|
|
68
|
+
const aspectRatio = propRatio === "auto" ? defaultRatio.current : propRatio;
|
|
68
69
|
const nativeRatio = convertAspectRatio(aspectRatio);
|
|
69
70
|
return (<View style={{ aspectRatio: nativeRatio }}>
|
|
70
|
-
<NativeView {...props} ref={ref} style={[props.style, { height: "100%" }]} source={
|
|
71
|
+
<NativeView {...props} ref={ref} style={[props.style, { height: "100%" }]} source={parseNativeSource(props.source)} slaves={props.slaves?.map((slave) => ({
|
|
71
72
|
...slave,
|
|
72
|
-
source:
|
|
73
|
+
source: parseNativeSource(slave.source),
|
|
73
74
|
}))} onEncounteredError={onEncounteredError} onDialogDisplay={onDialogDisplay} onTimeChanged={onTimeChanged} onPositionChanged={onPositionChanged} onESAdded={onESAdded} onRecordChanged={onRecordChanged} onSnapshotTaken={onSnapshotTaken} onFirstPlay={onFirstPlay}/>
|
|
74
75
|
</View>);
|
|
75
76
|
});
|
|
@@ -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;AAiBpC,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAAE,
|
|
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,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACnD,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,cAAc,GAAG,EAAE,GAAG,CAAC,CAAC;AAE9B,MAAM,gBAAgB,GAAG,UAAU,CACjC,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;IACb,MAAM,YAAY,GAAG,MAAM,CAAmB,cAAc,CAAC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KAAK,CAAC,CACV,GAAG,CAAC,CAAC,GAAG,CAAC,CACT,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC,CACzC,MAAM,CAAC,CAAC,iBAAiB,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CACxC,MAAM,CAAC,CAAC,KAAK,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;YACpC,GAAG,KAAK;YACR,MAAM,EAAE,iBAAiB,CAAC,KAAK,CAAC,MAAM,CAAE;SACzC,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 { parseNativeSource } 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 FALLBACK_RATIO = 16 / 9;\n\nconst LibVlcPlayerView = forwardRef<LibVlcPlayerViewRef, LibVlcPlayerViewProps>(\n (props, ref) => {\n const defaultRatio = useRef<VideoAspectRatio>(FALLBACK_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 const mediaRatio = nativeEvent.width / nativeEvent.height;\n\n if (props.onFirstPlay) {\n props.onFirstPlay(nativeEvent);\n }\n\n defaultRatio.current = mediaRatio || FALLBACK_RATIO;\n };\n\n const propRatio = props.aspectRatio;\n const aspectRatio = propRatio === \"auto\" ? defaultRatio.current : propRatio;\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={parseNativeSource(props.source)}\n slaves={props.slaves?.map((slave) => ({\n ...slave,\n source: parseNativeSource(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"]}
|
package/build/utils/assets.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assets.d.ts","sourceRoot":"","sources":["../../src/utils/assets.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAErD,wBAAgB,
|
|
1
|
+
{"version":3,"file":"assets.d.ts","sourceRoot":"","sources":["../../src/utils/assets.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAErD,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,YAAY,GAAG,YAAY,CAMpE"}
|
package/build/utils/assets.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
export function
|
|
1
|
+
import { Image } from "react-native";
|
|
2
|
+
export function parseNativeSource(source) {
|
|
3
3
|
if (typeof source === "number") {
|
|
4
|
-
return resolveAssetSource(source).uri;
|
|
4
|
+
return Image.resolveAssetSource(source).uri;
|
|
5
5
|
}
|
|
6
6
|
return source;
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assets.js","sourceRoot":"","sources":["../../src/utils/assets.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"assets.js","sourceRoot":"","sources":["../../src/utils/assets.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAIrC,MAAM,UAAU,iBAAiB,CAAC,MAAoB;IACpD,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE,CAAC;QAC/B,OAAO,KAAK,CAAC,kBAAkB,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC;IAC9C,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import { Image } from \"react-native\";\n\nimport { LibVlcSource } from \"../LibVlcPlayer.types\";\n\nexport function parseNativeSource(source: LibVlcSource): LibVlcSource {\n if (typeof source === \"number\") {\n return Image.resolveAssetSource(source).uri;\n }\n\n return source;\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "expo-libvlc-player",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.6",
|
|
4
4
|
"description": "LibVLC Player for Expo",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"types": "build/index.d.ts",
|
|
@@ -34,17 +34,17 @@
|
|
|
34
34
|
"license": "MIT",
|
|
35
35
|
"homepage": "https://github.com/cornejobarraza/expo-libvlc-player#readme",
|
|
36
36
|
"devDependencies": {
|
|
37
|
-
"@eslint/compat": "^1.
|
|
38
|
-
"@eslint/eslintrc": "^3.3.
|
|
39
|
-
"@eslint/js": "^9.
|
|
40
|
-
"@types/react": "~19.
|
|
41
|
-
"eslint": "^9.
|
|
42
|
-
"expo": "
|
|
43
|
-
"expo-module-scripts": "^
|
|
44
|
-
"globals": "^16.
|
|
37
|
+
"@eslint/compat": "^1.4.1",
|
|
38
|
+
"@eslint/eslintrc": "^3.3.5",
|
|
39
|
+
"@eslint/js": "^9.39.4",
|
|
40
|
+
"@types/react": "~19.2.10",
|
|
41
|
+
"eslint": "^9.39.4",
|
|
42
|
+
"expo": "^55.0.5",
|
|
43
|
+
"expo-module-scripts": "^55.0.2",
|
|
44
|
+
"globals": "^16.5.0",
|
|
45
45
|
"husky": "^9.1.7",
|
|
46
|
-
"lint-staged": "^16.
|
|
47
|
-
"react-native": "0.
|
|
46
|
+
"lint-staged": "^16.3.2",
|
|
47
|
+
"react-native": "0.83.2"
|
|
48
48
|
},
|
|
49
49
|
"peerDependencies": {
|
|
50
50
|
"expo": "*",
|
package/src/LibVlcPlayerView.tsx
CHANGED
|
@@ -18,7 +18,7 @@ import {
|
|
|
18
18
|
type VideoAspectRatio,
|
|
19
19
|
} from "./LibVlcPlayer.types";
|
|
20
20
|
import { convertAspectRatio } from "./utils/aspect";
|
|
21
|
-
import {
|
|
21
|
+
import { parseNativeSource } from "./utils/assets";
|
|
22
22
|
import { convertNativeEvent } from "./utils/events";
|
|
23
23
|
|
|
24
24
|
const NativeView: ComponentType<LibVlcPlayerViewNativeProps> =
|
|
@@ -29,11 +29,11 @@ const RENDERING_CHILDREN_WARNING =
|
|
|
29
29
|
|
|
30
30
|
let loggedRenderingChildrenWarning: boolean = false;
|
|
31
31
|
|
|
32
|
-
const
|
|
32
|
+
const FALLBACK_RATIO = 16 / 9;
|
|
33
33
|
|
|
34
34
|
const LibVlcPlayerView = forwardRef<LibVlcPlayerViewRef, LibVlcPlayerViewProps>(
|
|
35
35
|
(props, ref) => {
|
|
36
|
-
const
|
|
36
|
+
const defaultRatio = useRef<VideoAspectRatio>(FALLBACK_RATIO);
|
|
37
37
|
|
|
38
38
|
if (props.children && !loggedRenderingChildrenWarning) {
|
|
39
39
|
console.warn(RENDERING_CHILDREN_WARNING);
|
|
@@ -98,17 +98,17 @@ const LibVlcPlayerView = forwardRef<LibVlcPlayerViewRef, LibVlcPlayerViewProps>(
|
|
|
98
98
|
|
|
99
99
|
const onFirstPlay = (event: NativeEvent<MediaInfo>) => {
|
|
100
100
|
const nativeEvent = convertNativeEvent(event);
|
|
101
|
+
const mediaRatio = nativeEvent.width / nativeEvent.height;
|
|
101
102
|
|
|
102
103
|
if (props.onFirstPlay) {
|
|
103
104
|
props.onFirstPlay(nativeEvent);
|
|
104
105
|
}
|
|
105
106
|
|
|
106
|
-
|
|
107
|
-
nativeEvent.width / nativeEvent.height || DEFAULT_ASPECT_RATIO;
|
|
107
|
+
defaultRatio.current = mediaRatio || FALLBACK_RATIO;
|
|
108
108
|
};
|
|
109
109
|
|
|
110
|
-
const
|
|
111
|
-
|
|
110
|
+
const propRatio = props.aspectRatio;
|
|
111
|
+
const aspectRatio = propRatio === "auto" ? defaultRatio.current : propRatio;
|
|
112
112
|
const nativeRatio = convertAspectRatio(aspectRatio);
|
|
113
113
|
|
|
114
114
|
return (
|
|
@@ -117,10 +117,10 @@ const LibVlcPlayerView = forwardRef<LibVlcPlayerViewRef, LibVlcPlayerViewProps>(
|
|
|
117
117
|
{...props}
|
|
118
118
|
ref={ref}
|
|
119
119
|
style={[props.style, { height: "100%" }]}
|
|
120
|
-
source={
|
|
120
|
+
source={parseNativeSource(props.source)}
|
|
121
121
|
slaves={props.slaves?.map((slave) => ({
|
|
122
122
|
...slave,
|
|
123
|
-
source:
|
|
123
|
+
source: parseNativeSource(slave.source)!,
|
|
124
124
|
}))}
|
|
125
125
|
onEncounteredError={onEncounteredError}
|
|
126
126
|
onDialogDisplay={onDialogDisplay}
|
package/src/utils/assets.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Image } from "react-native";
|
|
2
2
|
|
|
3
3
|
import { LibVlcSource } from "../LibVlcPlayer.types";
|
|
4
4
|
|
|
5
|
-
export function
|
|
5
|
+
export function parseNativeSource(source: LibVlcSource): LibVlcSource {
|
|
6
6
|
if (typeof source === "number") {
|
|
7
|
-
return resolveAssetSource(source).uri;
|
|
7
|
+
return Image.resolveAssetSource(source).uri;
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
return source;
|