expo-libmpv 0.3.7 → 0.3.9

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.
@@ -36,7 +36,7 @@ if (useManagedAndroidSdkVersions) {
36
36
  }
37
37
 
38
38
  dependencies {
39
- implementation "com.libmpv:android-libmpv:0.6.4"
39
+ implementation "com.libmpv:android-libmpv:0.7.0"
40
40
  }
41
41
 
42
42
  android {
@@ -23,13 +23,10 @@ class LibmpvWrapper(private val applicationContext: Context) {
23
23
  @Volatile private var isPlaying = false
24
24
  @Volatile private var hasPlayedOnce = false
25
25
 
26
- private var eventObserver: MPVLib.EventObserver? = null
27
- private var logObserver: MPVLib.LogObserver? = null
28
26
  private var mpvDirectory: String? = null
29
27
  private var surfaceWidth: Int = -1
30
28
  private var surfaceHeight: Int = -1
31
29
  private var surfaceView: SurfaceView? = null
32
- private val mpv: MPVLib = MPVLib(true)
33
30
 
34
31
  fun isCreated(): Boolean = created
35
32
  fun isPlaying(): Boolean = isPlaying
@@ -40,7 +37,7 @@ class LibmpvWrapper(private val applicationContext: Context) {
40
37
  if (destroyed){ return }
41
38
  try {
42
39
  val message: String = (exception.message as? String) ?: "Unable to read error message"
43
- logObserver?.logMessage("RNLE", 20, message)
40
+ MPVLib.logMessage("RNLE", 20, message)
44
41
  } catch (e: Exception) {
45
42
  if (!SWALLOW){
46
43
  throw e
@@ -50,7 +47,7 @@ class LibmpvWrapper(private val applicationContext: Context) {
50
47
 
51
48
  fun createManagedInstance(): Boolean {
52
49
  try{
53
- mpv.create(applicationContext)
50
+ MPVLib.create(applicationContext)
54
51
  createMpvDirectory()
55
52
  created = true
56
53
  return true
@@ -62,7 +59,7 @@ class LibmpvWrapper(private val applicationContext: Context) {
62
59
  fun initNativeBinding() {
63
60
  if (destroyed || !created){ return }
64
61
  try {
65
- mpv.init()
62
+ MPVLib.init()
66
63
  } catch (e: Exception) {
67
64
  logException(e)
68
65
  if (!SWALLOW){
@@ -90,8 +87,8 @@ class LibmpvWrapper(private val applicationContext: Context) {
90
87
  }
91
88
 
92
89
  // Copy conf
93
- val mpvConfPath = "${mpvDir}/mpv.conf"
94
- applicationContext.assets.open("mpv.conf").use { mpvConfIn ->
90
+ val mpvConfPath = "${mpvDir}/MPVLib.conf"
91
+ applicationContext.assets.open("MPVLib.conf").use { mpvConfIn ->
95
92
  FileOutputStream(mpvConfPath).use { confOut ->
96
93
  mpvConfIn.copyTo(confOut)
97
94
  }
@@ -104,17 +101,16 @@ class LibmpvWrapper(private val applicationContext: Context) {
104
101
  fun addEventObserver(observer: MPVLib.EventObserver) {
105
102
  if (destroyed || !created){ return }
106
103
  try {
107
- mpv.removeObservers()
108
- eventObserver = observer
109
- mpv.addObserver(eventObserver)
110
- mpv.observeProperty("demuxer-cache-time", MPVLib.MPV_FORMAT_INT64)
111
- mpv.observeProperty("duration", MPVLib.MPV_FORMAT_INT64)
112
- mpv.observeProperty("eof-reached", MPVLib.MPV_FORMAT_FLAG)
113
- mpv.observeProperty("paused-for-cache", MPVLib.MPV_FORMAT_FLAG)
114
- mpv.observeProperty("seekable", MPVLib.MPV_FORMAT_FLAG)
115
- mpv.observeProperty("speed", MPVLib.MPV_FORMAT_DOUBLE)
116
- mpv.observeProperty("time-pos", MPVLib.MPV_FORMAT_INT64)
117
- mpv.observeProperty("track-list", MPVLib.MPV_FORMAT_STRING)
104
+ MPVLib.removeObservers()
105
+ MPVLib.addObserver(observer)
106
+ MPVLib.observeProperty("demuxer-cache-time", MPVLib.MpvFormat.MPV_FORMAT_INT64)
107
+ MPVLib.observeProperty("duration", MPVLib.MpvFormat.MPV_FORMAT_INT64)
108
+ MPVLib.observeProperty("eof-reached", MPVLib.MpvFormat.MPV_FORMAT_FLAG)
109
+ MPVLib.observeProperty("paused-for-cache", MPVLib.MpvFormat.MPV_FORMAT_FLAG)
110
+ MPVLib.observeProperty("seekable", MPVLib.MpvFormat.MPV_FORMAT_FLAG)
111
+ MPVLib.observeProperty("speed", MPVLib.MpvFormat.MPV_FORMAT_DOUBLE)
112
+ MPVLib.observeProperty("time-pos", MPVLib.MpvFormat.MPV_FORMAT_INT64)
113
+ MPVLib.observeProperty("track-list", MPVLib.MpvFormat.MPV_FORMAT_STRING)
118
114
  } catch (e: Exception) {
119
115
  logException(e)
120
116
  if (!SWALLOW){
@@ -126,9 +122,8 @@ class LibmpvWrapper(private val applicationContext: Context) {
126
122
  fun addLogObserver(observer: MPVLib.LogObserver) {
127
123
  if (destroyed || !created){ return }
128
124
  try {
129
- mpv.removeLogObservers()
130
- logObserver = observer
131
- mpv.addLogObserver(logObserver)
125
+ MPVLib.removeLogObservers()
126
+ MPVLib.addLogObserver(observer)
132
127
  } catch (e: Exception) {
133
128
  logException(e)
134
129
  if (!SWALLOW) {
@@ -140,7 +135,7 @@ class LibmpvWrapper(private val applicationContext: Context) {
140
135
  fun setOptionString(option: String, setting: String) {
141
136
  if (destroyed || !created){ return }
142
137
  try {
143
- mpv.setOptionString(option, setting)
138
+ MPVLib.setOptionString(option, setting)
144
139
  } catch (e: Exception) {
145
140
  logException(e)
146
141
  if (!SWALLOW){
@@ -152,7 +147,7 @@ class LibmpvWrapper(private val applicationContext: Context) {
152
147
  fun setPropertyString(property: String, setting: String) {
153
148
  if (destroyed || !created){ return }
154
149
  try {
155
- mpv.setPropertyString(property, setting)
150
+ MPVLib.setPropertyString(property, setting)
156
151
  } catch (e: Exception) {
157
152
  logException(e)
158
153
  if (!SWALLOW){
@@ -164,7 +159,7 @@ class LibmpvWrapper(private val applicationContext: Context) {
164
159
  fun command(orders: Array<String>) {
165
160
  if (destroyed || !created){ return }
166
161
  try {
167
- mpv.command(orders)
162
+ MPVLib.command(orders)
168
163
  } catch (e: Exception) {
169
164
  logException(e)
170
165
  if (!SWALLOW){
@@ -178,7 +173,7 @@ class LibmpvWrapper(private val applicationContext: Context) {
178
173
  try {
179
174
  this.surfaceView = surfaceView
180
175
  applySurfaceDimensions()
181
- mpv.attachSurface(surfaceView.holder.surface)
176
+ MPVLib.attachSurface(surfaceView.holder.surface)
182
177
  } catch (e: Exception) {
183
178
  logException(e)
184
179
  if (!SWALLOW){
@@ -253,7 +248,7 @@ class LibmpvWrapper(private val applicationContext: Context) {
253
248
  fun detachSurface(){
254
249
  if(destroyed) { return }
255
250
  try{
256
- mpv.detachSurface()
251
+ MPVLib.detachSurface()
257
252
  }
258
253
  catch(e:Exception){
259
254
  logException(e)
@@ -279,9 +274,9 @@ class LibmpvWrapper(private val applicationContext: Context) {
279
274
  setPropertyString("ao", "null")
280
275
  detachSurface()
281
276
  Handler(Looper.getMainLooper()).post {
282
- mpv.removeObservers()
283
- mpv.removeLogObservers()
284
- mpv.destroy()
277
+ MPVLib.removeObservers()
278
+ MPVLib.removeLogObservers()
279
+ MPVLib.destroy()
285
280
  created = false
286
281
  cleaning = false
287
282
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expo-libmpv",
3
- "version": "0.3.7",
3
+ "version": "0.3.9",
4
4
  "description": "A libmpv Fabric component for Android",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",