expo-libvlc-player 2.0.2 → 2.0.4

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 = "expo.modules.libvlcplayer"
4
- version = "2.0.2"
4
+ version = "2.0.4"
5
5
 
6
6
  def expoModulesCorePlugin = new File(project(":expo-modules-core").projectDir.absolutePath, "ExpoModulesCorePlugin.gradle")
7
7
  apply from: expoModulesCorePlugin
@@ -27,7 +27,7 @@ android {
27
27
  namespace "expo.modules.libvlcplayer"
28
28
  defaultConfig {
29
29
  versionCode 1
30
- versionName "2.0.2"
30
+ versionName "2.0.4"
31
31
  consumerProguardFiles("proguard-rules.pro")
32
32
  }
33
33
  lintOptions {
@@ -34,14 +34,17 @@ class LibVlcPlayerView(
34
34
  context: Context,
35
35
  appContext: AppContext,
36
36
  ) : ExpoView(context, appContext) {
37
- private val playerView: VLCVideoLayout = VLCVideoLayout(context)
37
+ private val playerView: VLCVideoLayout =
38
+ VLCVideoLayout(context).also {
39
+ addView(it)
40
+ }
38
41
 
39
42
  private var libVLC: LibVLC? = null
40
43
  internal var mediaPlayer: MediaPlayer? = null
41
- internal var media: Media? = null
44
+ private var media: Media? = null
42
45
  private var shouldCreate: Boolean = false
43
46
 
44
- internal var mediaLength: Long = 0L
47
+ private var mediaLength: Long = 0L
45
48
  internal var oldVolume: Int = MAX_PLAYER_VOLUME
46
49
  internal var firstPlay: Boolean = false
47
50
 
@@ -103,11 +106,15 @@ class LibVlcPlayerView(
103
106
 
104
107
  fun attachPlayer() {
105
108
  mediaPlayer?.let { player ->
106
- if (playerView.getParent() == null) {
109
+ val parent = playerView.getParent()
110
+
111
+ if (parent == null) {
107
112
  addView(playerView)
108
113
  }
109
114
 
110
- if (!player.getVLCVout().areViewsAttached()) {
115
+ val attached = player.getVLCVout().areViewsAttached()
116
+
117
+ if (!attached) {
111
118
  player.attachViews(playerView, DISPLAY_MANAGER, ENABLE_SUBTITLES, USE_TEXTURE_VIEW)
112
119
  }
113
120
  }
@@ -119,7 +126,6 @@ class LibVlcPlayerView(
119
126
  }
120
127
 
121
128
  fun destroyPlayer() {
122
- media?.release()
123
129
  media = null
124
130
  mediaPlayer?.release()
125
131
  mediaPlayer = null
@@ -409,7 +415,7 @@ class LibVlcPlayerView(
409
415
  }
410
416
  }
411
417
 
412
- internal fun ArrayList<String>.hasAudioOption(): Boolean {
418
+ private fun ArrayList<String>.hasAudioOption(): Boolean {
413
419
  val options =
414
420
  setOf(
415
421
  "--no-audio",
@@ -80,6 +80,8 @@ class LibVlcPlayerView: ExpoView {
80
80
 
81
81
  func destroyPlayer() {
82
82
  mediaPlayer?.media = nil
83
+ mediaPlayer?.delegate = nil
84
+ mediaPlayer?.drawable = nil
83
85
  mediaPlayer = nil
84
86
  }
85
87
 
@@ -368,7 +370,7 @@ class LibVlcPlayerView: ExpoView {
368
370
  }
369
371
  }
370
372
 
371
- extension Array where Element == String {
373
+ private extension Array where Element == String {
372
374
  func hasAudioOption() -> Bool {
373
375
  let options: Set<String> = [
374
376
  "--no-audio", "-no-audio", ":no-audio",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expo-libvlc-player",
3
- "version": "2.0.2",
3
+ "version": "2.0.4",
4
4
  "description": "LibVLC Player for Expo",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",