expo-libvlc-player 3.1.0 → 3.1.1

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 = "3.1.0"
4
+ version = "3.1.1"
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 "3.1.0"
30
+ versionName "3.1.1"
31
31
  consumerProguardFiles("proguard-rules.pro")
32
32
  }
33
33
  lintOptions {
@@ -19,7 +19,7 @@ private const val ES_ADDED_EVENT = "onESAdded"
19
19
  private const val RECORD_CHANGED_EVENT = "onRecordChanged"
20
20
  private const val SNAPSHOT_TAKEN_EVENT = "onSnapshotTaken"
21
21
  private const val FIRST_PLAY_EVENT = "onFirstPlay"
22
- private const val FOREROUND_EVENT = "onForeground"
22
+ private const val FOREGROUND_EVENT = "onForeground"
23
23
  private const val BACKGROUND_EVENT = "onBackground"
24
24
 
25
25
  val playerEvents =
@@ -37,7 +37,7 @@ val playerEvents =
37
37
  RECORD_CHANGED_EVENT,
38
38
  SNAPSHOT_TAKEN_EVENT,
39
39
  FIRST_PLAY_EVENT,
40
- FOREROUND_EVENT,
40
+ FOREGROUND_EVENT,
41
41
  BACKGROUND_EVENT,
42
42
  )
43
43
 
@@ -47,11 +47,11 @@ class LibVlcPlayerModule : Module() {
47
47
  Name("ExpoLibVlcPlayer")
48
48
 
49
49
  OnCreate {
50
- MediaPlayerManager.onModuleCreated(appContext)
50
+ MediaPlayerManager.onModuleCreate(appContext)
51
51
  }
52
52
 
53
53
  OnDestroy {
54
- MediaPlayerManager.onModuleDestroyed()
54
+ MediaPlayerManager.onModuleDestroy()
55
55
  }
56
56
 
57
57
  View(LibVlcPlayerView::class) {
@@ -156,11 +156,11 @@ class LibVlcPlayerModule : Module() {
156
156
  }
157
157
 
158
158
  OnActivityEntersForeground {
159
- MediaPlayerManager.onPlayerForeground()
159
+ MediaPlayerManager.onModuleForeground()
160
160
  }
161
161
 
162
162
  OnActivityEntersBackground {
163
- MediaPlayerManager.onPlayerBackground()
163
+ MediaPlayerManager.onModuleBackground()
164
164
  }
165
165
  }
166
166
  }
@@ -5,11 +5,19 @@ import expo.modules.kotlin.exception.Exceptions
5
5
  import java.lang.ref.WeakReference
6
6
 
7
7
  object MediaPlayerManager {
8
+ lateinit var audioFocusManager: AudioFocusManager
9
+
8
10
  internal var playerViews: MutableList<WeakReference<LibVlcPlayerView>> = mutableListOf()
9
11
 
10
- lateinit var audioFocusManager: AudioFocusManager
12
+ fun registerPlayerView(view: LibVlcPlayerView) {
13
+ playerViews.find { it.get() == view } ?: run { playerViews.add(WeakReference(view)) }
14
+ }
15
+
16
+ fun unregisterPlayerView(view: LibVlcPlayerView) {
17
+ playerViews.removeAll { it.get() == view }
18
+ }
11
19
 
12
- fun onModuleCreated(appContext: AppContext) {
20
+ fun onModuleCreate(appContext: AppContext) {
13
21
  val context = appContext.reactContext ?: throw Exceptions.ReactContextLost()
14
22
 
15
23
  if (!this::audioFocusManager.isInitialized) {
@@ -17,21 +25,13 @@ object MediaPlayerManager {
17
25
  }
18
26
  }
19
27
 
20
- fun onModuleDestroyed() {
28
+ fun onModuleDestroy() {
21
29
  playerViews.forEach { playerView ->
22
30
  playerView.get()?.destroyPlayer()
23
31
  }
24
32
  }
25
33
 
26
- fun registerPlayerView(view: LibVlcPlayerView) {
27
- playerViews.find { it.get() == view } ?: run { playerViews.add(WeakReference(view)) }
28
- }
29
-
30
- fun unregisterPlayerView(view: LibVlcPlayerView) {
31
- playerViews.removeAll { it.get() == view }
32
- }
33
-
34
- fun onPlayerForeground() {
34
+ fun onModuleForeground() {
35
35
  playerViews.forEach { playerView ->
36
36
  playerView.get()?.let { view ->
37
37
  view.onForeground(Unit)
@@ -39,7 +39,7 @@ object MediaPlayerManager {
39
39
  }
40
40
  }
41
41
 
42
- fun onPlayerBackground() {
42
+ fun onModuleBackground() {
43
43
  playerViews.forEach { playerView ->
44
44
  playerView.get()?.let { view ->
45
45
  view.onBackground(Unit)
@@ -39,11 +39,11 @@ public class LibVlcPlayerModule: Module {
39
39
  Name("ExpoLibVlcPlayer")
40
40
 
41
41
  AsyncFunction("triggerAlert") { () in
42
- LocalNetworkAlert.shared.triggerLocalNetworkPrivacyAlert()
42
+ LocalNetworkManager.shared.triggerLocalNetworkPrivacyAlert()
43
43
  }
44
44
 
45
45
  OnDestroy {
46
- MediaPlayerManager.shared.onModuleDestroyed()
46
+ MediaPlayerManager.shared.onModuleDestroy()
47
47
  }
48
48
 
49
49
  View(LibVlcPlayerView.self) {
@@ -143,11 +143,11 @@ public class LibVlcPlayerModule: Module {
143
143
  }
144
144
 
145
145
  OnAppEntersForeground {
146
- MediaPlayerManager.shared.onPlayerForeground()
146
+ MediaPlayerManager.shared.onModuleForeground()
147
147
  }
148
148
 
149
149
  OnAppEntersBackground {
150
- MediaPlayerManager.shared.onPlayerBackground()
150
+ MediaPlayerManager.shared.onModuleBackground()
151
151
  }
152
152
  }
153
153
  }
@@ -1,5 +1,5 @@
1
- class LocalNetworkAlert {
2
- static let shared = LocalNetworkAlert()
1
+ class LocalNetworkManager {
2
+ static let shared = LocalNetworkManager()
3
3
 
4
4
  /// Attempts to trigger the local network privacy alert.
5
5
  ///
@@ -5,12 +5,6 @@ class MediaPlayerManager {
5
5
 
6
6
  let playerViews = NSHashTable<LibVlcPlayerView>.weakObjects()
7
7
 
8
- func onModuleDestroyed() {
9
- for view in playerViews.allObjects {
10
- view.destroyPlayer()
11
- }
12
- }
13
-
14
8
  func registerPlayerView(_ view: LibVlcPlayerView) {
15
9
  playerViews.add(view)
16
10
  }
@@ -19,13 +13,19 @@ class MediaPlayerManager {
19
13
  playerViews.remove(view)
20
14
  }
21
15
 
22
- func onPlayerForeground() {
16
+ func onModuleDestroy() {
17
+ for view in playerViews.allObjects {
18
+ view.destroyPlayer()
19
+ }
20
+ }
21
+
22
+ func onModuleForeground() {
23
23
  for view in playerViews.allObjects {
24
24
  view.onForeground()
25
25
  }
26
26
  }
27
27
 
28
- func onPlayerBackground() {
28
+ func onModuleBackground() {
29
29
  for view in playerViews.allObjects {
30
30
  view.onBackground()
31
31
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expo-libvlc-player",
3
- "version": "3.1.0",
3
+ "version": "3.1.1",
4
4
  "description": "LibVLC Player for Expo",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",