expo-mpv 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.js +5 -0
- package/README.md +33 -0
- package/android/build.gradle +18 -0
- package/android/src/main/AndroidManifest.xml +2 -0
- package/android/src/main/java/expo/modules/mpv/ExpoMpvModule.kt +50 -0
- package/android/src/main/java/expo/modules/mpv/ExpoMpvView.kt +30 -0
- package/build/ExpoMpv.types.d.ts +128 -0
- package/build/ExpoMpv.types.d.ts.map +1 -0
- package/build/ExpoMpv.types.js +2 -0
- package/build/ExpoMpv.types.js.map +1 -0
- package/build/ExpoMpvModule.d.ts +7 -0
- package/build/ExpoMpvModule.d.ts.map +1 -0
- package/build/ExpoMpvModule.js +4 -0
- package/build/ExpoMpvModule.js.map +1 -0
- package/build/ExpoMpvView.d.ts +5 -0
- package/build/ExpoMpvView.d.ts.map +1 -0
- package/build/ExpoMpvView.js +25 -0
- package/build/ExpoMpvView.js.map +1 -0
- package/build/index.d.ts +4 -0
- package/build/index.d.ts.map +1 -0
- package/build/index.js +6 -0
- package/build/index.js.map +1 -0
- package/bun.lock +2142 -0
- package/expo-module.config.json +6 -0
- package/ios/ExpoMpv.podspec +56 -0
- package/ios/ExpoMpvModule.swift +105 -0
- package/ios/ExpoMpvView.swift +589 -0
- package/ios/download-mpvkit.sh +85 -0
- package/package.json +43 -0
- package/src/ExpoMpv.types.ts +145 -0
- package/src/ExpoMpvModule.ts +8 -0
- package/src/ExpoMpvView.tsx +33 -0
- package/src/index.ts +5 -0
- package/tsconfig.json +9 -0
package/.eslintrc.js
ADDED
package/README.md
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# expo-mpv
|
|
2
|
+
|
|
3
|
+
# API documentation
|
|
4
|
+
|
|
5
|
+
- [Documentation for the latest stable release](https://docs.expo.dev/versions/latest/sdk/mpv/)
|
|
6
|
+
- [Documentation for the main branch](https://docs.expo.dev/versions/unversioned/sdk/mpv/)
|
|
7
|
+
|
|
8
|
+
# Installation in managed Expo projects
|
|
9
|
+
|
|
10
|
+
For [managed](https://docs.expo.dev/archive/managed-vs-bare/) Expo projects, please follow the installation instructions in the [API documentation for the latest stable release](#api-documentation). If you follow the link and there is no documentation available then this library is not yet usable within managed projects — it is likely to be included in an upcoming Expo SDK release.
|
|
11
|
+
|
|
12
|
+
# Installation in bare React Native projects
|
|
13
|
+
|
|
14
|
+
For bare React Native projects, you must ensure that you have [installed and configured the `expo` package](https://docs.expo.dev/bare/installing-expo-modules/) before continuing.
|
|
15
|
+
|
|
16
|
+
### Add the package to your npm dependencies
|
|
17
|
+
|
|
18
|
+
```
|
|
19
|
+
npm install expo-mpv
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
### Configure for Android
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
### Configure for iOS
|
|
28
|
+
|
|
29
|
+
Run `npx pod-install` after installing the npm package.
|
|
30
|
+
|
|
31
|
+
# Contributing
|
|
32
|
+
|
|
33
|
+
Contributions are very welcome! Please refer to guidelines described in the [contributing guide]( https://github.com/expo/expo#contributing).
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
plugins {
|
|
2
|
+
id 'com.android.library'
|
|
3
|
+
id 'expo-module-gradle-plugin'
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
group = 'expo.modules.mpv'
|
|
7
|
+
version = '0.1.0'
|
|
8
|
+
|
|
9
|
+
android {
|
|
10
|
+
namespace "expo.modules.mpv"
|
|
11
|
+
defaultConfig {
|
|
12
|
+
versionCode 1
|
|
13
|
+
versionName "0.1.0"
|
|
14
|
+
}
|
|
15
|
+
lintOptions {
|
|
16
|
+
abortOnError false
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
package expo.modules.mpv
|
|
2
|
+
|
|
3
|
+
import expo.modules.kotlin.modules.Module
|
|
4
|
+
import expo.modules.kotlin.modules.ModuleDefinition
|
|
5
|
+
import java.net.URL
|
|
6
|
+
|
|
7
|
+
class ExpoMpvModule : Module() {
|
|
8
|
+
// Each module class must implement the definition function. The definition consists of components
|
|
9
|
+
// that describes the module's functionality and behavior.
|
|
10
|
+
// See https://docs.expo.dev/modules/module-api for more details about available components.
|
|
11
|
+
override fun definition() = ModuleDefinition {
|
|
12
|
+
// Sets the name of the module that JavaScript code will use to refer to the module. Takes a string as an argument.
|
|
13
|
+
// Can be inferred from module's class name, but it's recommended to set it explicitly for clarity.
|
|
14
|
+
// The module will be accessible from `requireNativeModule('ExpoMpv')` in JavaScript.
|
|
15
|
+
Name("ExpoMpv")
|
|
16
|
+
|
|
17
|
+
// Defines constant property on the module.
|
|
18
|
+
Constant("PI") {
|
|
19
|
+
Math.PI
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// Defines event names that the module can send to JavaScript.
|
|
23
|
+
Events("onChange")
|
|
24
|
+
|
|
25
|
+
// Defines a JavaScript synchronous function that runs the native code on the JavaScript thread.
|
|
26
|
+
Function("hello") {
|
|
27
|
+
"Hello world! 👋"
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// Defines a JavaScript function that always returns a Promise and whose native code
|
|
31
|
+
// is by default dispatched on the different thread than the JavaScript runtime runs on.
|
|
32
|
+
AsyncFunction("setValueAsync") { value: String ->
|
|
33
|
+
// Send an event to JavaScript.
|
|
34
|
+
sendEvent("onChange", mapOf(
|
|
35
|
+
"value" to value
|
|
36
|
+
))
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// Enables the module to be used as a native view. Definition components that are accepted as part of
|
|
40
|
+
// the view definition: Prop, Events.
|
|
41
|
+
View(ExpoMpvView::class) {
|
|
42
|
+
// Defines a setter for the `url` prop.
|
|
43
|
+
Prop("url") { view: ExpoMpvView, url: URL ->
|
|
44
|
+
view.webView.loadUrl(url.toString())
|
|
45
|
+
}
|
|
46
|
+
// Defines an event that the view can send to JavaScript.
|
|
47
|
+
Events("onLoad")
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
package expo.modules.mpv
|
|
2
|
+
|
|
3
|
+
import android.content.Context
|
|
4
|
+
import android.webkit.WebView
|
|
5
|
+
import android.webkit.WebViewClient
|
|
6
|
+
import expo.modules.kotlin.AppContext
|
|
7
|
+
import expo.modules.kotlin.viewevent.EventDispatcher
|
|
8
|
+
import expo.modules.kotlin.views.ExpoView
|
|
9
|
+
|
|
10
|
+
class ExpoMpvView(context: Context, appContext: AppContext) : ExpoView(context, appContext) {
|
|
11
|
+
// Creates and initializes an event dispatcher for the `onLoad` event.
|
|
12
|
+
// The name of the event is inferred from the value and needs to match the event name defined in the module.
|
|
13
|
+
private val onLoad by EventDispatcher()
|
|
14
|
+
|
|
15
|
+
// Defines a WebView that will be used as the root subview.
|
|
16
|
+
internal val webView = WebView(context).apply {
|
|
17
|
+
layoutParams = LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)
|
|
18
|
+
webViewClient = object : WebViewClient() {
|
|
19
|
+
override fun onPageFinished(view: WebView, url: String) {
|
|
20
|
+
// Sends an event to JavaScript. Triggers a callback defined on the view component in JavaScript.
|
|
21
|
+
onLoad(mapOf("url" to url))
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
init {
|
|
27
|
+
// Adds the WebView to the view hierarchy.
|
|
28
|
+
addView(webView)
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import type { StyleProp, ViewStyle } from 'react-native';
|
|
2
|
+
export type PlaybackStateChangeEvent = {
|
|
3
|
+
state: 'playing' | 'paused' | 'stopped';
|
|
4
|
+
isPlaying: boolean;
|
|
5
|
+
};
|
|
6
|
+
export type ProgressEvent = {
|
|
7
|
+
position: number;
|
|
8
|
+
duration: number;
|
|
9
|
+
bufferedDuration: number;
|
|
10
|
+
};
|
|
11
|
+
export type LoadEvent = {
|
|
12
|
+
duration: number;
|
|
13
|
+
width: number;
|
|
14
|
+
height: number;
|
|
15
|
+
};
|
|
16
|
+
export type ErrorEvent = {
|
|
17
|
+
error: string;
|
|
18
|
+
};
|
|
19
|
+
export type EndEvent = {
|
|
20
|
+
reason: 'ended' | 'error' | 'stopped' | 'unknown';
|
|
21
|
+
};
|
|
22
|
+
export type BufferEvent = {
|
|
23
|
+
isBuffering: boolean;
|
|
24
|
+
};
|
|
25
|
+
export type SeekEvent = {};
|
|
26
|
+
export type VolumeChangeEvent = {
|
|
27
|
+
volume: number;
|
|
28
|
+
muted: boolean;
|
|
29
|
+
};
|
|
30
|
+
export type PlaybackInfo = {
|
|
31
|
+
position: number;
|
|
32
|
+
duration: number;
|
|
33
|
+
isPlaying: boolean;
|
|
34
|
+
speed: number;
|
|
35
|
+
volume: number;
|
|
36
|
+
muted: boolean;
|
|
37
|
+
};
|
|
38
|
+
export type ExpoMpvModuleEvents = {};
|
|
39
|
+
export type ExpoMpvViewProps = {
|
|
40
|
+
/**
|
|
41
|
+
* Media source URL to play. Can be a remote URL or a local file path.
|
|
42
|
+
*/
|
|
43
|
+
source?: string;
|
|
44
|
+
/**
|
|
45
|
+
* Whether playback is paused.
|
|
46
|
+
*/
|
|
47
|
+
paused?: boolean;
|
|
48
|
+
/**
|
|
49
|
+
* Playback speed multiplier. Default is 1.0.
|
|
50
|
+
*/
|
|
51
|
+
speed?: number;
|
|
52
|
+
/**
|
|
53
|
+
* Volume level (0-100). Default is 100.
|
|
54
|
+
*/
|
|
55
|
+
volume?: number;
|
|
56
|
+
/**
|
|
57
|
+
* Whether audio is muted.
|
|
58
|
+
*/
|
|
59
|
+
muted?: boolean;
|
|
60
|
+
/**
|
|
61
|
+
* Whether to loop the current file.
|
|
62
|
+
*/
|
|
63
|
+
loop?: boolean;
|
|
64
|
+
/**
|
|
65
|
+
* Called when playback state changes (play/pause).
|
|
66
|
+
*/
|
|
67
|
+
onPlaybackStateChange?: (event: {
|
|
68
|
+
nativeEvent: PlaybackStateChangeEvent;
|
|
69
|
+
}) => void;
|
|
70
|
+
/**
|
|
71
|
+
* Called periodically with current playback progress.
|
|
72
|
+
*/
|
|
73
|
+
onProgress?: (event: {
|
|
74
|
+
nativeEvent: ProgressEvent;
|
|
75
|
+
}) => void;
|
|
76
|
+
/**
|
|
77
|
+
* Called when a media file has been loaded and is ready to play.
|
|
78
|
+
*/
|
|
79
|
+
onLoad?: (event: {
|
|
80
|
+
nativeEvent: LoadEvent;
|
|
81
|
+
}) => void;
|
|
82
|
+
/**
|
|
83
|
+
* Called when an error occurs.
|
|
84
|
+
*/
|
|
85
|
+
onError?: (event: {
|
|
86
|
+
nativeEvent: ErrorEvent;
|
|
87
|
+
}) => void;
|
|
88
|
+
/**
|
|
89
|
+
* Called when playback reaches the end.
|
|
90
|
+
*/
|
|
91
|
+
onEnd?: (event: {
|
|
92
|
+
nativeEvent: EndEvent;
|
|
93
|
+
}) => void;
|
|
94
|
+
/**
|
|
95
|
+
* Called when buffering state changes.
|
|
96
|
+
*/
|
|
97
|
+
onBuffer?: (event: {
|
|
98
|
+
nativeEvent: BufferEvent;
|
|
99
|
+
}) => void;
|
|
100
|
+
/**
|
|
101
|
+
* Called when a seek operation completes.
|
|
102
|
+
*/
|
|
103
|
+
onSeek?: (event: {
|
|
104
|
+
nativeEvent: SeekEvent;
|
|
105
|
+
}) => void;
|
|
106
|
+
/**
|
|
107
|
+
* Called when volume or mute state changes.
|
|
108
|
+
*/
|
|
109
|
+
onVolumeChange?: (event: {
|
|
110
|
+
nativeEvent: VolumeChangeEvent;
|
|
111
|
+
}) => void;
|
|
112
|
+
style?: StyleProp<ViewStyle>;
|
|
113
|
+
};
|
|
114
|
+
export type ExpoMpvViewRef = {
|
|
115
|
+
play: () => Promise<void>;
|
|
116
|
+
pause: () => Promise<void>;
|
|
117
|
+
togglePlay: () => Promise<void>;
|
|
118
|
+
stop: () => Promise<void>;
|
|
119
|
+
seekTo: (position: number) => Promise<void>;
|
|
120
|
+
seekBy: (offset: number) => Promise<void>;
|
|
121
|
+
setSpeed: (speed: number) => Promise<void>;
|
|
122
|
+
setVolume: (volume: number) => Promise<void>;
|
|
123
|
+
setMuted: (muted: boolean) => Promise<void>;
|
|
124
|
+
setSubtitleTrack: (trackId: number) => Promise<void>;
|
|
125
|
+
setAudioTrack: (trackId: number) => Promise<void>;
|
|
126
|
+
getPlaybackInfo: () => Promise<PlaybackInfo>;
|
|
127
|
+
};
|
|
128
|
+
//# sourceMappingURL=ExpoMpv.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ExpoMpv.types.d.ts","sourceRoot":"","sources":["../src/ExpoMpv.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAIzD,MAAM,MAAM,wBAAwB,GAAG;IACrC,KAAK,EAAE,SAAS,GAAG,QAAQ,GAAG,SAAS,CAAC;IACxC,SAAS,EAAE,OAAO,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAC1B,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,gBAAgB,EAAE,MAAM,CAAC;CAC1B,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG;IACtB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG;IACvB,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,QAAQ,GAAG;IACrB,MAAM,EAAE,OAAO,GAAG,OAAO,GAAG,SAAS,GAAG,SAAS,CAAC;CACnD,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG;IACxB,WAAW,EAAE,OAAO,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG,EAAE,CAAC;AAE3B,MA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EAAE,MAAM,OAAO,CAAC,YAAY,CAAC,CAAC;CAC9C,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ExpoMpv.types.js","sourceRoot":"","sources":["../src/ExpoMpv.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { StyleProp, ViewStyle } from 'react-native';\n\n// MARK: - Event Payloads\n\nexport type PlaybackStateChangeEvent = {\n state: 'playing' | 'paused' | 'stopped';\n isPlaying: boolean;\n};\n\nexport type ProgressEvent = {\n position: number;\n duration: number;\n bufferedDuration: number;\n};\n\nexport type LoadEvent = {\n duration: number;\n width: number;\n height: number;\n};\n\nexport type ErrorEvent = {\n error: string;\n};\n\nexport type EndEvent = {\n reason: 'ended' | 'error' | 'stopped' | 'unknown';\n};\n\nexport type BufferEvent = {\n isBuffering: boolean;\n};\n\nexport type SeekEvent = {};\n\nexport type VolumeChangeEvent = {\n volume: number;\n muted: boolean;\n};\n\nexport type PlaybackInfo = {\n position: number;\n duration: number;\n isPlaying: boolean;\n speed: number;\n volume: number;\n muted: boolean;\n};\n\n// MARK: - Module Events (non-view)\n\nexport type ExpoMpvModuleEvents = {};\n\n// MARK: - View Props\n\nexport type ExpoMpvViewProps = {\n /**\n * Media source URL to play. Can be a remote URL or a local file path.\n */\n source?: string;\n\n /**\n * Whether playback is paused.\n */\n paused?: boolean;\n\n /**\n * Playback speed multiplier. Default is 1.0.\n */\n speed?: number;\n\n /**\n * Volume level (0-100). Default is 100.\n */\n volume?: number;\n\n /**\n * Whether audio is muted.\n */\n muted?: boolean;\n\n /**\n * Whether to loop the current file.\n */\n loop?: boolean;\n\n /**\n * Called when playback state changes (play/pause).\n */\n onPlaybackStateChange?: (event: { nativeEvent: PlaybackStateChangeEvent }) => void;\n\n /**\n * Called periodically with current playback progress.\n */\n onProgress?: (event: { nativeEvent: ProgressEvent }) => void;\n\n /**\n * Called when a media file has been loaded and is ready to play.\n */\n onLoad?: (event: { nativeEvent: LoadEvent }) => void;\n\n /**\n * Called when an error occurs.\n */\n onError?: (event: { nativeEvent: ErrorEvent }) => void;\n\n /**\n * Called when playback reaches the end.\n */\n onEnd?: (event: { nativeEvent: EndEvent }) => void;\n\n /**\n * Called when buffering state changes.\n */\n onBuffer?: (event: { nativeEvent: BufferEvent }) => void;\n\n /**\n * Called when a seek operation completes.\n */\n onSeek?: (event: { nativeEvent: SeekEvent }) => void;\n\n /**\n * Called when volume or mute state changes.\n */\n onVolumeChange?: (event: { nativeEvent: VolumeChangeEvent }) => void;\n\n style?: StyleProp<ViewStyle>;\n};\n\n// MARK: - View Ref Methods\n\nexport type ExpoMpvViewRef = {\n play: () => Promise<void>;\n pause: () => Promise<void>;\n togglePlay: () => Promise<void>;\n stop: () => Promise<void>;\n seekTo: (position: number) => Promise<void>;\n seekBy: (offset: number) => Promise<void>;\n setSpeed: (speed: number) => Promise<void>;\n setVolume: (volume: number) => Promise<void>;\n setMuted: (muted: boolean) => Promise<void>;\n setSubtitleTrack: (trackId: number) => Promise<void>;\n setAudioTrack: (trackId: number) => Promise<void>;\n getPlaybackInfo: () => Promise<PlaybackInfo>;\n};\n"]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { NativeModule } from 'expo';
|
|
2
|
+
import { ExpoMpvModuleEvents } from './ExpoMpv.types';
|
|
3
|
+
declare class ExpoMpvModule extends NativeModule<ExpoMpvModuleEvents> {
|
|
4
|
+
}
|
|
5
|
+
declare const _default: ExpoMpvModule;
|
|
6
|
+
export default _default;
|
|
7
|
+
//# sourceMappingURL=ExpoMpvModule.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ExpoMpvModule.d.ts","sourceRoot":"","sources":["../src/ExpoMpvModule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAuB,MAAM,MAAM,CAAC;AAEzD,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAEtD,OAAO,OAAO,aAAc,SAAQ,YAAY,CAAC,mBAAmB,CAAC;CAAG;;AAGxE,wBAA6D"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ExpoMpvModule.js","sourceRoot":"","sources":["../src/ExpoMpvModule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,mBAAmB,EAAE,MAAM,MAAM,CAAC;AAMzD,yDAAyD;AACzD,eAAe,mBAAmB,CAAgB,SAAS,CAAC,CAAC","sourcesContent":["import { NativeModule, requireNativeModule } from 'expo';\n\nimport { ExpoMpvModuleEvents } from './ExpoMpv.types';\n\ndeclare class ExpoMpvModule extends NativeModule<ExpoMpvModuleEvents> {}\n\n// This call loads the native module object from the JSI.\nexport default requireNativeModule<ExpoMpvModule>('ExpoMpv');\n"]}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { ExpoMpvViewProps, ExpoMpvViewRef } from './ExpoMpv.types';
|
|
3
|
+
declare const ExpoMpvView: React.ForwardRefExoticComponent<ExpoMpvViewProps & React.RefAttributes<ExpoMpvViewRef>>;
|
|
4
|
+
export default ExpoMpvView;
|
|
5
|
+
//# sourceMappingURL=ExpoMpvView.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ExpoMpvView.d.ts","sourceRoot":"","sources":["../src/ExpoMpvView.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAKnE,QAAA,MAAM,WAAW,yFAmBf,CAAC;AAIH,eAAe,WAAW,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { requireNativeView } from 'expo';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { forwardRef, useImperativeHandle, useRef } from 'react';
|
|
4
|
+
const NativeView = requireNativeView('ExpoMpv');
|
|
5
|
+
const ExpoMpvView = forwardRef((props, ref) => {
|
|
6
|
+
const nativeRef = useRef(null);
|
|
7
|
+
useImperativeHandle(ref, () => ({
|
|
8
|
+
play: () => nativeRef.current?.play(),
|
|
9
|
+
pause: () => nativeRef.current?.pause(),
|
|
10
|
+
togglePlay: () => nativeRef.current?.togglePlay(),
|
|
11
|
+
stop: () => nativeRef.current?.stop(),
|
|
12
|
+
seekTo: (position) => nativeRef.current?.seekTo(position),
|
|
13
|
+
seekBy: (offset) => nativeRef.current?.seekBy(offset),
|
|
14
|
+
setSpeed: (speed) => nativeRef.current?.setSpeed(speed),
|
|
15
|
+
setVolume: (volume) => nativeRef.current?.setVolume(volume),
|
|
16
|
+
setMuted: (muted) => nativeRef.current?.setMuted(muted),
|
|
17
|
+
setSubtitleTrack: (trackId) => nativeRef.current?.setSubtitleTrack(trackId),
|
|
18
|
+
setAudioTrack: (trackId) => nativeRef.current?.setAudioTrack(trackId),
|
|
19
|
+
getPlaybackInfo: () => nativeRef.current?.getPlaybackInfo(),
|
|
20
|
+
}));
|
|
21
|
+
return <NativeView ref={nativeRef} {...props}/>;
|
|
22
|
+
});
|
|
23
|
+
ExpoMpvView.displayName = 'ExpoMpvView';
|
|
24
|
+
export default ExpoMpvView;
|
|
25
|
+
//# sourceMappingURL=ExpoMpvView.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ExpoMpvView.js","sourceRoot":"","sources":["../src/ExpoMpvView.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,MAAM,CAAC;AACzC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,UAAU,EAAE,mBAAmB,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAIhE,MAAM,UAAU,GACd,iBAAiB,CAAC,SAAS,CAAC,CAAC;AAE/B,MAAM,WAAW,GAAG,UAAU,CAAmC,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;IAC9E,MAAM,SAAS,GAAG,MAAM,CAAM,IAAI,CAAC,CAAC;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AACnD,CAAC,CAAC,CAAC;AAEH,WAAW,CAAC,WAAW,GAAG,aAAa,CAAC;AAExC,eAAe,WAAW,CAAC","sourcesContent":["import { requireNativeView } from 'expo';\nimport * as React from 'react';\nimport { forwardRef, useImperativeHandle, useRef } from 'react';\n\nimport { ExpoMpvViewProps, ExpoMpvViewRef } from './ExpoMpv.types';\n\nconst NativeView: React.ComponentType<ExpoMpvViewProps & { ref?: React.Ref<any> }> =\n requireNativeView('ExpoMpv');\n\nconst ExpoMpvView = forwardRef<ExpoMpvViewRef, ExpoMpvViewProps>((props, ref) => {\n const nativeRef = useRef<any>(null);\n\n useImperativeHandle(ref, () => ({\n play: () => nativeRef.current?.play(),\n pause: () => nativeRef.current?.pause(),\n togglePlay: () => nativeRef.current?.togglePlay(),\n stop: () => nativeRef.current?.stop(),\n seekTo: (position: number) => nativeRef.current?.seekTo(position),\n seekBy: (offset: number) => nativeRef.current?.seekBy(offset),\n setSpeed: (speed: number) => nativeRef.current?.setSpeed(speed),\n setVolume: (volume: number) => nativeRef.current?.setVolume(volume),\n setMuted: (muted: boolean) => nativeRef.current?.setMuted(muted),\n setSubtitleTrack: (trackId: number) => nativeRef.current?.setSubtitleTrack(trackId),\n setAudioTrack: (trackId: number) => nativeRef.current?.setAudioTrack(trackId),\n getPlaybackInfo: () => nativeRef.current?.getPlaybackInfo(),\n }));\n\n return <NativeView ref={nativeRef} {...props} />;\n});\n\nExpoMpvView.displayName = 'ExpoMpvView';\n\nexport default ExpoMpvView;\n"]}
|
package/build/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC1C,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,eAAe,CAAC;AACvD,cAAc,iBAAiB,CAAC"}
|
package/build/index.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
// Reexport the native module. On web, it will be resolved to ExpoMpvModule.web.ts
|
|
2
|
+
// and on native platforms to ExpoMpvModule.ts
|
|
3
|
+
export { default } from './ExpoMpvModule';
|
|
4
|
+
export { default as ExpoMpvView } from './ExpoMpvView';
|
|
5
|
+
export * from './ExpoMpv.types';
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,kFAAkF;AAClF,8CAA8C;AAC9C,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC1C,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,eAAe,CAAC;AACvD,cAAc,iBAAiB,CAAC","sourcesContent":["// Reexport the native module. On web, it will be resolved to ExpoMpvModule.web.ts\n// and on native platforms to ExpoMpvModule.ts\nexport { default } from './ExpoMpvModule';\nexport { default as ExpoMpvView } from './ExpoMpvView';\nexport * from './ExpoMpv.types';\n"]}
|