react-native-tpstreams 0.2.18 → 0.2.19

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.
@@ -3,4 +3,4 @@ Tpstreams_minSdkVersion=24
3
3
  Tpstreams_targetSdkVersion=34
4
4
  Tpstreams_compileSdkVersion=35
5
5
  Tpstreams_ndkVersion=27.1.12297006
6
- Tpstreams_tpstreamsAndroidPlayerVersion=1.0.15
6
+ Tpstreams_tpstreamsAndroidPlayerVersion=1.0.16
@@ -11,6 +11,7 @@ import com.tpstreams.player.TPStreamsPlayerView
11
11
  import androidx.media3.common.Player
12
12
  import androidx.media3.common.PlaybackParameters
13
13
  import androidx.media3.common.PlaybackException
14
+ import android.media.MediaCodec
14
15
 
15
16
  class TPStreamsRNPlayerView(context: ThemedReactContext) : FrameLayout(context) {
16
17
  private val playerView: TPStreamsPlayerView = TPStreamsPlayerView(context)
@@ -19,6 +20,8 @@ class TPStreamsRNPlayerView(context: ThemedReactContext) : FrameLayout(context)
19
20
 
20
21
  companion object {
21
22
  private const val DEFAULT_OFFLINE_LICENSE_EXPIRE_TIME = 15L * 24L * 60L * 60L // 15 days in seconds
23
+ private const val ERROR_CODE_PLAYER_CREATION_FAILED = 1001
24
+ private const val ERROR_CODE_DRM_LICENSE_EXPIRED = 5001
22
25
  }
23
26
 
24
27
  private var videoId: String? = null
@@ -141,7 +144,7 @@ class TPStreamsRNPlayerView(context: ThemedReactContext) : FrameLayout(context)
141
144
  emitEvent("onIsLoadingChanged", mapOf("isLoading" to false))
142
145
  } catch (e: Exception) {
143
146
  Log.e("TPStreamsRN", "Error creating player", e)
144
- sendErrorEvent("Error creating player", 1001, e.message)
147
+ sendErrorEvent("Error creating player", ERROR_CODE_PLAYER_CREATION_FAILED, e.message)
145
148
  }
146
149
  }
147
150
 
@@ -165,11 +168,23 @@ class TPStreamsRNPlayerView(context: ThemedReactContext) : FrameLayout(context)
165
168
 
166
169
  override fun onPlayerError(error: PlaybackException) {
167
170
  Log.e("TPStreamsRN", "Player error", error)
171
+ if (isDrmLicenseExpiredError(error)) {
172
+ sendErrorEvent("Playback error", ERROR_CODE_DRM_LICENSE_EXPIRED, "Offline DRM license expired")
173
+ return
174
+ }
168
175
  sendErrorEvent("Playback error", error.errorCode, error.message)
169
176
  }
170
177
  }
171
178
  }
172
179
 
180
+ private fun isDrmLicenseExpiredError(error: PlaybackException): Boolean {
181
+ val cause = error.cause
182
+ return error.errorCode == PlaybackException.ERROR_CODE_DRM_LICENSE_EXPIRED ||
183
+ error.errorCode == PlaybackException.ERROR_CODE_DRM_DISALLOWED_OPERATION ||
184
+ error.errorCode == PlaybackException.ERROR_CODE_DRM_SYSTEM_ERROR ||
185
+ cause is MediaCodec.CryptoException
186
+ }
187
+
173
188
  // Player control methods
174
189
  fun play() {
175
190
  player?.play()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-tpstreams",
3
- "version": "0.2.18",
3
+ "version": "0.2.19",
4
4
  "description": "Video component for TPStreams",
5
5
  "main": "./lib/module/index.js",
6
6
  "types": "./lib/typescript/src/index.d.ts",