expo-libvlc-player 3.1.0 → 3.1.2

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.2"
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.2"
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,19 @@ 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
+ }
56
+
57
+ OnActivityEntersForeground {
58
+ MediaPlayerManager.onModuleForeground()
59
+ }
60
+
61
+ OnActivityEntersBackground {
62
+ MediaPlayerManager.onModuleBackground()
55
63
  }
56
64
 
57
65
  View(LibVlcPlayerView::class) {
@@ -154,13 +162,5 @@ class LibVlcPlayerModule : Module() {
154
162
  view.dismiss()
155
163
  }
156
164
  }
157
-
158
- OnActivityEntersForeground {
159
- MediaPlayerManager.onPlayerForeground()
160
- }
161
-
162
- OnActivityEntersBackground {
163
- MediaPlayerManager.onPlayerBackground()
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)
@@ -38,12 +38,20 @@ public class LibVlcPlayerModule: Module {
38
38
  public func definition() -> ModuleDefinition {
39
39
  Name("ExpoLibVlcPlayer")
40
40
 
41
- AsyncFunction("triggerAlert") { () in
42
- LocalNetworkAlert.shared.triggerLocalNetworkPrivacyAlert()
41
+ AsyncFunction("triggerAlert") {
42
+ LocalNetworkManager.shared.triggerLocalNetworkPrivacyAlert()
43
43
  }
44
44
 
45
45
  OnDestroy {
46
- MediaPlayerManager.shared.onModuleDestroyed()
46
+ MediaPlayerManager.shared.onModuleDestroy()
47
+ }
48
+
49
+ OnAppEntersForeground {
50
+ MediaPlayerManager.shared.onModuleForeground()
51
+ }
52
+
53
+ OnAppEntersBackground {
54
+ MediaPlayerManager.shared.onModuleBackground()
47
55
  }
48
56
 
49
57
  View(LibVlcPlayerView.self) {
@@ -141,13 +149,5 @@ public class LibVlcPlayerModule: Module {
141
149
  view.dismiss()
142
150
  }
143
151
  }
144
-
145
- OnAppEntersForeground {
146
- MediaPlayerManager.shared.onPlayerForeground()
147
- }
148
-
149
- OnAppEntersBackground {
150
- MediaPlayerManager.shared.onPlayerBackground()
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.2",
4
4
  "description": "LibVLC Player for Expo",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",