expo-libmpv 0.4.4 → 0.4.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.
@@ -1,7 +1,7 @@
1
1
  apply plugin: 'com.android.library'
2
2
 
3
3
  group = 'com.libmpv'
4
- version = '0.3.5'
4
+ version = '0.4.5'
5
5
  def expoModulesCorePlugin = new File(project(":expo-modules-core").projectDir.absolutePath, "ExpoModulesCorePlugin.gradle")
6
6
  apply from: expoModulesCorePlugin
7
7
  applyKotlinExpoModulesCorePlugin()
@@ -43,7 +43,7 @@ android {
43
43
  namespace "com.libmpv"
44
44
  defaultConfig {
45
45
  versionCode 1
46
- versionName "0.3.5"
46
+ versionName "0.4.5"
47
47
  }
48
48
  lintOptions {
49
49
  abortOnError false
@@ -19,11 +19,6 @@ class LibmpvView(context: Context, appContext: AppContext) :
19
19
  MPVLib.LogObserver,
20
20
  MPVLib.EventObserver {
21
21
 
22
- companion object {
23
- const val HARDWARE_OPTIONS = "mediacodec-copy"
24
- const val ACCELERATED_CODECS = "h264,hevc,mpeg4,mpeg2video,vp8,vp9,av1"
25
- }
26
-
27
22
  private val onLibmpvLog by EventDispatcher()
28
23
  private val onLibmpvEvent by EventDispatcher()
29
24
 
@@ -37,8 +32,9 @@ class LibmpvView(context: Context, appContext: AppContext) :
37
32
  var surfaceHeight: Int? = null
38
33
  var audioIndex: Int? = null
39
34
  var subtitleIndex: Int? = null
40
- var useHardwareDecoder: Boolean? = null
41
35
  var videoOutput: String? = null
36
+ var decodingMode: String? = null
37
+ var acceleratedCodecs: String? = null
42
38
 
43
39
  init {
44
40
  surfaceView.holder.addCallback(this)
@@ -65,13 +61,16 @@ class LibmpvView(context: Context, appContext: AppContext) :
65
61
  }
66
62
 
67
63
  fun attemptCreation(){
68
- val allPropsReady = playUrl != null &&
69
- surfaceWidth != null &&
70
- surfaceHeight != null &&
71
- audioIndex != null &&
72
- subtitleIndex != null &&
73
- useHardwareDecoder != null &&
74
- videoOutput != null
64
+ val allPropsReady =
65
+ playUrl != null &&
66
+ surfaceWidth != null &&
67
+ surfaceHeight != null &&
68
+ audioIndex != null &&
69
+ subtitleIndex != null &&
70
+ videoOutput != null &&
71
+ decodingMode != null &&
72
+ acceleratedCodecs != null
73
+
75
74
 
76
75
  if (allPropsReady) {
77
76
  log("LibmpvView.attemptCreation", "Initializing MPV instance")
@@ -115,13 +114,15 @@ class LibmpvView(context: Context, appContext: AppContext) :
115
114
 
116
115
  mpv.setOptionString("profile", "fast")
117
116
 
118
- videoOutput?.let { mpv.setOptionString("vo", it) }
117
+ videoOutput?.let { vo -> mpv.setOptionString("vo", vo) }
119
118
 
120
- if (useHardwareDecoder == true) {
121
- mpv.setOptionString("hwdec", HARDWARE_OPTIONS)
122
- mpv.setOptionString("hwdec-codecs", ACCELERATED_CODECS)
123
- } else {
124
- mpv.setOptionString("hwdec", "no")
119
+ decodingMode?.let { mode ->
120
+ acceleratedCodecs?.let { codecs ->
121
+ mpv.setOptionString("hwdec", mode)
122
+ if (decodingMode != "no"){
123
+ mpv.setOptionString("hwdec-codecs", codecs)
124
+ }
125
+ }
125
126
  }
126
127
 
127
128
  mpv.setOptionString("gpu-context", "android")
@@ -173,16 +174,6 @@ class LibmpvView(context: Context, appContext: AppContext) :
173
174
  mpv.play(url, options)
174
175
  }
175
176
 
176
- fun setHardwareDecoder(useHardware: Boolean) {
177
- useHardwareDecoder = useHardware
178
- if (useHardwareDecoder == true) {
179
- mpv.setOptionString("hwdec", HARDWARE_OPTIONS)
180
- mpv.setOptionString("hwdec-codecs", ACCELERATED_CODECS)
181
- } else {
182
- mpv.setOptionString("hwdec", "no")
183
- }
184
- }
185
-
186
177
  // SurfaceHolder.Callback
187
178
  override fun surfaceCreated(holder: SurfaceHolder) {
188
179
  val width = surfaceWidth ?: 0
@@ -38,14 +38,16 @@ class LibmpvViewModule : Module() {
38
38
  view.log("setPlayUrl", playUrl)
39
39
  }
40
40
 
41
- Prop("useHardwareDecoder") { view: LibmpvView, useHardwareDecoder: Boolean ->
42
- view.useHardwareDecoder = useHardwareDecoder
43
- if (view.isSurfaceReady()) {
44
- view.setHardwareDecoder(useHardwareDecoder)
45
- } else {
46
- view.attemptCreation()
47
- }
48
- view.log("setUseHardwareDecoder", "$useHardwareDecoder")
41
+ Prop("decodingMode") { view: LibmpvView, decodingMode: String ->
42
+ view.decodingMode = decodingMode
43
+ view.attemptCreation()
44
+ view.log("setDecodingMode", "$decodingMode")
45
+ }
46
+
47
+ Prop("acceleratedCodecs") { view: LibmpvView, acceleratedCodecs: String ->
48
+ view.acceleratedCodecs = acceleratedCodecs
49
+ view.attemptCreation()
50
+ view.log("setAcceleratedCodecs", "$acceleratedCodecs")
49
51
  }
50
52
 
51
53
  Prop("surfaceWidth") { view: LibmpvView, surfaceWidth: Int ->
package/app.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "expo": {
3
- "runtimeVersion": "0.3.5",
3
+ "runtimeVersion": "0.4.5",
4
4
  "plugins": [
5
5
  [
6
6
  "expo-build-properties",
@@ -1,5 +1,7 @@
1
1
  import * as React from 'react';
2
2
  import { LibmpvViewProps, LibmpvViewNativeMethods } from './LibmpvViewTypes';
3
+ export declare const DEFAULT_DECODING_MODE: string;
4
+ export declare const DEFAULT_ACCELERATED_CODECS: string;
3
5
  export declare const LibmpvView: React.ForwardRefExoticComponent<Omit<LibmpvViewProps, "ref"> & React.RefAttributes<LibmpvViewNativeMethods>>;
4
6
  export default LibmpvView;
5
7
  //# sourceMappingURL=LibmpvView.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"LibmpvView.d.ts","sourceRoot":"","sources":["../src/LibmpvView.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,eAAe,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAC;AAkC7E,eAAO,MAAM,UAAU,8GAuDrB,CAAA;AAEF,eAAe,UAAU,CAAA"}
1
+ {"version":3,"file":"LibmpvView.d.ts","sourceRoot":"","sources":["../src/LibmpvView.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,eAAe,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAC;AAkC7E,eAAO,MAAM,qBAAqB,EAAE,MAA0B,CAAA;AAE9D,eAAO,MAAM,0BAA0B,EAAE,MAAiD,CAAA;AAE1F,eAAO,MAAM,UAAU,8GAwDrB,CAAA;AAEF,eAAe,UAAU,CAAA"}
@@ -29,6 +29,8 @@ const EVENT_LOOKUP = {
29
29
  25: 'HOOK'
30
30
  };
31
31
  const LibmpvViewNative = requireNativeView('LibmpvView');
32
+ export const DEFAULT_DECODING_MODE = "mediacodec-copy";
33
+ export const DEFAULT_ACCELERATED_CODECS = "h264,hevc,mpeg4,mpeg2video,vp8,vp9,av1";
32
34
  export const LibmpvView = React.forwardRef((props, parentRef) => {
33
35
  React.useEffect(() => {
34
36
  return () => {
@@ -67,7 +69,7 @@ export const LibmpvView = React.forwardRef((props, parentRef) => {
67
69
  // The order props are handled in the native code is non-deterministic
68
70
  // Each native prop setter checks to see if all required props are set
69
71
  // Only then will it try to create an instance of mpv
70
- return <LibmpvViewNative ref={parentRef} style={props.surfaceStyle ? props.surfaceStyle : styles.videoPlayer} videoOutput={props.videoOutput} playUrl={props.playUrl} isPlaying={props.isPlaying} useHardwareDecoder={props.useHardwareDecoder} surfaceWidth={props.surfaceWidth} surfaceHeight={props.surfaceHeight} selectedAudioTrack={props.selectedAudioTrack} selectedSubtitleTrack={props.selectedSubtitleTrack} seekToSeconds={props.seekToSeconds} onLibmpvEvent={onLogEvent} onLibmpvLog={onLibmpvLog}/>;
72
+ return <LibmpvViewNative ref={parentRef} style={props.surfaceStyle ? props.surfaceStyle : styles.videoPlayer} videoOutput={props.videoOutput} playUrl={props.playUrl} isPlaying={props.isPlaying} decodingMode={props.decodingMode} acceleratedCodecs={props.acceleratedCodecs} surfaceWidth={props.surfaceWidth} surfaceHeight={props.surfaceHeight} selectedAudioTrack={props.selectedAudioTrack} selectedSubtitleTrack={props.selectedSubtitleTrack} seekToSeconds={props.seekToSeconds} onLibmpvEvent={onLogEvent} onLibmpvLog={onLibmpvLog}/>;
71
73
  });
72
74
  export default LibmpvView;
73
75
  //# sourceMappingURL=LibmpvView.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"LibmpvView.js","sourceRoot":"","sources":["../src/LibmpvView.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,MAAM,CAAC;AACzC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,MAAM,MAAM,GAAQ;IAClB,WAAW,EAAE;QACX,QAAQ,EAAE,UAAU;QACpB,IAAI,EAAE,CAAC;QACP,MAAM,EAAE,CAAC;QACT,KAAK,EAAE,CAAC;QACR,GAAG,EAAE,CAAC;KACP;CACF,CAAC;AAEF,MAAM,YAAY,GAAQ;IACxB,CAAC,EAAE,MAAM;IACT,CAAC,EAAE,UAAU;IACb,CAAC,EAAE,aAAa;IAChB,CAAC,EAAE,oBAAoB;IACvB,CAAC,EAAE,oBAAoB;IACvB,CAAC,EAAE,eAAe;IAClB,CAAC,EAAE,YAAY;IACf,CAAC,EAAE,UAAU;IACb,CAAC,EAAE,aAAa;IAChB,EAAE,EAAE,gBAAgB;IACpB,EAAE,EAAE,gBAAgB;IACpB,EAAE,EAAE,gBAAgB;IACpB,EAAE,EAAE,MAAM;IACV,EAAE,EAAE,kBAAkB;IACtB,EAAE,EAAE,iBAAiB;IACrB,EAAE,EAAE,gBAAgB;IACpB,EAAE,EAAE,MAAM;CACX,CAAA;AAED,MAAM,gBAAgB,GAAyC,iBAAiB,CAAC,YAAY,CAAC,CAAC;AAE/F,MAAM,CAAC,MAAM,UAAU,GAAG,KAAK,CAAC,UAAU,CAA2C,CAAC,KAAU,EAAE,SAAc,EAAE,EAAE;IAClH,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE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,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC;QACtC,CAAC;IACH,CAAC,CAAA;IAED,sEAAsE;IACtE,sEAAsE;IACtE,qDAAqD;IACrD,OAAO,CAAC,gBAAgB,CACtB,GAAG,CAAC,CAAC,SAAS,CAAC,CACf,KAAK,CAAC,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC,CAAC,MAAM,CAAC,WAAW,CAAC,CACpE,WAAW,CAAC,CAAC,KAAK,CAAC,WAAW,CAAC,CAC/B,OAAO,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CACvB,SAAS,CAAC,CAAC,KAAK,CAAC,SAAS,CAAC,CAC3B,kBAAkB,CAAC,CAAC,KAAK,CAAC,kBAAkB,CAAC,CAC7C,YAAY,CAAC,CAAC,KAAK,CAAC,YAAY,CAAC,CACjC,aAAa,CAAC,CAAC,KAAK,CAAC,aAAa,CAAC,CACnC,kBAAkB,CAAC,CAAC,KAAK,CAAC,kBAAkB,CAAC,CAC7C,qBAAqB,CAAC,CAAC,KAAK,CAAC,qBAAqB,CAAC,CACnD,aAAa,CAAC,CAAC,KAAK,CAAC,aAAa,CAAC,CACnC,aAAa,CAAC,CAAC,UAAU,CAAC,CAC1B,WAAW,CAAC,CAAC,WAAW,CAAC,EACzB,CAAA;AACJ,CAAC,CAAC,CAAA;AAEF,eAAe,UAAU,CAAA","sourcesContent":["import { requireNativeView } from 'expo';\nimport * as React from 'react';\nimport { LibmpvViewProps, LibmpvViewNativeMethods } from './LibmpvViewTypes';\n\nconst styles: any = {\n videoPlayer: {\n position: \"absolute\",\n left: 0,\n bottom: 0,\n right: 0,\n top: 0\n }\n};\n\nconst EVENT_LOOKUP: any = {\n 0: 'NONE',\n 1: 'SHUTDOWN',\n 2: 'LOG_MESSAGE',\n 3: 'GET_PROPERTY_REPLY',\n 4: 'SET_PROPERTY_REPLY',\n 5: 'COMMAND_REPLY',\n 6: 'START_FILE',\n 7: 'END_FILE',\n 8: 'FILE_LOADED',\n 16: 'CLIENT_MESSAGE',\n 17: 'VIDEO_RECONFIG',\n 18: 'AUDIO_RECONFIG',\n 20: 'SEEK',\n 21: 'PLAYBACK_RESTART',\n 22: 'PROPERTY_CHANGE',\n 24: 'QUEUE_OVERFLOW',\n 25: 'HOOK'\n}\n\nconst LibmpvViewNative: React.ComponentType<LibmpvViewProps> = requireNativeView('LibmpvView');\n\nexport const LibmpvView = React.forwardRef<LibmpvViewNativeMethods, LibmpvViewProps>((props: any, parentRef: any) => {\n React.useEffect(() => {\n return () => {\n if (parentRef?.current?.cleanup) {\n parentRef.current.cleanup();\n }\n };\n }, []);\n\n // Pass mpv events and logs back up to the parent\n const onLogEvent = (libmpvEvent: any) => {\n if (props.onLibmpvEvent) {\n if (libmpvEvent && libmpvEvent.nativeEvent) {\n libmpvEvent = libmpvEvent.nativeEvent\n }\n if (libmpvEvent.eventId) {\n libmpvEvent.value = parseInt(libmpvEvent.eventId, 10)\n libmpvEvent.eventKind = EVENT_LOOKUP[libmpvEvent.eventId]\n }\n else if (libmpvEvent.kind === 'long' || libmpvEvent.kind === 'double') {\n libmpvEvent.value = Number(libmpvEvent.value)\n }\n else if (libmpvEvent.kind === 'boolean') {\n libmpvEvent.value = libmpvEvent.value === 'true'\n }\n return props.onLibmpvEvent(libmpvEvent)\n }\n }\n const onLibmpvLog = (libmpvLog: any) => {\n if (props.onLibmpvLog) {\n if (libmpvLog && libmpvLog.nativeEvent) {\n libmpvLog = libmpvLog.nativeEvent\n }\n return props.onLibmpvLog(libmpvLog);\n }\n }\n\n // The order props are handled in the native code is non-deterministic\n // Each native prop setter checks to see if all required props are set\n // Only then will it try to create an instance of mpv\n return <LibmpvViewNative\n ref={parentRef}\n style={props.surfaceStyle ? props.surfaceStyle : styles.videoPlayer}\n videoOutput={props.videoOutput}\n playUrl={props.playUrl}\n isPlaying={props.isPlaying}\n useHardwareDecoder={props.useHardwareDecoder}\n surfaceWidth={props.surfaceWidth}\n surfaceHeight={props.surfaceHeight}\n selectedAudioTrack={props.selectedAudioTrack}\n selectedSubtitleTrack={props.selectedSubtitleTrack}\n seekToSeconds={props.seekToSeconds}\n onLibmpvEvent={onLogEvent}\n onLibmpvLog={onLibmpvLog}\n />\n})\n\nexport default LibmpvView"]}
1
+ {"version":3,"file":"LibmpvView.js","sourceRoot":"","sources":["../src/LibmpvView.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,MAAM,CAAC;AACzC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,MAAM,MAAM,GAAQ;IAClB,WAAW,EAAE;QACX,QAAQ,EAAE,UAAU;QACpB,IAAI,EAAE,CAAC;QACP,MAAM,EAAE,CAAC;QACT,KAAK,EAAE,CAAC;QACR,GAAG,EAAE,CAAC;KACP;CACF,CAAC;AAEF,MAAM,YAAY,GAAQ;IACxB,CAAC,EAAE,MAAM;IACT,CAAC,EAAE,UAAU;IACb,CAAC,EAAE,aAAa;IAChB,CAAC,EAAE,oBAAoB;IACvB,CAAC,EAAE,oBAAoB;IACvB,CAAC,EAAE,eAAe;IAClB,CAAC,EAAE,YAAY;IACf,CAAC,EAAE,UAAU;IACb,CAAC,EAAE,aAAa;IAChB,EAAE,EAAE,gBAAgB;IACpB,EAAE,EAAE,gBAAgB;IACpB,EAAE,EAAE,gBAAgB;IACpB,EAAE,EAAE,MAAM;IACV,EAAE,EAAE,kBAAkB;IACtB,EAAE,EAAE,iBAAiB;IACrB,EAAE,EAAE,gBAAgB;IACpB,EAAE,EAAE,MAAM;CACX,CAAA;AAED,MAAM,gBAAgB,GAAyC,iBAAiB,CAAC,YAAY,CAAC,CAAC;AAE/F,MAAM,CAAC,MAAM,qBAAqB,GAAW,iBAAiB,CAAA;AAE9D,MAAM,CAAC,MAAM,0BAA0B,GAAW,wCAAwC,CAAA;AAE1F,MAAM,CAAC,MAAM,UAAU,GAAG,KAAK,CAAC,UAAU,CAA2C,CAAC,KAAU,EAAE,SAA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AG,SAAS,CAAC,WAAW,CAAA;YACnC,CAAC;YACD,OAAO,KAAK,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC;QACtC,CAAC;IACH,CAAC,CAAA;IAED,sEAAsE;IACtE,sEAAsE;IACtE,qDAAqD;IACrD,OAAO,CAAC,gBAAgB,CACtB,GAAG,CAAC,CAAC,SAAS,CAAC,CACf,KAAK,CAAC,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC,CAAC,MAAM,CAAC,WAAW,CAAC,CACpE,WAAW,CAAC,CAAC,KAAK,CAAC,WAAW,CAAC,CAC/B,OAAO,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CACvB,SAAS,CAAC,CAAC,KAAK,CAAC,SAAS,CAAC,CAC3B,YAAY,CAAC,CAAC,KAAK,CAAC,YAAY,CAAC,CACjC,iBAAiB,CAAC,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAC3C,YAAY,CAAC,CAAC,KAAK,CAAC,YAAY,CAAC,CACjC,aAAa,CAAC,CAAC,KAAK,CAAC,aAAa,CAAC,CACnC,kBAAkB,CAAC,CAAC,KAAK,CAAC,kBAAkB,CAAC,CAC7C,qBAAqB,CAAC,CAAC,KAAK,CAAC,qBAAqB,CAAC,CACnD,aAAa,CAAC,CAAC,KAAK,CAAC,aAAa,CAAC,CACnC,aAAa,CAAC,CAAC,UAAU,CAAC,CAC1B,WAAW,CAAC,CAAC,WAAW,CAAC,EACzB,CAAA;AACJ,CAAC,CAAC,CAAA;AAEF,eAAe,UAAU,CAAA","sourcesContent":["import { requireNativeView } from 'expo';\nimport * as React from 'react';\nimport { LibmpvViewProps, LibmpvViewNativeMethods } from './LibmpvViewTypes';\n\nconst styles: any = {\n videoPlayer: {\n position: \"absolute\",\n left: 0,\n bottom: 0,\n right: 0,\n top: 0\n }\n};\n\nconst EVENT_LOOKUP: any = {\n 0: 'NONE',\n 1: 'SHUTDOWN',\n 2: 'LOG_MESSAGE',\n 3: 'GET_PROPERTY_REPLY',\n 4: 'SET_PROPERTY_REPLY',\n 5: 'COMMAND_REPLY',\n 6: 'START_FILE',\n 7: 'END_FILE',\n 8: 'FILE_LOADED',\n 16: 'CLIENT_MESSAGE',\n 17: 'VIDEO_RECONFIG',\n 18: 'AUDIO_RECONFIG',\n 20: 'SEEK',\n 21: 'PLAYBACK_RESTART',\n 22: 'PROPERTY_CHANGE',\n 24: 'QUEUE_OVERFLOW',\n 25: 'HOOK'\n}\n\nconst LibmpvViewNative: React.ComponentType<LibmpvViewProps> = requireNativeView('LibmpvView');\n\nexport const DEFAULT_DECODING_MODE: string = \"mediacodec-copy\"\n\nexport const DEFAULT_ACCELERATED_CODECS: string = \"h264,hevc,mpeg4,mpeg2video,vp8,vp9,av1\"\n\nexport const LibmpvView = React.forwardRef<LibmpvViewNativeMethods, LibmpvViewProps>((props: any, parentRef: any) => {\n React.useEffect(() => {\n return () => {\n if (parentRef?.current?.cleanup) {\n parentRef.current.cleanup();\n }\n };\n }, []);\n\n // Pass mpv events and logs back up to the parent\n const onLogEvent = (libmpvEvent: any) => {\n if (props.onLibmpvEvent) {\n if (libmpvEvent && libmpvEvent.nativeEvent) {\n libmpvEvent = libmpvEvent.nativeEvent\n }\n if (libmpvEvent.eventId) {\n libmpvEvent.value = parseInt(libmpvEvent.eventId, 10)\n libmpvEvent.eventKind = EVENT_LOOKUP[libmpvEvent.eventId]\n }\n else if (libmpvEvent.kind === 'long' || libmpvEvent.kind === 'double') {\n libmpvEvent.value = Number(libmpvEvent.value)\n }\n else if (libmpvEvent.kind === 'boolean') {\n libmpvEvent.value = libmpvEvent.value === 'true'\n }\n return props.onLibmpvEvent(libmpvEvent)\n }\n }\n const onLibmpvLog = (libmpvLog: any) => {\n if (props.onLibmpvLog) {\n if (libmpvLog && libmpvLog.nativeEvent) {\n libmpvLog = libmpvLog.nativeEvent\n }\n return props.onLibmpvLog(libmpvLog);\n }\n }\n\n // The order props are handled in the native code is non-deterministic\n // Each native prop setter checks to see if all required props are set\n // Only then will it try to create an instance of mpv\n return <LibmpvViewNative\n ref={parentRef}\n style={props.surfaceStyle ? props.surfaceStyle : styles.videoPlayer}\n videoOutput={props.videoOutput}\n playUrl={props.playUrl}\n isPlaying={props.isPlaying}\n decodingMode={props.decodingMode}\n acceleratedCodecs={props.acceleratedCodecs}\n surfaceWidth={props.surfaceWidth}\n surfaceHeight={props.surfaceHeight}\n selectedAudioTrack={props.selectedAudioTrack}\n selectedSubtitleTrack={props.selectedSubtitleTrack}\n seekToSeconds={props.seekToSeconds}\n onLibmpvEvent={onLogEvent}\n onLibmpvLog={onLibmpvLog}\n />\n})\n\nexport default LibmpvView"]}
@@ -4,7 +4,8 @@ export type LibmpvViewProps = {
4
4
  videoOutput: string;
5
5
  playUrl: string;
6
6
  isPlaying: boolean;
7
- useHardwareDecoder: boolean;
7
+ decodingMode: string;
8
+ acceleratedCodecs: string;
8
9
  selectedAudioTrack: number;
9
10
  selectedSubtitleTrack: number;
10
11
  seekToSeconds: number;
@@ -1 +1 @@
1
- {"version":3,"file":"LibmpvViewTypes.d.ts","sourceRoot":"","sources":["../src/LibmpvViewTypes.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,eAAe,GAAG;IAC5B,GAAG,EAAE,GAAG,CAAC;IACT,KAAK,EAAE,GAAG,CAAC;IACX,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,OAAO,CAAC;IACnB,kBAAkB,EAAE,OAAO,CAAC;IAC5B,kBAAkB,EAAE,MAAM,CAAC;IAC3B,qBAAqB,EAAE,MAAM,CAAC;IAC9B,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,aAAa,EAAE,CAAC,WAAW,EAAE,GAAG,KAAK,IAAI,CAAC;IAC1C,WAAW,EAAE,CAAC,SAAS,EAAE,GAAG,KAAK,IAAI,CAAC;CACvC,CAAC;AAEF,MAAM,MAAM,uBAAuB,GAAG;IACpC,UAAU,EAAE,CAAC,sBAAsB,EAAE,MAAM,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACrE,eAAe,EAAE,CAAC,sBAAsB,EAAE,MAAM,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC3E,CAAC"}
1
+ {"version":3,"file":"LibmpvViewTypes.d.ts","sourceRoot":"","sources":["../src/LibmpvViewTypes.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,eAAe,GAAG;IAC5B,GAAG,EAAE,GAAG,CAAC;IACT,KAAK,EAAE,GAAG,CAAC;IACX,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,OAAO,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;IACrB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,kBAAkB,EAAE,MAAM,CAAC;IAC3B,qBAAqB,EAAE,MAAM,CAAC;IAC9B,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,aAAa,EAAE,CAAC,WAAW,EAAE,GAAG,KAAK,IAAI,CAAC;IAC1C,WAAW,EAAE,CAAC,SAAS,EAAE,GAAG,KAAK,IAAI,CAAC;CACvC,CAAC;AAEF,MAAM,MAAM,uBAAuB,GAAG;IACpC,UAAU,EAAE,CAAC,sBAAsB,EAAE,MAAM,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACrE,eAAe,EAAE,CAAC,sBAAsB,EAAE,MAAM,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC3E,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"LibmpvViewTypes.js","sourceRoot":"","sources":["../src/LibmpvViewTypes.ts"],"names":[],"mappings":"","sourcesContent":["export type LibmpvViewProps = {\n ref: any,\n style: any,\n videoOutput: string,\n playUrl: string,\n isPlaying: boolean,\n useHardwareDecoder: boolean,\n selectedAudioTrack: number,\n selectedSubtitleTrack: number,\n seekToSeconds: number,\n surfaceWidth: number,\n surfaceHeight: number,\n onLibmpvEvent: (libmpvEvent: any) => void,\n onLibmpvLog: (libmpvLog: any) => void,\n};\n\nexport type LibmpvViewNativeMethods = {\n runCommand: (pipeDelimitedArguments: string) => void | Promise<void>;\n setOptionString: (pipeDelimitedArguments: string) => void | Promise<void>;\n};"]}
1
+ {"version":3,"file":"LibmpvViewTypes.js","sourceRoot":"","sources":["../src/LibmpvViewTypes.ts"],"names":[],"mappings":"","sourcesContent":["export type LibmpvViewProps = {\n ref: any,\n style: any,\n videoOutput: string,\n playUrl: string,\n isPlaying: boolean,\n decodingMode: string,\n acceleratedCodecs: string,\n selectedAudioTrack: number,\n selectedSubtitleTrack: number,\n seekToSeconds: number,\n surfaceWidth: number,\n surfaceHeight: number,\n onLibmpvEvent: (libmpvEvent: any) => void,\n onLibmpvLog: (libmpvLog: any) => void,\n};\n\nexport type LibmpvViewNativeMethods = {\n runCommand: (pipeDelimitedArguments: string) => void | Promise<void>;\n setOptionString: (pipeDelimitedArguments: string) => void | Promise<void>;\n};"]}
package/build/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
1
  import { default as LibmpvView } from './LibmpvView';
2
- export { default as LibmpvView } from './LibmpvView';
2
+ export { default as LibmpvView, DEFAULT_ACCELERATED_CODECS, DEFAULT_DECODING_MODE } from './LibmpvView';
3
3
  export default LibmpvView;
4
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,cAAc,CAAC;AAErD,eAAe,UAAU,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,OAAO,IAAI,UAAU,EACxB,MAAM,cAAc,CAAC;AACtB,OAAO,EACH,OAAO,IAAI,UAAU,EACrB,0BAA0B,EAC1B,qBAAqB,EACxB,MAAM,cAAc,CAAC;AAItB,eAAe,UAAU,CAAA"}
package/build/index.js CHANGED
@@ -1,4 +1,4 @@
1
1
  import { default as LibmpvView } from './LibmpvView';
2
- export { default as LibmpvView } from './LibmpvView';
2
+ export { default as LibmpvView, DEFAULT_ACCELERATED_CODECS, DEFAULT_DECODING_MODE } from './LibmpvView';
3
3
  export default LibmpvView;
4
4
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,cAAc,CAAC;AAErD,eAAe,UAAU,CAAA","sourcesContent":["import { default as LibmpvView } from './LibmpvView';\nexport { default as LibmpvView } from './LibmpvView';\n\nexport default LibmpvView\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,OAAO,IAAI,UAAU,EACxB,MAAM,cAAc,CAAC;AACtB,OAAO,EACH,OAAO,IAAI,UAAU,EACrB,0BAA0B,EAC1B,qBAAqB,EACxB,MAAM,cAAc,CAAC;AAItB,eAAe,UAAU,CAAA","sourcesContent":["import {\n default as LibmpvView\n} from './LibmpvView';\nexport {\n default as LibmpvView,\n DEFAULT_ACCELERATED_CODECS,\n DEFAULT_DECODING_MODE\n} from './LibmpvView';\n\n\n\nexport default LibmpvView\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expo-libmpv",
3
- "version": "0.4.4",
3
+ "version": "0.4.5",
4
4
  "description": "A libmpv Fabric component for Android",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",
@@ -34,6 +34,10 @@ const EVENT_LOOKUP: any = {
34
34
 
35
35
  const LibmpvViewNative: React.ComponentType<LibmpvViewProps> = requireNativeView('LibmpvView');
36
36
 
37
+ export const DEFAULT_DECODING_MODE: string = "mediacodec-copy"
38
+
39
+ export const DEFAULT_ACCELERATED_CODECS: string = "h264,hevc,mpeg4,mpeg2video,vp8,vp9,av1"
40
+
37
41
  export const LibmpvView = React.forwardRef<LibmpvViewNativeMethods, LibmpvViewProps>((props: any, parentRef: any) => {
38
42
  React.useEffect(() => {
39
43
  return () => {
@@ -80,7 +84,8 @@ export const LibmpvView = React.forwardRef<LibmpvViewNativeMethods, LibmpvViewPr
80
84
  videoOutput={props.videoOutput}
81
85
  playUrl={props.playUrl}
82
86
  isPlaying={props.isPlaying}
83
- useHardwareDecoder={props.useHardwareDecoder}
87
+ decodingMode={props.decodingMode}
88
+ acceleratedCodecs={props.acceleratedCodecs}
84
89
  surfaceWidth={props.surfaceWidth}
85
90
  surfaceHeight={props.surfaceHeight}
86
91
  selectedAudioTrack={props.selectedAudioTrack}
@@ -4,7 +4,8 @@ export type LibmpvViewProps = {
4
4
  videoOutput: string,
5
5
  playUrl: string,
6
6
  isPlaying: boolean,
7
- useHardwareDecoder: boolean,
7
+ decodingMode: string,
8
+ acceleratedCodecs: string,
8
9
  selectedAudioTrack: number,
9
10
  selectedSubtitleTrack: number,
10
11
  seekToSeconds: number,
package/src/index.ts CHANGED
@@ -1,4 +1,12 @@
1
- import { default as LibmpvView } from './LibmpvView';
2
- export { default as LibmpvView } from './LibmpvView';
1
+ import {
2
+ default as LibmpvView
3
+ } from './LibmpvView';
4
+ export {
5
+ default as LibmpvView,
6
+ DEFAULT_ACCELERATED_CODECS,
7
+ DEFAULT_DECODING_MODE
8
+ } from './LibmpvView';
9
+
10
+
3
11
 
4
12
  export default LibmpvView