react-native-tpstreams 0.2.17 → 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.
@@ -41,12 +41,6 @@ public class TPStreamsRNPlayerViewManagerDelegate<T extends View, U extends Base
41
41
  case "showDefaultCaptions":
42
42
  mViewManager.setShowDefaultCaptions(view, value == null ? false : (boolean) value);
43
43
  break;
44
- case "downloadMetadata":
45
- mViewManager.setDownloadMetadata(view, value == null ? null : (String) value);
46
- break;
47
- case "offlineLicenseExpireTime":
48
- mViewManager.setOfflineLicenseExpireTime(view, value == null ? 0f : ((Double) value).doubleValue());
49
- break;
50
44
  default:
51
45
  super.setProperty(view, propName, value);
52
46
  }
@@ -79,9 +73,6 @@ public class TPStreamsRNPlayerViewManagerDelegate<T extends View, U extends Base
79
73
  case "getPlaybackSpeed":
80
74
  mViewManager.getPlaybackSpeed(view);
81
75
  break;
82
- case "setNewAccessToken":
83
- mViewManager.setNewAccessToken(view, args.getString(0));
84
- break;
85
76
  }
86
77
  }
87
78
  }
@@ -20,8 +20,6 @@ public interface TPStreamsRNPlayerViewManagerInterface<T extends View> extends V
20
20
  void setStartAt(T view, double value);
21
21
  void setEnableDownload(T view, boolean value);
22
22
  void setShowDefaultCaptions(T view, boolean value);
23
- void setDownloadMetadata(T view, @Nullable String value);
24
- void setOfflineLicenseExpireTime(T view, double value);
25
23
  void play(T view);
26
24
  void pause(T view);
27
25
  void seekTo(T view, double positionMs);
@@ -30,5 +28,4 @@ public interface TPStreamsRNPlayerViewManagerInterface<T extends View> extends V
30
28
  void getDuration(T view);
31
29
  void isPlaying(T view);
32
30
  void getPlaybackSpeed(T view);
33
- void setNewAccessToken(T view, String newToken);
34
31
  }
@@ -95,13 +95,4 @@ $payload.setProperty(runtime, "details", $event.details);
95
95
  });
96
96
  }
97
97
 
98
-
99
- void TPStreamsRNPlayerViewEventEmitter::onAccessTokenExpired(OnAccessTokenExpired $event) const {
100
- dispatchEvent("accessTokenExpired", [$event=std::move($event)](jsi::Runtime &runtime) {
101
- auto $payload = jsi::Object(runtime);
102
- $payload.setProperty(runtime, "videoId", $event.videoId);
103
- return $payload;
104
- });
105
- }
106
-
107
98
  } // namespace facebook::react
@@ -54,10 +54,6 @@ class TPStreamsRNPlayerViewEventEmitter : public ViewEventEmitter {
54
54
  int code;
55
55
  std::string details;
56
56
  };
57
-
58
- struct OnAccessTokenExpired {
59
- std::string videoId;
60
- };
61
57
  void onCurrentPosition(OnCurrentPosition value) const;
62
58
 
63
59
  void onDuration(OnDuration value) const;
@@ -75,7 +71,5 @@ class TPStreamsRNPlayerViewEventEmitter : public ViewEventEmitter {
75
71
  void onIsLoadingChanged(OnIsLoadingChanged value) const;
76
72
 
77
73
  void onError(OnError value) const;
78
-
79
- void onAccessTokenExpired(OnAccessTokenExpired value) const;
80
74
  };
81
75
  } // namespace facebook::react
@@ -24,9 +24,7 @@ TPStreamsRNPlayerViewProps::TPStreamsRNPlayerViewProps(
24
24
  shouldAutoPlay(convertRawProp(context, rawProps, "shouldAutoPlay", sourceProps.shouldAutoPlay, {false})),
25
25
  startAt(convertRawProp(context, rawProps, "startAt", sourceProps.startAt, {0.0})),
26
26
  enableDownload(convertRawProp(context, rawProps, "enableDownload", sourceProps.enableDownload, {false})),
27
- showDefaultCaptions(convertRawProp(context, rawProps, "showDefaultCaptions", sourceProps.showDefaultCaptions, {false})),
28
- downloadMetadata(convertRawProp(context, rawProps, "downloadMetadata", sourceProps.downloadMetadata, {})),
29
- offlineLicenseExpireTime(convertRawProp(context, rawProps, "offlineLicenseExpireTime", sourceProps.offlineLicenseExpireTime, {0.0}))
27
+ showDefaultCaptions(convertRawProp(context, rawProps, "showDefaultCaptions", sourceProps.showDefaultCaptions, {false}))
30
28
  {}
31
29
 
32
30
  } // namespace facebook::react
@@ -27,8 +27,6 @@ class TPStreamsRNPlayerViewProps final : public ViewProps {
27
27
  double startAt{0.0};
28
28
  bool enableDownload{false};
29
29
  bool showDefaultCaptions{false};
30
- std::string downloadMetadata{};
31
- double offlineLicenseExpireTime{0.0};
32
30
  };
33
31
 
34
32
  } // namespace facebook::react
@@ -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.14
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.17",
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",