react-native-tpstreams 0.1.15 → 0.2.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.
- package/LICENSE +1 -1
- package/README.md +20 -418
- package/Tpstreams.podspec +3 -25
- package/android/build.gradle +14 -42
- package/android/src/main/AndroidManifest.xml +1 -3
- package/android/src/main/java/com/tpstreams/TPStreamsRNModule.kt +18 -0
- package/android/src/main/java/com/tpstreams/{TpstreamsPackage.kt → TPStreamsRNPackage.kt} +10 -5
- package/android/src/main/java/com/tpstreams/TPStreamsRNPlayerView.kt +162 -0
- package/android/src/main/java/com/tpstreams/TPStreamsRNPlayerViewManager.kt +97 -0
- package/ios/TpstreamsView.h +14 -0
- package/ios/TpstreamsView.mm +71 -0
- package/ios/TpstreamsViewManager.mm +19 -0
- package/lib/module/TPStreamsPlayer.js +159 -0
- package/lib/module/TPStreamsPlayer.js.map +1 -0
- package/lib/module/TPStreamsPlayerViewNativeComponent.ts +70 -0
- package/lib/module/index.js +10 -3
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/src/TPStreamsPlayer.d.ts +32 -0
- package/lib/typescript/src/TPStreamsPlayer.d.ts.map +1 -0
- package/lib/typescript/src/TPStreamsPlayerViewNativeComponent.d.ts +54 -0
- package/lib/typescript/src/TPStreamsPlayerViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +8 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/package.json +42 -76
- package/src/TPStreamsPlayer.tsx +225 -0
- package/src/TPStreamsPlayerViewNativeComponent.ts +70 -0
- package/src/index.tsx +12 -7
- package/android/generated/java/com/tpstreams/NativeTpstreamsSpec.java +0 -37
- package/android/generated/jni/CMakeLists.txt +0 -36
- package/android/generated/jni/RNTpstreamsSpec-generated.cpp +0 -32
- package/android/generated/jni/RNTpstreamsSpec.h +0 -31
- package/android/generated/jni/react/renderer/components/RNTpstreamsSpec/RNTpstreamsSpecJSI-generated.cpp +0 -28
- package/android/generated/jni/react/renderer/components/RNTpstreamsSpec/RNTpstreamsSpecJSI.h +0 -71
- package/android/libs/extracted-aar/META-INF/com/android/build/gradle/aar-metadata.properties +0 -4
- package/android/src/main/AndroidManifestNew.xml +0 -2
- package/android/src/main/java/com/tpstreams/FragmentModule.kt +0 -225
- package/android/src/main/java/com/tpstreams/PlayerFragment.kt +0 -234
- package/android/src/main/java/com/tpstreams/TpStreamsPlayerView.kt +0 -102
- package/android/src/main/java/com/tpstreams/TpStreamsPlayerViewManager.kt +0 -55
- package/android/src/main/java/com/tpstreams/TpstreamsModule.kt +0 -168
- package/android/src/main/res/layout/fragment_player.xml +0 -29
- package/android/src/main/res/xml/network_security_config.xml +0 -8
- package/ios/Tpstreams.h +0 -6
- package/ios/Tpstreams.mm +0 -18
- package/ios/generated/RNTpstreamsSpec/RNTpstreamsSpec-generated.mm +0 -39
- package/ios/generated/RNTpstreamsSpec/RNTpstreamsSpec.h +0 -63
- package/ios/generated/RNTpstreamsSpecJSI-generated.cpp +0 -28
- package/ios/generated/RNTpstreamsSpecJSI.h +0 -71
- package/lib/commonjs/NativeTpstreams.js +0 -9
- package/lib/commonjs/NativeTpstreams.js.map +0 -1
- package/lib/commonjs/index.js +0 -10
- package/lib/commonjs/index.js.map +0 -1
- package/lib/commonjs/types.js +0 -2
- package/lib/commonjs/types.js.map +0 -1
- package/lib/module/NativeTpstreams.js +0 -5
- package/lib/module/NativeTpstreams.js.map +0 -1
- package/lib/module/types.js +0 -2
- package/lib/module/types.js.map +0 -1
- package/lib/typescript/commonjs/package.json +0 -1
- package/lib/typescript/commonjs/src/NativeTpstreams.d.ts +0 -7
- package/lib/typescript/commonjs/src/NativeTpstreams.d.ts.map +0 -1
- package/lib/typescript/commonjs/src/index.d.ts +0 -5
- package/lib/typescript/commonjs/src/index.d.ts.map +0 -1
- package/lib/typescript/commonjs/src/types.d.ts +0 -11
- package/lib/typescript/commonjs/src/types.d.ts.map +0 -1
- package/lib/typescript/module/src/NativeTpstreams.d.ts +0 -7
- package/lib/typescript/module/src/NativeTpstreams.d.ts.map +0 -1
- package/lib/typescript/module/src/index.d.ts +0 -5
- package/lib/typescript/module/src/index.d.ts.map +0 -1
- package/lib/typescript/module/src/types.d.ts +0 -11
- package/lib/typescript/module/src/types.d.ts.map +0 -1
- package/react-native.config.js +0 -12
- package/src/NativeTpstreams.ts +0 -8
- package/src/types.ts +0 -10
- /package/lib/{typescript/module → module}/package.json +0 -0
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
package com.tpstreams
|
|
2
|
+
|
|
3
|
+
import android.util.Log
|
|
4
|
+
import android.widget.FrameLayout
|
|
5
|
+
import com.facebook.react.bridge.Arguments
|
|
6
|
+
import com.facebook.react.bridge.ReactContext
|
|
7
|
+
import com.facebook.react.uimanager.ThemedReactContext
|
|
8
|
+
import com.facebook.react.uimanager.events.RCTEventEmitter
|
|
9
|
+
import com.tpstreams.player.TPStreamsPlayer
|
|
10
|
+
import com.tpstreams.player.TPStreamsPlayerView
|
|
11
|
+
import androidx.media3.common.Player
|
|
12
|
+
import androidx.media3.common.PlaybackParameters
|
|
13
|
+
import androidx.media3.common.PlaybackException
|
|
14
|
+
|
|
15
|
+
class TPStreamsRNPlayerView(context: ThemedReactContext) : FrameLayout(context) {
|
|
16
|
+
private val playerView: TPStreamsPlayerView = TPStreamsPlayerView(context)
|
|
17
|
+
private var player: TPStreamsPlayer? = null
|
|
18
|
+
private val reactContext: ReactContext = context
|
|
19
|
+
|
|
20
|
+
private var videoId: String? = null
|
|
21
|
+
private var accessToken: String? = null
|
|
22
|
+
|
|
23
|
+
init {
|
|
24
|
+
addView(playerView, LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT))
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// Emit React Native events
|
|
28
|
+
private fun emitEvent(eventName: String, data: Map<String, Any>) {
|
|
29
|
+
val event = Arguments.createMap()
|
|
30
|
+
data.forEach { (key, value) ->
|
|
31
|
+
when (value) {
|
|
32
|
+
is Int -> event.putInt(key, value)
|
|
33
|
+
is Double -> event.putDouble(key, value)
|
|
34
|
+
is Boolean -> event.putBoolean(key, value)
|
|
35
|
+
is String -> event.putString(key, value)
|
|
36
|
+
else -> Log.w("TPStreamsRN", "Unsupported type for event data: ${value::class.java}")
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
reactContext.getJSModule(RCTEventEmitter::class.java)
|
|
40
|
+
.receiveEvent(id, eventName, event)
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
private fun sendErrorEvent(message: String, code: Int = 0, details: String? = null) {
|
|
44
|
+
val event = Arguments.createMap()
|
|
45
|
+
event.putString("message", message)
|
|
46
|
+
event.putInt("code", code)
|
|
47
|
+
details?.let { event.putString("details", it) }
|
|
48
|
+
reactContext.getJSModule(RCTEventEmitter::class.java)
|
|
49
|
+
.receiveEvent(id, "onError", event)
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
fun setVideoId(videoId: String?) {
|
|
53
|
+
this.videoId = videoId
|
|
54
|
+
tryCreatePlayer()
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
fun setAccessToken(accessToken: String?) {
|
|
58
|
+
this.accessToken = accessToken
|
|
59
|
+
tryCreatePlayer()
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
private fun tryCreatePlayer() {
|
|
63
|
+
if (videoId.isNullOrEmpty() || accessToken.isNullOrEmpty()) return
|
|
64
|
+
if (player != null) return
|
|
65
|
+
|
|
66
|
+
try {
|
|
67
|
+
player = TPStreamsPlayer.create(context, videoId!!, accessToken!!)
|
|
68
|
+
|
|
69
|
+
// Add player event listeners
|
|
70
|
+
player?.addListener(createPlayerListener())
|
|
71
|
+
|
|
72
|
+
playerView.player = player
|
|
73
|
+
playerView.showController()
|
|
74
|
+
|
|
75
|
+
// Send initial events
|
|
76
|
+
emitEvent("onPlayerStateChanged", mapOf("playbackState" to 0))
|
|
77
|
+
emitEvent("onIsPlayingChanged", mapOf("isPlaying" to false))
|
|
78
|
+
emitEvent("onPlaybackSpeedChanged", mapOf("speed" to 1.0))
|
|
79
|
+
emitEvent("onIsLoadingChanged", mapOf("isLoading" to false))
|
|
80
|
+
} catch (e: Exception) {
|
|
81
|
+
Log.e("TPStreamsRN", "Error creating player", e)
|
|
82
|
+
sendErrorEvent("Error creating player", 1001, e.message)
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
private fun createPlayerListener(): Player.Listener {
|
|
87
|
+
return object : Player.Listener {
|
|
88
|
+
override fun onPlaybackStateChanged(playbackState: Int) {
|
|
89
|
+
emitEvent("onPlayerStateChanged", mapOf("playbackState" to playbackState))
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
override fun onIsPlayingChanged(isPlaying: Boolean) {
|
|
93
|
+
emitEvent("onIsPlayingChanged", mapOf("isPlaying" to isPlaying))
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
override fun onPlaybackParametersChanged(playbackParameters: PlaybackParameters) {
|
|
97
|
+
emitEvent("onPlaybackSpeedChanged", mapOf("speed" to playbackParameters.speed.toDouble()))
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
override fun onIsLoadingChanged(isLoading: Boolean) {
|
|
101
|
+
emitEvent("onIsLoadingChanged", mapOf("isLoading" to isLoading))
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
override fun onPlayerError(error: PlaybackException) {
|
|
105
|
+
Log.e("TPStreamsRN", "Player error", error)
|
|
106
|
+
sendErrorEvent("Playback error", error.errorCode, error.message)
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// Player control methods
|
|
112
|
+
fun play() {
|
|
113
|
+
player?.play()
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
fun pause() {
|
|
117
|
+
player?.pause()
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
fun seekTo(positionMs: Long) {
|
|
121
|
+
player?.seekTo(positionMs)
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
fun setPlaybackSpeed(speed: Float) {
|
|
125
|
+
player?.setPlaybackSpeed(speed)
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
// Player information methods with event emission
|
|
129
|
+
fun getCurrentPosition(): Long {
|
|
130
|
+
val position = player?.currentPosition ?: 0L
|
|
131
|
+
emitEvent("onCurrentPosition", mapOf("position" to position.toDouble()))
|
|
132
|
+
return position
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
fun getDuration(): Long {
|
|
136
|
+
val duration = player?.duration ?: 0L
|
|
137
|
+
emitEvent("onDuration", mapOf("duration" to duration.toDouble()))
|
|
138
|
+
return duration
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
fun isPlaying(): Boolean {
|
|
142
|
+
val playing = player?.isPlaying ?: false
|
|
143
|
+
emitEvent("onIsPlaying", mapOf("isPlaying" to playing))
|
|
144
|
+
return playing
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
fun getPlaybackSpeed(): Float {
|
|
148
|
+
val speed = player?.playbackParameters?.speed ?: 1.0f
|
|
149
|
+
emitEvent("onPlaybackSpeed", mapOf("speed" to speed.toDouble()))
|
|
150
|
+
return speed
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
override fun onDetachedFromWindow() {
|
|
154
|
+
super.onDetachedFromWindow()
|
|
155
|
+
try {
|
|
156
|
+
player?.release()
|
|
157
|
+
} catch (e: Exception) {
|
|
158
|
+
Log.e("TPStreamsRN", "Error releasing player", e)
|
|
159
|
+
}
|
|
160
|
+
player = null
|
|
161
|
+
}
|
|
162
|
+
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
package com.tpstreams
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.module.annotations.ReactModule
|
|
4
|
+
import com.facebook.react.uimanager.SimpleViewManager
|
|
5
|
+
import com.facebook.react.uimanager.ThemedReactContext
|
|
6
|
+
import com.facebook.react.uimanager.ViewManagerDelegate
|
|
7
|
+
import com.facebook.react.uimanager.annotations.ReactProp
|
|
8
|
+
import com.facebook.react.viewmanagers.TPStreamsRNPlayerViewManagerInterface
|
|
9
|
+
import com.facebook.react.viewmanagers.TPStreamsRNPlayerViewManagerDelegate
|
|
10
|
+
import com.facebook.react.common.MapBuilder
|
|
11
|
+
|
|
12
|
+
@ReactModule(name = TPStreamsRNPlayerViewManager.NAME)
|
|
13
|
+
class TPStreamsRNPlayerViewManager : SimpleViewManager<TPStreamsRNPlayerView>(),
|
|
14
|
+
TPStreamsRNPlayerViewManagerInterface<TPStreamsRNPlayerView> {
|
|
15
|
+
|
|
16
|
+
companion object {
|
|
17
|
+
const val NAME = "TPStreamsRNPlayerView"
|
|
18
|
+
|
|
19
|
+
// Event names
|
|
20
|
+
private const val EVENT_CURRENT_POSITION = "onCurrentPosition"
|
|
21
|
+
private const val EVENT_DURATION = "onDuration"
|
|
22
|
+
private const val EVENT_IS_PLAYING = "onIsPlaying"
|
|
23
|
+
private const val EVENT_PLAYBACK_SPEED = "onPlaybackSpeed"
|
|
24
|
+
private const val EVENT_PLAYER_STATE_CHANGED = "onPlayerStateChanged"
|
|
25
|
+
private const val EVENT_IS_PLAYING_CHANGED = "onIsPlayingChanged"
|
|
26
|
+
private const val EVENT_PLAYBACK_SPEED_CHANGED = "onPlaybackSpeedChanged"
|
|
27
|
+
private const val EVENT_IS_LOADING_CHANGED = "onIsLoadingChanged"
|
|
28
|
+
private const val EVENT_ERROR = "onError"
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
private val mDelegate: ViewManagerDelegate<TPStreamsRNPlayerView> =
|
|
32
|
+
TPStreamsRNPlayerViewManagerDelegate(this)
|
|
33
|
+
|
|
34
|
+
override fun getDelegate(): ViewManagerDelegate<TPStreamsRNPlayerView>? = mDelegate
|
|
35
|
+
|
|
36
|
+
override fun getName(): String = NAME
|
|
37
|
+
|
|
38
|
+
override fun getExportedCustomDirectEventTypeConstants(): Map<String, Any> {
|
|
39
|
+
return MapBuilder.builder<String, Any>()
|
|
40
|
+
.put(EVENT_CURRENT_POSITION, MapBuilder.of("registrationName", EVENT_CURRENT_POSITION))
|
|
41
|
+
.put(EVENT_DURATION, MapBuilder.of("registrationName", EVENT_DURATION))
|
|
42
|
+
.put(EVENT_IS_PLAYING, MapBuilder.of("registrationName", EVENT_IS_PLAYING))
|
|
43
|
+
.put(EVENT_PLAYBACK_SPEED, MapBuilder.of("registrationName", EVENT_PLAYBACK_SPEED))
|
|
44
|
+
.put(EVENT_PLAYER_STATE_CHANGED, MapBuilder.of("registrationName", EVENT_PLAYER_STATE_CHANGED))
|
|
45
|
+
.put(EVENT_IS_PLAYING_CHANGED, MapBuilder.of("registrationName", EVENT_IS_PLAYING_CHANGED))
|
|
46
|
+
.put(EVENT_PLAYBACK_SPEED_CHANGED, MapBuilder.of("registrationName", EVENT_PLAYBACK_SPEED_CHANGED))
|
|
47
|
+
.put(EVENT_IS_LOADING_CHANGED, MapBuilder.of("registrationName", EVENT_IS_LOADING_CHANGED))
|
|
48
|
+
.put(EVENT_ERROR, MapBuilder.of("registrationName", EVENT_ERROR))
|
|
49
|
+
.build()
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
public override fun createViewInstance(context: ThemedReactContext): TPStreamsRNPlayerView =
|
|
53
|
+
TPStreamsRNPlayerView(context)
|
|
54
|
+
|
|
55
|
+
@ReactProp(name = "videoId")
|
|
56
|
+
override fun setVideoId(view: TPStreamsRNPlayerView, videoId: String?) {
|
|
57
|
+
view.setVideoId(videoId)
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
@ReactProp(name = "accessToken")
|
|
61
|
+
override fun setAccessToken(view: TPStreamsRNPlayerView, accessToken: String?) {
|
|
62
|
+
view.setAccessToken(accessToken)
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// Command implementations
|
|
66
|
+
override fun play(view: TPStreamsRNPlayerView) {
|
|
67
|
+
view.play()
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
override fun pause(view: TPStreamsRNPlayerView) {
|
|
71
|
+
view.pause()
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
override fun seekTo(view: TPStreamsRNPlayerView, positionMs: Double) {
|
|
75
|
+
view.seekTo(positionMs.toLong())
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
override fun setPlaybackSpeed(view: TPStreamsRNPlayerView, speed: Float) {
|
|
79
|
+
view.setPlaybackSpeed(speed)
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
override fun getCurrentPosition(view: TPStreamsRNPlayerView) {
|
|
83
|
+
view.getCurrentPosition()
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
override fun getDuration(view: TPStreamsRNPlayerView) {
|
|
87
|
+
view.getDuration()
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
override fun isPlaying(view: TPStreamsRNPlayerView) {
|
|
91
|
+
view.isPlaying()
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
override fun getPlaybackSpeed(view: TPStreamsRNPlayerView) {
|
|
95
|
+
view.getPlaybackSpeed()
|
|
96
|
+
}
|
|
97
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#import <React/RCTViewComponentView.h>
|
|
2
|
+
#import <UIKit/UIKit.h>
|
|
3
|
+
|
|
4
|
+
#ifndef TpstreamsViewNativeComponent_h
|
|
5
|
+
#define TpstreamsViewNativeComponent_h
|
|
6
|
+
|
|
7
|
+
NS_ASSUME_NONNULL_BEGIN
|
|
8
|
+
|
|
9
|
+
@interface TpstreamsView : RCTViewComponentView
|
|
10
|
+
@end
|
|
11
|
+
|
|
12
|
+
NS_ASSUME_NONNULL_END
|
|
13
|
+
|
|
14
|
+
#endif /* TpstreamsViewNativeComponent_h */
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
#import "TpstreamsView.h"
|
|
2
|
+
|
|
3
|
+
#import <react/renderer/components/TpstreamsViewSpec/ComponentDescriptors.h>
|
|
4
|
+
#import <react/renderer/components/TpstreamsViewSpec/EventEmitters.h>
|
|
5
|
+
#import <react/renderer/components/TpstreamsViewSpec/Props.h>
|
|
6
|
+
#import <react/renderer/components/TpstreamsViewSpec/RCTComponentViewHelpers.h>
|
|
7
|
+
|
|
8
|
+
#import "RCTFabricComponentsPlugins.h"
|
|
9
|
+
|
|
10
|
+
using namespace facebook::react;
|
|
11
|
+
|
|
12
|
+
@interface TpstreamsView () <RCTTpstreamsViewViewProtocol>
|
|
13
|
+
|
|
14
|
+
@end
|
|
15
|
+
|
|
16
|
+
@implementation TpstreamsView {
|
|
17
|
+
UIView * _view;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
+ (ComponentDescriptorProvider)componentDescriptorProvider
|
|
21
|
+
{
|
|
22
|
+
return concreteComponentDescriptorProvider<TpstreamsViewComponentDescriptor>();
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
- (instancetype)initWithFrame:(CGRect)frame
|
|
26
|
+
{
|
|
27
|
+
if (self = [super initWithFrame:frame]) {
|
|
28
|
+
static const auto defaultProps = std::make_shared<const TpstreamsViewProps>();
|
|
29
|
+
_props = defaultProps;
|
|
30
|
+
|
|
31
|
+
_view = [[UIView alloc] init];
|
|
32
|
+
|
|
33
|
+
self.contentView = _view;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return self;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
- (void)updateProps:(Props::Shared const &)props oldProps:(Props::Shared const &)oldProps
|
|
40
|
+
{
|
|
41
|
+
const auto &oldViewProps = *std::static_pointer_cast<TpstreamsViewProps const>(_props);
|
|
42
|
+
const auto &newViewProps = *std::static_pointer_cast<TpstreamsViewProps const>(props);
|
|
43
|
+
|
|
44
|
+
if (oldViewProps.color != newViewProps.color) {
|
|
45
|
+
NSString * colorToConvert = [[NSString alloc] initWithUTF8String: newViewProps.color.c_str()];
|
|
46
|
+
[_view setBackgroundColor:[self hexStringToColor:colorToConvert]];
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
[super updateProps:props oldProps:oldProps];
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
Class<RCTComponentViewProtocol> TpstreamsViewCls(void)
|
|
53
|
+
{
|
|
54
|
+
return TpstreamsView.class;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
- hexStringToColor:(NSString *)stringToConvert
|
|
58
|
+
{
|
|
59
|
+
NSString *noHashString = [stringToConvert stringByReplacingOccurrencesOfString:@"#" withString:@""];
|
|
60
|
+
NSScanner *stringScanner = [NSScanner scannerWithString:noHashString];
|
|
61
|
+
|
|
62
|
+
unsigned hex;
|
|
63
|
+
if (![stringScanner scanHexInt:&hex]) return nil;
|
|
64
|
+
int r = (hex >> 16) & 0xFF;
|
|
65
|
+
int g = (hex >> 8) & 0xFF;
|
|
66
|
+
int b = (hex) & 0xFF;
|
|
67
|
+
|
|
68
|
+
return [UIColor colorWithRed:r / 255.0f green:g / 255.0f blue:b / 255.0f alpha:1.0f];
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
@end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
#import <React/RCTViewManager.h>
|
|
2
|
+
#import <React/RCTUIManager.h>
|
|
3
|
+
#import "RCTBridge.h"
|
|
4
|
+
|
|
5
|
+
@interface TpstreamsViewManager : RCTViewManager
|
|
6
|
+
@end
|
|
7
|
+
|
|
8
|
+
@implementation TpstreamsViewManager
|
|
9
|
+
|
|
10
|
+
RCT_EXPORT_MODULE(TpstreamsView)
|
|
11
|
+
|
|
12
|
+
- (UIView *)view
|
|
13
|
+
{
|
|
14
|
+
return [[UIView alloc] init];
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
RCT_EXPORT_VIEW_PROPERTY(color, NSString)
|
|
18
|
+
|
|
19
|
+
@end
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { forwardRef, useImperativeHandle, useRef, useCallback } from 'react';
|
|
4
|
+
import TPStreamsPlayerView, { Commands } from './TPStreamsPlayerViewNativeComponent';
|
|
5
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
6
|
+
// Create a unique ID for each instance to track promises
|
|
7
|
+
let nextInstanceId = 0;
|
|
8
|
+
|
|
9
|
+
// Type for tracking promises waiting to be resolved
|
|
10
|
+
|
|
11
|
+
// Return type for player API methods
|
|
12
|
+
|
|
13
|
+
// Prop types for the player component
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* TPStreamsPlayer - React component wrapper for TPStreamsPlayerView
|
|
17
|
+
* Provides a simple imperative API for controlling the player
|
|
18
|
+
*/
|
|
19
|
+
const TPStreamsPlayer = /*#__PURE__*/forwardRef((props, ref) => {
|
|
20
|
+
const {
|
|
21
|
+
videoId,
|
|
22
|
+
accessToken,
|
|
23
|
+
style,
|
|
24
|
+
onPlayerStateChanged,
|
|
25
|
+
onIsPlayingChanged,
|
|
26
|
+
onPlaybackSpeedChanged,
|
|
27
|
+
onIsLoadingChanged,
|
|
28
|
+
onError,
|
|
29
|
+
...restProps
|
|
30
|
+
} = props;
|
|
31
|
+
const nativeRef = useRef(null);
|
|
32
|
+
const instanceId = useRef(nextInstanceId++);
|
|
33
|
+
const promiseMap = useRef({});
|
|
34
|
+
|
|
35
|
+
// Event handlers that resolve promises
|
|
36
|
+
const onCurrentPosition = useCallback(event => {
|
|
37
|
+
const key = `position-${instanceId.current}`;
|
|
38
|
+
const handler = promiseMap.current[key];
|
|
39
|
+
if (handler) {
|
|
40
|
+
handler.resolve(event.nativeEvent.position);
|
|
41
|
+
delete promiseMap.current[key];
|
|
42
|
+
}
|
|
43
|
+
}, []);
|
|
44
|
+
const onDuration = useCallback(event => {
|
|
45
|
+
const key = `duration-${instanceId.current}`;
|
|
46
|
+
const handler = promiseMap.current[key];
|
|
47
|
+
if (handler) {
|
|
48
|
+
handler.resolve(event.nativeEvent.duration);
|
|
49
|
+
delete promiseMap.current[key];
|
|
50
|
+
}
|
|
51
|
+
}, []);
|
|
52
|
+
const onIsPlaying = useCallback(event => {
|
|
53
|
+
const key = `isPlaying-${instanceId.current}`;
|
|
54
|
+
const handler = promiseMap.current[key];
|
|
55
|
+
if (handler) {
|
|
56
|
+
handler.resolve(event.nativeEvent.isPlaying);
|
|
57
|
+
delete promiseMap.current[key];
|
|
58
|
+
}
|
|
59
|
+
}, []);
|
|
60
|
+
const onPlaybackSpeed = useCallback(event => {
|
|
61
|
+
const key = `playbackSpeed-${instanceId.current}`;
|
|
62
|
+
const handler = promiseMap.current[key];
|
|
63
|
+
if (handler) {
|
|
64
|
+
handler.resolve(event.nativeEvent.speed);
|
|
65
|
+
delete promiseMap.current[key];
|
|
66
|
+
}
|
|
67
|
+
}, []);
|
|
68
|
+
|
|
69
|
+
// Player event handlers
|
|
70
|
+
const handlePlayerStateChanged = useCallback(event => {
|
|
71
|
+
onPlayerStateChanged?.(event.nativeEvent.playbackState);
|
|
72
|
+
}, [onPlayerStateChanged]);
|
|
73
|
+
const handleIsPlayingChanged = useCallback(event => {
|
|
74
|
+
onIsPlayingChanged?.(event.nativeEvent.isPlaying);
|
|
75
|
+
}, [onIsPlayingChanged]);
|
|
76
|
+
const handlePlaybackSpeedChanged = useCallback(event => {
|
|
77
|
+
onPlaybackSpeedChanged?.(event.nativeEvent.speed);
|
|
78
|
+
}, [onPlaybackSpeedChanged]);
|
|
79
|
+
const handleIsLoadingChanged = useCallback(event => {
|
|
80
|
+
onIsLoadingChanged?.(event.nativeEvent.isLoading);
|
|
81
|
+
}, [onIsLoadingChanged]);
|
|
82
|
+
const handleError = useCallback(event => {
|
|
83
|
+
const {
|
|
84
|
+
message,
|
|
85
|
+
code,
|
|
86
|
+
details
|
|
87
|
+
} = event.nativeEvent;
|
|
88
|
+
|
|
89
|
+
// Reject any pending promises with this error
|
|
90
|
+
Object.entries(promiseMap.current).forEach(([key, handler]) => {
|
|
91
|
+
handler.reject(new Error(`${message}: ${details || 'Unknown error'}`));
|
|
92
|
+
delete promiseMap.current[key];
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
// Forward the error to the client if they provided an onError handler
|
|
96
|
+
onError?.({
|
|
97
|
+
message,
|
|
98
|
+
code,
|
|
99
|
+
details
|
|
100
|
+
});
|
|
101
|
+
}, [onError]);
|
|
102
|
+
|
|
103
|
+
// Helper to create promise-based API methods
|
|
104
|
+
const createPromiseMethod = useCallback((command, eventKey) => {
|
|
105
|
+
return () => new Promise((resolve, reject) => {
|
|
106
|
+
if (nativeRef.current) {
|
|
107
|
+
const key = `${eventKey}-${instanceId.current}`;
|
|
108
|
+
promiseMap.current[key] = {
|
|
109
|
+
resolve,
|
|
110
|
+
reject
|
|
111
|
+
};
|
|
112
|
+
command(nativeRef.current);
|
|
113
|
+
|
|
114
|
+
// Set a timeout to reject the promise if it's not resolved in time
|
|
115
|
+
setTimeout(() => {
|
|
116
|
+
if (promiseMap.current[key]) {
|
|
117
|
+
reject(new Error(`Timeout getting ${eventKey}`));
|
|
118
|
+
delete promiseMap.current[key];
|
|
119
|
+
}
|
|
120
|
+
}, 5000);
|
|
121
|
+
} else {
|
|
122
|
+
reject(new Error('Player is not initialized'));
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
}, []);
|
|
126
|
+
useImperativeHandle(ref, () => ({
|
|
127
|
+
play: () => nativeRef.current && Commands.play(nativeRef.current),
|
|
128
|
+
pause: () => nativeRef.current && Commands.pause(nativeRef.current),
|
|
129
|
+
seekTo: positionMs => nativeRef.current && Commands.seekTo(nativeRef.current, positionMs),
|
|
130
|
+
setPlaybackSpeed: speed => nativeRef.current && Commands.setPlaybackSpeed(nativeRef.current, speed),
|
|
131
|
+
getCurrentPosition: createPromiseMethod(Commands.getCurrentPosition, 'position'),
|
|
132
|
+
getDuration: createPromiseMethod(Commands.getDuration, 'duration'),
|
|
133
|
+
isPlaying: createPromiseMethod(Commands.isPlaying, 'isPlaying'),
|
|
134
|
+
getPlaybackSpeed: createPromiseMethod(Commands.getPlaybackSpeed, 'speed')
|
|
135
|
+
}), [createPromiseMethod]);
|
|
136
|
+
|
|
137
|
+
// Create native props object with the correct types
|
|
138
|
+
const nativeProps = {
|
|
139
|
+
...restProps,
|
|
140
|
+
videoId,
|
|
141
|
+
accessToken,
|
|
142
|
+
style,
|
|
143
|
+
onCurrentPosition,
|
|
144
|
+
onDuration,
|
|
145
|
+
onIsPlaying,
|
|
146
|
+
onPlaybackSpeed,
|
|
147
|
+
onPlayerStateChanged: handlePlayerStateChanged,
|
|
148
|
+
onIsPlayingChanged: handleIsPlayingChanged,
|
|
149
|
+
onPlaybackSpeedChanged: handlePlaybackSpeedChanged,
|
|
150
|
+
onIsLoadingChanged: handleIsLoadingChanged,
|
|
151
|
+
onError: handleError
|
|
152
|
+
};
|
|
153
|
+
return /*#__PURE__*/_jsx(TPStreamsPlayerView, {
|
|
154
|
+
...nativeProps,
|
|
155
|
+
ref: nativeRef
|
|
156
|
+
});
|
|
157
|
+
});
|
|
158
|
+
export default TPStreamsPlayer;
|
|
159
|
+
//# sourceMappingURL=TPStreamsPlayer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["forwardRef","useImperativeHandle","useRef","useCallback","TPStreamsPlayerView","Commands","jsx","_jsx","nextInstanceId","TPStreamsPlayer","props","ref","videoId","accessToken","style","onPlayerStateChanged","onIsPlayingChanged","onPlaybackSpeedChanged","onIsLoadingChanged","onError","restProps","nativeRef","instanceId","promiseMap","onCurrentPosition","event","key","current","handler","resolve","nativeEvent","position","onDuration","duration","onIsPlaying","isPlaying","onPlaybackSpeed","speed","handlePlayerStateChanged","playbackState","handleIsPlayingChanged","handlePlaybackSpeedChanged","handleIsLoadingChanged","isLoading","handleError","message","code","details","Object","entries","forEach","reject","Error","createPromiseMethod","command","eventKey","Promise","setTimeout","play","pause","seekTo","positionMs","setPlaybackSpeed","getCurrentPosition","getDuration","getPlaybackSpeed","nativeProps"],"sourceRoot":"../../src","sources":["TPStreamsPlayer.tsx"],"mappings":";;AAAA,SAASA,U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C;;EAED;EACA,MAAMa,WAAwB,GAAG;IAC/B,GAAG9C,SAAS;IACZR,OAAO;IACPC,WAAW;IACXC,KAAK;IACLU,iBAAiB;IACjBQ,UAAU;IACVE,WAAW;IACXE,eAAe;IACfrB,oBAAoB,EAAEuB,wBAAwB;IAC9CtB,kBAAkB,EAAEwB,sBAAsB;IAC1CvB,sBAAsB,EAAEwB,0BAA0B;IAClDvB,kBAAkB,EAAEwB,sBAAsB;IAC1CvB,OAAO,EAAEyB;EACX,CAAC;EAED,oBAAOrC,IAAA,CAACH,mBAAmB;IAAA,GAAK8D,WAAW;IAAEvD,GAAG,EAAEU;EAAU,CAAE,CAAC;AACjE,CACF,CAAC;AAED,eAAeZ,eAAe","ignoreList":[]}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent';
|
|
2
|
+
import type { ViewProps } from 'react-native';
|
|
3
|
+
import type {
|
|
4
|
+
Double,
|
|
5
|
+
Float,
|
|
6
|
+
Int32,
|
|
7
|
+
} from 'react-native/Libraries/Types/CodegenTypes';
|
|
8
|
+
import type { HostComponent } from 'react-native';
|
|
9
|
+
import type { DirectEventHandler } from 'react-native/Libraries/Types/CodegenTypes';
|
|
10
|
+
import codegenNativeCommands from 'react-native/Libraries/Utilities/codegenNativeCommands';
|
|
11
|
+
|
|
12
|
+
export interface ErrorEvent {
|
|
13
|
+
message: string;
|
|
14
|
+
code: Int32;
|
|
15
|
+
details?: string;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface NativeProps extends ViewProps {
|
|
19
|
+
videoId?: string;
|
|
20
|
+
accessToken?: string;
|
|
21
|
+
|
|
22
|
+
// Event props for receiving data from native methods
|
|
23
|
+
onCurrentPosition?: DirectEventHandler<{ position: Double }>;
|
|
24
|
+
onDuration?: DirectEventHandler<{ duration: Double }>;
|
|
25
|
+
onIsPlaying?: DirectEventHandler<{ isPlaying: boolean }>;
|
|
26
|
+
onPlaybackSpeed?: DirectEventHandler<{ speed: Float }>;
|
|
27
|
+
|
|
28
|
+
// Player event props
|
|
29
|
+
onPlayerStateChanged?: DirectEventHandler<{ playbackState: Int32 }>;
|
|
30
|
+
onIsPlayingChanged?: DirectEventHandler<{ isPlaying: boolean }>;
|
|
31
|
+
onPlaybackSpeedChanged?: DirectEventHandler<{ speed: Double }>;
|
|
32
|
+
onIsLoadingChanged?: DirectEventHandler<{ isLoading: boolean }>;
|
|
33
|
+
onError?: DirectEventHandler<ErrorEvent>;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
interface TPStreamsPlayerViewCommands {
|
|
37
|
+
play: (viewRef: React.ElementRef<HostComponent<NativeProps>>) => void;
|
|
38
|
+
pause: (viewRef: React.ElementRef<HostComponent<NativeProps>>) => void;
|
|
39
|
+
seekTo: (
|
|
40
|
+
viewRef: React.ElementRef<HostComponent<NativeProps>>,
|
|
41
|
+
positionMs: Double
|
|
42
|
+
) => void;
|
|
43
|
+
setPlaybackSpeed: (
|
|
44
|
+
viewRef: React.ElementRef<HostComponent<NativeProps>>,
|
|
45
|
+
speed: Float
|
|
46
|
+
) => void;
|
|
47
|
+
getCurrentPosition: (
|
|
48
|
+
viewRef: React.ElementRef<HostComponent<NativeProps>>
|
|
49
|
+
) => void;
|
|
50
|
+
getDuration: (viewRef: React.ElementRef<HostComponent<NativeProps>>) => void;
|
|
51
|
+
isPlaying: (viewRef: React.ElementRef<HostComponent<NativeProps>>) => void;
|
|
52
|
+
getPlaybackSpeed: (
|
|
53
|
+
viewRef: React.ElementRef<HostComponent<NativeProps>>
|
|
54
|
+
) => void;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export const Commands = codegenNativeCommands<TPStreamsPlayerViewCommands>({
|
|
58
|
+
supportedCommands: [
|
|
59
|
+
'play',
|
|
60
|
+
'pause',
|
|
61
|
+
'seekTo',
|
|
62
|
+
'setPlaybackSpeed',
|
|
63
|
+
'getCurrentPosition',
|
|
64
|
+
'getDuration',
|
|
65
|
+
'isPlaying',
|
|
66
|
+
'getPlaybackSpeed',
|
|
67
|
+
],
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
export default codegenNativeComponent<NativeProps>('TPStreamsRNPlayerView');
|
package/lib/module/index.js
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
export
|
|
3
|
+
import { NativeModules } from 'react-native';
|
|
4
|
+
export { default as TPStreamsPlayerView } from './TPStreamsPlayerViewNativeComponent';
|
|
5
|
+
export * from './TPStreamsPlayerViewNativeComponent';
|
|
6
|
+
export { default as TPStreamsPlayer } from "./TPStreamsPlayer.js";
|
|
7
|
+
const TPStreamsModule = NativeModules.TPStreams;
|
|
8
|
+
export const TPStreams = {
|
|
9
|
+
initialize: organizationId => {
|
|
10
|
+
TPStreamsModule.initialize(organizationId);
|
|
11
|
+
}
|
|
12
|
+
};
|
|
6
13
|
//# sourceMappingURL=index.js.map
|
package/lib/module/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["NativeModules","default","TPStreamsPlayerView","TPStreamsPlayer","TPStreamsModule","TPStreams","initialize","organizationId"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;AAAA,SAASA,aAAa,QAAQ,cAAc;AAC5C,SAASC,OAAO,IAAIC,mBAAmB,QAAQ,sCAAsC;AACrF,cAAc,sCAAsC;AAEpD,SAASD,OAAO,IAAIE,eAAe,QAAQ,sBAAmB;AAG9D,MAAMC,eAAe,GAAGJ,aAAa,CAACK,SAAS;AAE/C,OAAO,MAAMA,SAAS,GAAG;EACvBC,UAAU,EAAGC,cAAsB,IAAW;IAC5CH,eAAe,CAACE,UAAU,CAACC,cAAc,CAAC;EAC5C;AACF,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"module"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { ViewProps } from 'react-native';
|
|
3
|
+
export interface TPStreamsPlayerRef {
|
|
4
|
+
play: () => void;
|
|
5
|
+
pause: () => void;
|
|
6
|
+
seekTo: (positionMs: number) => void;
|
|
7
|
+
setPlaybackSpeed: (speed: number) => void;
|
|
8
|
+
getCurrentPosition: () => Promise<number>;
|
|
9
|
+
getDuration: () => Promise<number>;
|
|
10
|
+
isPlaying: () => Promise<boolean>;
|
|
11
|
+
getPlaybackSpeed: () => Promise<number>;
|
|
12
|
+
}
|
|
13
|
+
export interface TPStreamsPlayerProps extends ViewProps {
|
|
14
|
+
videoId?: string;
|
|
15
|
+
accessToken?: string;
|
|
16
|
+
onPlayerStateChanged?: (state: number) => void;
|
|
17
|
+
onIsPlayingChanged?: (isPlaying: boolean) => void;
|
|
18
|
+
onPlaybackSpeedChanged?: (speed: number) => void;
|
|
19
|
+
onIsLoadingChanged?: (isLoading: boolean) => void;
|
|
20
|
+
onError?: (error: {
|
|
21
|
+
message: string;
|
|
22
|
+
code: number;
|
|
23
|
+
details?: string;
|
|
24
|
+
}) => void;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* TPStreamsPlayer - React component wrapper for TPStreamsPlayerView
|
|
28
|
+
* Provides a simple imperative API for controlling the player
|
|
29
|
+
*/
|
|
30
|
+
declare const TPStreamsPlayer: import("react").ForwardRefExoticComponent<TPStreamsPlayerProps & import("react").RefAttributes<TPStreamsPlayerRef>>;
|
|
31
|
+
export default TPStreamsPlayer;
|
|
32
|
+
//# sourceMappingURL=TPStreamsPlayer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TPStreamsPlayer.d.ts","sourceRoot":"","sources":["../../../src/TPStreamsPlayer.tsx"],"names":[],"mappings":";AAQA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAc9C,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,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