react-native-spalla-player 0.13.3 → 1.0.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 +2 -3
- package/SpallaPlayer.podspec +22 -0
- package/android/build.gradle +22 -58
- package/android/gradle.properties +5 -5
- package/android/src/main/AndroidManifest.xml +1 -2
- package/android/src/main/java/com/spallaplayer/RNSpallaPlayerEvent.kt +19 -0
- package/android/src/main/java/com/spallaplayer/SpallaPlayerModule.kt +64 -150
- package/android/src/main/java/com/spallaplayer/SpallaPlayerPackage.kt +15 -3
- package/android/src/main/java/com/spallaplayer/SpallaPlayerViewManager.kt +164 -107
- package/ios/SpallaPlayerModule.h +17 -0
- package/ios/SpallaPlayerModule.mm +59 -0
- package/ios/SpallaPlayerView.h +14 -0
- package/ios/SpallaPlayerView.mm +158 -0
- package/ios/SpallaPlayerWrapper.swift +12 -8
- package/lib/module/NativeSpallaPlayerModule.js +5 -0
- package/lib/module/NativeSpallaPlayerModule.js.map +1 -0
- package/lib/module/SpallaPlayerViewNativeComponent.js +11 -0
- package/lib/module/SpallaPlayerViewNativeComponent.js.map +1 -0
- package/lib/module/index.js +48 -55
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/src/NativeSpallaPlayerModule.d.ts +13 -0
- package/lib/typescript/src/NativeSpallaPlayerModule.d.ts.map +1 -0
- package/lib/typescript/src/SpallaPlayerViewNativeComponent.d.ts +33 -0
- package/lib/typescript/src/SpallaPlayerViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/src/components/CastButton.d.ts.map +1 -0
- package/lib/typescript/{module/src → src}/index.d.ts +9 -15
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/package.json +93 -103
- package/src/NativeSpallaPlayerModule.ts +14 -0
- package/src/SpallaPlayerViewNativeComponent.ts +61 -0
- package/src/index.tsx +71 -82
- package/android/src/main/AndroidManifestNew.xml +0 -2
- package/android/src/main/java/com/spallaplayer/SpallaPlayerContainerView.kt +0 -36
- package/ios/RNSpallaPlayer.m +0 -102
- package/ios/RNSpallaPlayer.swift +0 -11
- package/ios/SpallaPlayer-Bridging-Header.h +0 -1
- package/lib/commonjs/components/CastButton.js +0 -49
- package/lib/commonjs/components/CastButton.js.map +0 -1
- package/lib/commonjs/index.js +0 -81
- package/lib/commonjs/index.js.map +0 -1
- package/lib/typescript/commonjs/package.json +0 -1
- package/lib/typescript/commonjs/src/components/CastButton.d.ts.map +0 -1
- package/lib/typescript/commonjs/src/index.d.ts +0 -61
- package/lib/typescript/commonjs/src/index.d.ts.map +0 -1
- package/lib/typescript/module/src/components/CastButton.d.ts +0 -13
- package/lib/typescript/module/src/components/CastButton.d.ts.map +0 -1
- package/lib/typescript/module/src/index.d.ts.map +0 -1
- package/react-native-spalla-player.podspec +0 -44
- /package/lib/{typescript/module → module}/package.json +0 -0
- /package/lib/typescript/{commonjs/src → src}/components/CastButton.d.ts +0 -0
package/LICENSE
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
MIT License
|
|
2
2
|
|
|
3
|
-
Copyright (c)
|
|
4
|
-
|
|
3
|
+
Copyright (c) 2025 Rogerio Shimizu
|
|
5
4
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
5
|
of this software and associated documentation files (the "Software"), to deal
|
|
7
6
|
in the Software without restriction, including without limitation the rights
|
|
@@ -18,4 +17,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
18
17
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
18
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
19
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
20
|
+
SOFTWARE.
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
require "json"
|
|
2
|
+
|
|
3
|
+
package = JSON.parse(File.read(File.join(__dir__, "package.json")))
|
|
4
|
+
|
|
5
|
+
Pod::Spec.new do |s|
|
|
6
|
+
s.name = "SpallaPlayer"
|
|
7
|
+
s.version = package["version"]
|
|
8
|
+
s.summary = package["description"]
|
|
9
|
+
s.homepage = package["homepage"]
|
|
10
|
+
s.license = package["license"]
|
|
11
|
+
s.authors = package["author"]
|
|
12
|
+
|
|
13
|
+
s.platforms = { :ios => min_ios_version_supported }
|
|
14
|
+
s.source = { :git => "https://github.com/rojas/react-native-spalla-player.git", :tag => "#{s.version}" }
|
|
15
|
+
|
|
16
|
+
s.source_files = "ios/**/*.{h,m,mm,swift,cpp}"
|
|
17
|
+
s.private_header_files = "ios/**/*.h"
|
|
18
|
+
|
|
19
|
+
s.dependency "SpallaSDK", "~> 2.2.5"
|
|
20
|
+
|
|
21
|
+
install_modules_dependencies(s)
|
|
22
|
+
end
|
package/android/build.gradle
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
buildscript {
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
ext.getExtOrDefault = {name ->
|
|
3
|
+
return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties['SpallaPlayer_' + name]
|
|
4
|
+
}
|
|
4
5
|
|
|
5
6
|
repositories {
|
|
6
7
|
google()
|
|
@@ -9,68 +10,33 @@ buildscript {
|
|
|
9
10
|
}
|
|
10
11
|
|
|
11
12
|
dependencies {
|
|
12
|
-
classpath
|
|
13
|
+
classpath "com.android.tools.build:gradle:8.7.2"
|
|
13
14
|
// noinspection DifferentKotlinGradleVersion
|
|
14
|
-
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$
|
|
15
|
+
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${getExtOrDefault('kotlinVersion')}"
|
|
15
16
|
}
|
|
16
17
|
}
|
|
17
18
|
|
|
18
|
-
def reactNativeArchitectures() {
|
|
19
|
-
def value = rootProject.getProperties().get("reactNativeArchitectures")
|
|
20
|
-
return value ? value.split(",") : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"]
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
def isNewArchitectureEnabled() {
|
|
24
|
-
return rootProject.hasProperty("newArchEnabled") && rootProject.getProperty("newArchEnabled") == "true"
|
|
25
|
-
}
|
|
26
|
-
|
|
27
19
|
apply plugin: "com.android.library"
|
|
28
20
|
apply plugin: "kotlin-android"
|
|
29
21
|
|
|
30
|
-
|
|
31
|
-
apply plugin: "com.facebook.react"
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
def getExtOrDefault(name) {
|
|
35
|
-
return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties["SpallaPlayer_" + name]
|
|
36
|
-
}
|
|
22
|
+
apply plugin: "com.facebook.react"
|
|
37
23
|
|
|
38
24
|
def getExtOrIntegerDefault(name) {
|
|
39
25
|
return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["SpallaPlayer_" + name]).toInteger()
|
|
40
26
|
}
|
|
41
27
|
|
|
42
|
-
def safeExtGet(prop, fallback) {
|
|
43
|
-
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
def supportsNamespace() {
|
|
48
|
-
def parsed = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION.tokenize('.')
|
|
49
|
-
def major = parsed[0].toInteger()
|
|
50
|
-
def minor = parsed[1].toInteger()
|
|
51
|
-
|
|
52
|
-
// Namespace support was added in 7.3.0
|
|
53
|
-
return (major == 7 && minor >= 3) || major >= 8
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
|
|
57
28
|
android {
|
|
58
|
-
|
|
59
|
-
namespace "com.spallaplayer"
|
|
60
|
-
|
|
61
|
-
sourceSets {
|
|
62
|
-
main {
|
|
63
|
-
manifest.srcFile "src/main/AndroidManifestNew.xml"
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
}
|
|
29
|
+
namespace "com.spallaplayer"
|
|
67
30
|
|
|
68
31
|
compileSdkVersion getExtOrIntegerDefault("compileSdkVersion")
|
|
69
32
|
|
|
70
33
|
defaultConfig {
|
|
71
34
|
minSdkVersion getExtOrIntegerDefault("minSdkVersion")
|
|
72
35
|
targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
|
|
73
|
-
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
buildFeatures {
|
|
39
|
+
buildConfig true
|
|
74
40
|
}
|
|
75
41
|
|
|
76
42
|
buildTypes {
|
|
@@ -79,10 +45,6 @@ android {
|
|
|
79
45
|
}
|
|
80
46
|
}
|
|
81
47
|
|
|
82
|
-
buildFeatures {
|
|
83
|
-
buildConfig = true
|
|
84
|
-
}
|
|
85
|
-
|
|
86
48
|
lintOptions {
|
|
87
49
|
disable "GradleCompatible"
|
|
88
50
|
}
|
|
@@ -91,26 +53,28 @@ android {
|
|
|
91
53
|
sourceCompatibility JavaVersion.VERSION_1_8
|
|
92
54
|
targetCompatibility JavaVersion.VERSION_1_8
|
|
93
55
|
}
|
|
56
|
+
|
|
57
|
+
sourceSets {
|
|
58
|
+
main {
|
|
59
|
+
java.srcDirs += [
|
|
60
|
+
"generated/java",
|
|
61
|
+
"generated/jni"
|
|
62
|
+
]
|
|
63
|
+
}
|
|
64
|
+
}
|
|
94
65
|
}
|
|
95
66
|
|
|
96
67
|
repositories {
|
|
97
68
|
mavenCentral()
|
|
98
69
|
google()
|
|
99
|
-
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
|
|
100
|
-
maven { url 'https://maven.theoplayer.com/releases' }
|
|
101
70
|
}
|
|
102
71
|
|
|
103
72
|
def kotlin_version = getExtOrDefault("kotlinVersion")
|
|
104
73
|
|
|
105
74
|
dependencies {
|
|
106
|
-
|
|
107
|
-
// For > 0.71, this will be replaced by `com.facebook.react:react-android:$version` by react gradle plugin
|
|
108
|
-
//noinspection GradleDynamicVersion
|
|
109
|
-
implementation "com.facebook.react:react-native:+"
|
|
75
|
+
implementation "com.facebook.react:react-android"
|
|
110
76
|
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
|
111
77
|
implementation "androidx.mediarouter:mediarouter:1.2.0"
|
|
112
|
-
implementation "stream.spalla:spalla-android-sdk:1.10.
|
|
78
|
+
implementation "stream.spalla:spalla-android-sdk:1.10.1"
|
|
113
79
|
implementation "com.google.android.gms:play-services-cast-framework:21.3.0"
|
|
114
80
|
}
|
|
115
|
-
|
|
116
|
-
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
SpallaPlayer_kotlinVersion=
|
|
2
|
-
SpallaPlayer_minSdkVersion=
|
|
3
|
-
SpallaPlayer_targetSdkVersion=
|
|
4
|
-
SpallaPlayer_compileSdkVersion=
|
|
5
|
-
|
|
1
|
+
SpallaPlayer_kotlinVersion=2.0.21
|
|
2
|
+
SpallaPlayer_minSdkVersion=24
|
|
3
|
+
SpallaPlayer_targetSdkVersion=34
|
|
4
|
+
SpallaPlayer_compileSdkVersion=35
|
|
5
|
+
SpallaPlayer_ndkVersion=27.1.12297006
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
package com.spallaplayer
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.WritableMap
|
|
4
|
+
import com.facebook.react.uimanager.events.Event
|
|
5
|
+
import com.facebook.react.uimanager.events.RCTEventEmitter
|
|
6
|
+
|
|
7
|
+
// This class is a requirement for Fabric's eventing system.
|
|
8
|
+
// It defines the shape and behavior of the events your component sends.
|
|
9
|
+
class RNSpallaPlayerEvent(
|
|
10
|
+
surfaceId: Int,
|
|
11
|
+
viewTag: Int,
|
|
12
|
+
private val eventName1: String,
|
|
13
|
+
private val eventData: WritableMap?
|
|
14
|
+
) : Event<RNSpallaPlayerEvent>(surfaceId, viewTag) {
|
|
15
|
+
|
|
16
|
+
override fun getEventName(): String = eventName1
|
|
17
|
+
|
|
18
|
+
override fun getEventData() = eventData
|
|
19
|
+
}
|
|
@@ -1,193 +1,107 @@
|
|
|
1
1
|
package com.spallaplayer
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import android.util.Log
|
|
4
4
|
import com.facebook.react.bridge.ReactApplicationContext
|
|
5
5
|
import com.facebook.react.bridge.ReactContextBaseJavaModule
|
|
6
6
|
import com.facebook.react.bridge.ReactMethod
|
|
7
7
|
import com.facebook.react.bridge.UIManager
|
|
8
|
-
import com.facebook.react.uimanager.NativeViewHierarchyManager
|
|
9
8
|
import com.facebook.react.uimanager.UIManagerHelper
|
|
10
|
-
import com.facebook.react.uimanager.UIManagerModule
|
|
11
9
|
import com.facebook.react.uimanager.common.UIManagerType
|
|
12
10
|
import com.spalla.sdk.android.core.SpallaSDK
|
|
13
11
|
import com.spalla.sdk.android.core.player.view.SpallaPlayerView
|
|
14
12
|
|
|
13
|
+
class SpallaPlayerModule(
|
|
14
|
+
val reactContext: ReactApplicationContext
|
|
15
|
+
): ReactContextBaseJavaModule(reactContext) {
|
|
15
16
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
LifecycleEventListener {
|
|
19
|
-
private val _reactContext: ReactApplicationContext
|
|
20
|
-
|
|
21
|
-
init {
|
|
22
|
-
reactContext.addLifecycleEventListener(this)
|
|
23
|
-
_reactContext = reactContext
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
override fun getName(): String {
|
|
27
|
-
return "RNSpallaPlayer"
|
|
17
|
+
companion object {
|
|
18
|
+
val REACT_NAME: String = "SpallaPlayerModule"
|
|
28
19
|
}
|
|
29
20
|
|
|
30
|
-
override fun
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
override fun onHostPause() {
|
|
21
|
+
override fun getName() = REACT_NAME
|
|
34
22
|
|
|
23
|
+
@ReactMethod
|
|
24
|
+
fun play(tag: Double) {
|
|
25
|
+
reactContext.runOnUiQueueThread {
|
|
26
|
+
val view = getSpallaPlayerView(tag)
|
|
27
|
+
view?.play()
|
|
28
|
+
}
|
|
35
29
|
}
|
|
36
30
|
|
|
37
|
-
|
|
31
|
+
@ReactMethod
|
|
32
|
+
fun pause(tag: Double) {
|
|
33
|
+
reactContext.runOnUiQueueThread {
|
|
34
|
+
val view = getSpallaPlayerView(tag)
|
|
35
|
+
view?.pause()
|
|
36
|
+
}
|
|
38
37
|
}
|
|
39
38
|
|
|
40
39
|
@ReactMethod
|
|
41
|
-
fun
|
|
42
|
-
|
|
43
|
-
val
|
|
44
|
-
|
|
45
|
-
uiManager.resolveView(tag)?.let { view ->
|
|
46
|
-
if (view is SpallaPlayerContainerView) {
|
|
47
|
-
view.spallaPlayerView.play()
|
|
48
|
-
} else {
|
|
49
|
-
throw ClassCastException(
|
|
50
|
-
"Cannot play: view with tag #$tag is not a SpallaPlayerView"
|
|
51
|
-
)
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
} else {
|
|
56
|
-
val uiManager: UIManagerModule? =
|
|
57
|
-
_reactContext.getNativeModule(UIManagerModule::class.java)
|
|
58
|
-
uiManager?.prependUIBlock { nativeViewHierarchyManager: NativeViewHierarchyManager ->
|
|
59
|
-
val playerView = nativeViewHierarchyManager.resolveView(tag)
|
|
60
|
-
if (playerView is SpallaPlayerContainerView) {
|
|
61
|
-
playerView.spallaPlayerView.play()
|
|
62
|
-
} else {
|
|
63
|
-
throw ClassCastException(
|
|
64
|
-
String.format(
|
|
65
|
-
"Cannot play: view with tag #%d is not a SpallaPlayerView",
|
|
66
|
-
tag
|
|
67
|
-
)
|
|
68
|
-
)
|
|
69
|
-
}
|
|
70
|
-
}
|
|
40
|
+
fun seekTo(tag: Double, time: Double) {
|
|
41
|
+
reactContext.runOnUiQueueThread {
|
|
42
|
+
val view = getSpallaPlayerView(tag)
|
|
43
|
+
view?.seekTo(time)
|
|
71
44
|
}
|
|
72
45
|
}
|
|
73
46
|
|
|
74
47
|
@ReactMethod
|
|
75
|
-
fun
|
|
76
|
-
|
|
77
|
-
val
|
|
78
|
-
|
|
79
|
-
uiManager.resolveView(tag)?.let { view ->
|
|
80
|
-
if (view is SpallaPlayerContainerView) {
|
|
81
|
-
view.spallaPlayerView.pause()
|
|
82
|
-
} else {
|
|
83
|
-
throw ClassCastException(
|
|
84
|
-
"Cannot pause: view with tag #$tag is not a SpallaPlayerView"
|
|
85
|
-
)
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
} else {
|
|
90
|
-
val uiManager: UIManagerModule? =
|
|
91
|
-
_reactContext.getNativeModule(UIManagerModule::class.java)
|
|
92
|
-
uiManager?.prependUIBlock { nativeViewHierarchyManager: NativeViewHierarchyManager ->
|
|
93
|
-
val playerView = nativeViewHierarchyManager.resolveView(tag)
|
|
94
|
-
if (playerView is SpallaPlayerContainerView) {
|
|
95
|
-
playerView.spallaPlayerView.pause()
|
|
96
|
-
} else {
|
|
97
|
-
throw ClassCastException(
|
|
98
|
-
String.format(
|
|
99
|
-
"Cannot play: view with tag #%d is not a SpallaPplayerView",
|
|
100
|
-
tag
|
|
101
|
-
)
|
|
102
|
-
)
|
|
103
|
-
}
|
|
104
|
-
}
|
|
48
|
+
fun selectSubtitle(tag: Double, subtitle: String?) {
|
|
49
|
+
reactContext.runOnUiQueueThread {
|
|
50
|
+
val view = getSpallaPlayerView(tag)
|
|
51
|
+
view?.selectSubtitle(subtitle)
|
|
105
52
|
}
|
|
106
|
-
|
|
107
|
-
|
|
108
53
|
}
|
|
109
54
|
|
|
110
55
|
@ReactMethod
|
|
111
|
-
fun
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
playerView.spallaPlayerView.seekTo(time)
|
|
117
|
-
} else {
|
|
118
|
-
throw ClassCastException(
|
|
119
|
-
String.format(
|
|
120
|
-
"Cannot play: view with tag #%d is not a SpallaPplayerView",
|
|
121
|
-
tag
|
|
122
|
-
)
|
|
123
|
-
)
|
|
124
|
-
}
|
|
125
|
-
}
|
|
56
|
+
fun selectPlaybackRate(tag: Double, rate: Double) {
|
|
57
|
+
reactContext.runOnUiQueueThread {
|
|
58
|
+
val view = getSpallaPlayerView(tag)
|
|
59
|
+
view?.selectPlaybackRate(rate)
|
|
60
|
+
}
|
|
126
61
|
}
|
|
127
62
|
|
|
128
63
|
@ReactMethod
|
|
129
|
-
fun
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
} else {
|
|
136
|
-
throw ClassCastException(
|
|
137
|
-
String.format(
|
|
138
|
-
"Cannot play: view with tag #%d is not a SpallaPplayerView",
|
|
139
|
-
tag
|
|
140
|
-
)
|
|
141
|
-
)
|
|
142
|
-
}
|
|
143
|
-
}
|
|
64
|
+
fun unmount(tag: Double) {
|
|
65
|
+
try {
|
|
66
|
+
pause(tag)
|
|
67
|
+
} catch (e: Exception) {
|
|
68
|
+
Log.e("SpallaPlayerModule", "Error in unmount method", e)
|
|
69
|
+
}
|
|
144
70
|
}
|
|
145
71
|
|
|
146
72
|
@ReactMethod
|
|
147
|
-
fun
|
|
148
|
-
|
|
149
|
-
.
|
|
150
|
-
|
|
151
|
-
if (playerView is SpallaPlayerContainerView) {
|
|
152
|
-
playerView.spallaPlayerView.selectPlaybackRate(rate)
|
|
153
|
-
} else {
|
|
154
|
-
throw ClassCastException(
|
|
155
|
-
String.format(
|
|
156
|
-
"Cannot play: view with tag #%d is not a SpallaPplayerView",
|
|
157
|
-
tag
|
|
158
|
-
)
|
|
159
|
-
)
|
|
160
|
-
}
|
|
73
|
+
fun initialize(token: String?, applicationId: String?) {
|
|
74
|
+
try {
|
|
75
|
+
if (token.isNullOrBlank()) {
|
|
76
|
+
throw IllegalArgumentException("Token cannot be null or empty")
|
|
161
77
|
}
|
|
78
|
+
SpallaSDK.initialize(reactContext, token)
|
|
79
|
+
} catch (e: Exception) {
|
|
80
|
+
Log.e("SpallaPlayerModule", "Failed to initialize SpallaSDK", e)
|
|
81
|
+
}
|
|
162
82
|
}
|
|
163
83
|
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
val uiManager = UIManagerHelper.getUIManager(_reactContext, UIManagerType.FABRIC)
|
|
84
|
+
fun getSpallaPlayerView(tag: Double): SpallaPlayerView? {
|
|
85
|
+
try {
|
|
86
|
+
val uiManager = UIManagerHelper.getUIManager(reactContext, UIManagerType.FABRIC)
|
|
168
87
|
if (uiManager is UIManager) {
|
|
169
|
-
uiManager.resolveView(tag)
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
val playerView = nativeViewHierarchyManager.resolveView(tag)
|
|
180
|
-
if (playerView is SpallaPlayerContainerView) {
|
|
181
|
-
playerView.spallaPlayerView.pause()
|
|
88
|
+
val view = uiManager.resolveView(tag.toInt())
|
|
89
|
+
if (view is SpallaPlayerView) {
|
|
90
|
+
return view
|
|
91
|
+
} else if (view != null) {
|
|
92
|
+
Log.e(
|
|
93
|
+
"SpallaPlayerModule",
|
|
94
|
+
"Cannot play: view with tag #$tag is not a SpallaPlayerView"
|
|
95
|
+
)
|
|
96
|
+
} else {
|
|
97
|
+
Log.e("SpallaPlayerModule", "Cannot find view with tag #$tag")
|
|
182
98
|
}
|
|
99
|
+
} else {
|
|
100
|
+
Log.e("SpallaPlayerModule", "UIManager is not available")
|
|
183
101
|
}
|
|
102
|
+
} catch (e: Exception) {
|
|
103
|
+
Log.e("SpallaPlayerModule", "Error in play method", e)
|
|
184
104
|
}
|
|
105
|
+
return null
|
|
185
106
|
}
|
|
186
|
-
|
|
187
|
-
@ReactMethod
|
|
188
|
-
fun initialize(token: String, applicationId: String?) {
|
|
189
|
-
SpallaSDK.initialize(_reactContext, token)
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
|
|
193
107
|
}
|
|
@@ -5,14 +5,26 @@ import com.facebook.react.bridge.NativeModule
|
|
|
5
5
|
import com.facebook.react.bridge.ReactApplicationContext
|
|
6
6
|
import com.facebook.react.uimanager.ViewManager
|
|
7
7
|
import com.spallaplayer.components.RNGoogleCastButtonManager
|
|
8
|
+
import java.util.ArrayList
|
|
8
9
|
|
|
10
|
+
class SpallaPlayerViewPackage : ReactPackage {
|
|
11
|
+
override fun createViewManagers(reactContext: ReactApplicationContext): List<ViewManager<*, *>> {
|
|
12
|
+
val viewManagers: MutableList<ViewManager<*, *>> = ArrayList()
|
|
13
|
+
viewManagers.add(SpallaPlayerViewManager())
|
|
14
|
+
viewManagers.add(RNGoogleCastButtonManager())
|
|
15
|
+
return viewManagers
|
|
16
|
+
}
|
|
9
17
|
|
|
10
|
-
|
|
18
|
+
@Deprecated("Migrate to [BaseReactPackage] and implement [getModule] instead.")
|
|
11
19
|
override fun createNativeModules(reactContext: ReactApplicationContext): List<NativeModule> {
|
|
12
20
|
return listOf(SpallaPlayerModule(reactContext))
|
|
13
21
|
}
|
|
14
22
|
|
|
15
|
-
override fun
|
|
16
|
-
return
|
|
23
|
+
override fun getModule(name: String, reactContext: ReactApplicationContext): NativeModule? {
|
|
24
|
+
return when (name) {
|
|
25
|
+
SpallaPlayerModule.REACT_NAME -> SpallaPlayerModule(reactContext)
|
|
26
|
+
else -> null
|
|
27
|
+
}
|
|
17
28
|
}
|
|
29
|
+
|
|
18
30
|
}
|