react-native-spalla-player 0.13.3 → 1.0.0
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.fabric.kt +103 -0
- package/android/src/main/java/com/spallaplayer/SpallaPlayerModule.kt +32 -21
- package/android/src/main/java/com/spallaplayer/SpallaPlayerPackage.kt +18 -4
- package/android/src/main/java/com/spallaplayer/SpallaPlayerView.kt +15 -0
- package/android/src/main/java/com/spallaplayer/SpallaPlayerViewManager.fabric.kt +289 -0
- package/android/src/main/java/com/spallaplayer/SpallaPlayerViewManager.kt +25 -27
- 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
|
+
}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
package com.spallaplayer
|
|
2
|
+
|
|
3
|
+
import android.util.Log
|
|
4
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
5
|
+
import com.facebook.react.bridge.ReactContextBaseJavaModule
|
|
6
|
+
import com.facebook.react.bridge.ReactMethod
|
|
7
|
+
import com.facebook.react.bridge.UIManager
|
|
8
|
+
import com.facebook.react.uimanager.UIManagerHelper
|
|
9
|
+
import com.facebook.react.uimanager.common.UIManagerType
|
|
10
|
+
import com.spalla.sdk.android.core.SpallaSDK
|
|
11
|
+
import com.spalla.sdk.android.core.player.view.SpallaPlayerView
|
|
12
|
+
|
|
13
|
+
class SpallaPlayerModuleFabric(
|
|
14
|
+
val reactContext: ReactApplicationContext
|
|
15
|
+
): ReactContextBaseJavaModule(reactContext) {
|
|
16
|
+
|
|
17
|
+
override fun getName() = "SpallaPlayerModule"
|
|
18
|
+
|
|
19
|
+
@ReactMethod
|
|
20
|
+
fun play(tag: Double) {
|
|
21
|
+
reactContext.runOnUiQueueThread {
|
|
22
|
+
val view = getSpallaPlayerView(tag)
|
|
23
|
+
view?.play()
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
@ReactMethod
|
|
28
|
+
fun pause(tag: Double) {
|
|
29
|
+
reactContext.runOnUiQueueThread {
|
|
30
|
+
val view = getSpallaPlayerView(tag)
|
|
31
|
+
view?.pause()
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
@ReactMethod
|
|
36
|
+
fun seekTo(tag: Double, time: Double) {
|
|
37
|
+
reactContext.runOnUiQueueThread {
|
|
38
|
+
val view = getSpallaPlayerView(tag)
|
|
39
|
+
view?.seekTo(time)
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
@ReactMethod
|
|
44
|
+
fun selectSubtitle(tag: Double, subtitle: String?) {
|
|
45
|
+
reactContext.runOnUiQueueThread {
|
|
46
|
+
val view = getSpallaPlayerView(tag)
|
|
47
|
+
view?.selectSubtitle(subtitle)
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
@ReactMethod
|
|
52
|
+
fun selectPlaybackRate(tag: Double, rate: Double) {
|
|
53
|
+
reactContext.runOnUiQueueThread {
|
|
54
|
+
val view = getSpallaPlayerView(tag)
|
|
55
|
+
view?.selectPlaybackRate(rate)
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
@ReactMethod
|
|
60
|
+
fun unmount(tag: Double) {
|
|
61
|
+
try {
|
|
62
|
+
pause(tag)
|
|
63
|
+
} catch (e: Exception) {
|
|
64
|
+
Log.e("SpallaPlayerModule", "Error in unmount method", e)
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
@ReactMethod
|
|
69
|
+
fun initialize(token: String?, applicationId: String?) {
|
|
70
|
+
try {
|
|
71
|
+
if (token.isNullOrBlank()) {
|
|
72
|
+
throw IllegalArgumentException("Token cannot be null or empty")
|
|
73
|
+
}
|
|
74
|
+
SpallaSDK.initialize(reactContext, token)
|
|
75
|
+
} catch (e: Exception) {
|
|
76
|
+
Log.e("SpallaPlayerModule", "Failed to initialize SpallaSDK", e)
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
fun getSpallaPlayerView(tag: Double): SpallaPlayerView? {
|
|
81
|
+
try {
|
|
82
|
+
val uiManager = UIManagerHelper.getUIManager(reactContext, UIManagerType.FABRIC)
|
|
83
|
+
if (uiManager is UIManager) {
|
|
84
|
+
val view = uiManager.resolveView(tag.toInt())
|
|
85
|
+
if (view is SpallaPlayerView) {
|
|
86
|
+
return view
|
|
87
|
+
} else if (view != null) {
|
|
88
|
+
Log.e(
|
|
89
|
+
"SpallaPlayerModule",
|
|
90
|
+
"Cannot play: view with tag #$tag is not a SpallaPlayerView"
|
|
91
|
+
)
|
|
92
|
+
} else {
|
|
93
|
+
Log.e("SpallaPlayerModule", "Cannot find view with tag #$tag")
|
|
94
|
+
}
|
|
95
|
+
} else {
|
|
96
|
+
Log.e("SpallaPlayerModule", "UIManager is not available")
|
|
97
|
+
}
|
|
98
|
+
} catch (e: Exception) {
|
|
99
|
+
Log.e("SpallaPlayerModule", "Error in play method", e)
|
|
100
|
+
}
|
|
101
|
+
return null
|
|
102
|
+
}
|
|
103
|
+
}
|
|
@@ -18,11 +18,22 @@ class SpallaPlayerModule(reactContext: ReactApplicationContext) :
|
|
|
18
18
|
LifecycleEventListener {
|
|
19
19
|
private val _reactContext: ReactApplicationContext
|
|
20
20
|
|
|
21
|
+
companion object {
|
|
22
|
+
const val NAME = "RNSpallaPlayer"
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
|
|
21
26
|
init {
|
|
22
27
|
reactContext.addLifecycleEventListener(this)
|
|
23
28
|
_reactContext = reactContext
|
|
24
29
|
}
|
|
25
30
|
|
|
31
|
+
private fun isFabric(): Boolean {
|
|
32
|
+
val uiManager = UIManagerHelper.getUIManager(this._reactContext, UIManagerType.FABRIC)
|
|
33
|
+
// In Fabric, the UIManager is an instance of "FabricUIManager"
|
|
34
|
+
return uiManager?.javaClass?.simpleName == "FabricUIManager"
|
|
35
|
+
}
|
|
36
|
+
|
|
26
37
|
override fun getName(): String {
|
|
27
38
|
return "RNSpallaPlayer"
|
|
28
39
|
}
|
|
@@ -39,12 +50,12 @@ class SpallaPlayerModule(reactContext: ReactApplicationContext) :
|
|
|
39
50
|
|
|
40
51
|
@ReactMethod
|
|
41
52
|
fun play(tag: Int) {
|
|
42
|
-
if (
|
|
53
|
+
if (isFabric()) {
|
|
43
54
|
val uiManager = UIManagerHelper.getUIManager(_reactContext, UIManagerType.FABRIC)
|
|
44
55
|
if (uiManager is UIManager) {
|
|
45
56
|
uiManager.resolveView(tag)?.let { view ->
|
|
46
|
-
if (view is
|
|
47
|
-
view.
|
|
57
|
+
if (view is SpallaPlayerView) {
|
|
58
|
+
view.play()
|
|
48
59
|
} else {
|
|
49
60
|
throw ClassCastException(
|
|
50
61
|
"Cannot play: view with tag #$tag is not a SpallaPlayerView"
|
|
@@ -57,8 +68,8 @@ class SpallaPlayerModule(reactContext: ReactApplicationContext) :
|
|
|
57
68
|
_reactContext.getNativeModule(UIManagerModule::class.java)
|
|
58
69
|
uiManager?.prependUIBlock { nativeViewHierarchyManager: NativeViewHierarchyManager ->
|
|
59
70
|
val playerView = nativeViewHierarchyManager.resolveView(tag)
|
|
60
|
-
if (playerView is
|
|
61
|
-
playerView.
|
|
71
|
+
if (playerView is SpallaPlayerView) {
|
|
72
|
+
playerView.play()
|
|
62
73
|
} else {
|
|
63
74
|
throw ClassCastException(
|
|
64
75
|
String.format(
|
|
@@ -73,12 +84,12 @@ class SpallaPlayerModule(reactContext: ReactApplicationContext) :
|
|
|
73
84
|
|
|
74
85
|
@ReactMethod
|
|
75
86
|
fun pause(tag: Int) {
|
|
76
|
-
if (
|
|
87
|
+
if (isFabric()) {
|
|
77
88
|
val uiManager = UIManagerHelper.getUIManager(_reactContext, UIManagerType.FABRIC)
|
|
78
89
|
if (uiManager is UIManager) {
|
|
79
90
|
uiManager.resolveView(tag)?.let { view ->
|
|
80
|
-
if (view is
|
|
81
|
-
view.
|
|
91
|
+
if (view is SpallaPlayerView) {
|
|
92
|
+
view.pause()
|
|
82
93
|
} else {
|
|
83
94
|
throw ClassCastException(
|
|
84
95
|
"Cannot pause: view with tag #$tag is not a SpallaPlayerView"
|
|
@@ -91,8 +102,8 @@ class SpallaPlayerModule(reactContext: ReactApplicationContext) :
|
|
|
91
102
|
_reactContext.getNativeModule(UIManagerModule::class.java)
|
|
92
103
|
uiManager?.prependUIBlock { nativeViewHierarchyManager: NativeViewHierarchyManager ->
|
|
93
104
|
val playerView = nativeViewHierarchyManager.resolveView(tag)
|
|
94
|
-
if (playerView is
|
|
95
|
-
playerView.
|
|
105
|
+
if (playerView is SpallaPlayerView) {
|
|
106
|
+
playerView.pause()
|
|
96
107
|
} else {
|
|
97
108
|
throw ClassCastException(
|
|
98
109
|
String.format(
|
|
@@ -112,8 +123,8 @@ class SpallaPlayerModule(reactContext: ReactApplicationContext) :
|
|
|
112
123
|
_reactContext.getNativeModule(UIManagerModule::class.java)!!
|
|
113
124
|
.prependUIBlock { nativeViewHierarchyManager: NativeViewHierarchyManager ->
|
|
114
125
|
val playerView = nativeViewHierarchyManager.resolveView(tag)
|
|
115
|
-
if (playerView is
|
|
116
|
-
playerView.
|
|
126
|
+
if (playerView is SpallaPlayerView) {
|
|
127
|
+
playerView.seekTo(time)
|
|
117
128
|
} else {
|
|
118
129
|
throw ClassCastException(
|
|
119
130
|
String.format(
|
|
@@ -130,8 +141,8 @@ class SpallaPlayerModule(reactContext: ReactApplicationContext) :
|
|
|
130
141
|
_reactContext.getNativeModule(UIManagerModule::class.java)!!
|
|
131
142
|
.prependUIBlock { nativeViewHierarchyManager: NativeViewHierarchyManager ->
|
|
132
143
|
val playerView = nativeViewHierarchyManager.resolveView(tag)
|
|
133
|
-
if (playerView is
|
|
134
|
-
playerView.
|
|
144
|
+
if (playerView is SpallaPlayerView) {
|
|
145
|
+
playerView.selectSubtitle(subtitle)
|
|
135
146
|
} else {
|
|
136
147
|
throw ClassCastException(
|
|
137
148
|
String.format(
|
|
@@ -148,8 +159,8 @@ class SpallaPlayerModule(reactContext: ReactApplicationContext) :
|
|
|
148
159
|
_reactContext.getNativeModule(UIManagerModule::class.java)!!
|
|
149
160
|
.prependUIBlock { nativeViewHierarchyManager: NativeViewHierarchyManager ->
|
|
150
161
|
val playerView = nativeViewHierarchyManager.resolveView(tag)
|
|
151
|
-
if (playerView is
|
|
152
|
-
playerView.
|
|
162
|
+
if (playerView is SpallaPlayerView) {
|
|
163
|
+
playerView.selectPlaybackRate(rate)
|
|
153
164
|
} else {
|
|
154
165
|
throw ClassCastException(
|
|
155
166
|
String.format(
|
|
@@ -163,12 +174,12 @@ class SpallaPlayerModule(reactContext: ReactApplicationContext) :
|
|
|
163
174
|
|
|
164
175
|
@ReactMethod
|
|
165
176
|
fun unmount(tag: Int) {
|
|
166
|
-
if (
|
|
177
|
+
if (isFabric()) {
|
|
167
178
|
val uiManager = UIManagerHelper.getUIManager(_reactContext, UIManagerType.FABRIC)
|
|
168
179
|
if (uiManager is UIManager) {
|
|
169
180
|
uiManager.resolveView(tag)?.let { view ->
|
|
170
|
-
if (view is
|
|
171
|
-
view.
|
|
181
|
+
if (view is SpallaPlayerView) {
|
|
182
|
+
view.pause()
|
|
172
183
|
}
|
|
173
184
|
}
|
|
174
185
|
}
|
|
@@ -177,8 +188,8 @@ class SpallaPlayerModule(reactContext: ReactApplicationContext) :
|
|
|
177
188
|
_reactContext.getNativeModule(UIManagerModule::class.java)
|
|
178
189
|
uiManager?.prependUIBlock { nativeViewHierarchyManager: NativeViewHierarchyManager ->
|
|
179
190
|
val playerView = nativeViewHierarchyManager.resolveView(tag)
|
|
180
|
-
if (playerView is
|
|
181
|
-
playerView.
|
|
191
|
+
if (playerView is SpallaPlayerView) {
|
|
192
|
+
playerView.pause()
|
|
182
193
|
}
|
|
183
194
|
}
|
|
184
195
|
}
|
|
@@ -3,16 +3,30 @@ package com.spallaplayer
|
|
|
3
3
|
import com.facebook.react.ReactPackage
|
|
4
4
|
import com.facebook.react.bridge.NativeModule
|
|
5
5
|
import com.facebook.react.bridge.ReactApplicationContext
|
|
6
|
+
import com.facebook.react.module.model.ReactModuleInfo
|
|
7
|
+
import com.facebook.react.module.model.ReactModuleInfoProvider
|
|
6
8
|
import com.facebook.react.uimanager.ViewManager
|
|
7
9
|
import com.spallaplayer.components.RNGoogleCastButtonManager
|
|
10
|
+
import java.util.ArrayList
|
|
8
11
|
|
|
12
|
+
class SpallaPlayerViewPackage : ReactPackage {
|
|
13
|
+
override fun createViewManagers(reactContext: ReactApplicationContext): List<ViewManager<*, *>> {
|
|
14
|
+
val viewManagers: MutableList<ViewManager<*, *>> = ArrayList()
|
|
15
|
+
viewManagers.add(SpallaPlayerViewManager())
|
|
16
|
+
viewManagers.add(RNGoogleCastButtonManager())
|
|
17
|
+
return viewManagers
|
|
18
|
+
}
|
|
9
19
|
|
|
10
|
-
|
|
20
|
+
@Deprecated("Migrate to [BaseReactPackage] and implement [getModule] instead.")
|
|
11
21
|
override fun createNativeModules(reactContext: ReactApplicationContext): List<NativeModule> {
|
|
12
|
-
return listOf(
|
|
22
|
+
return listOf(SpallaPlayerModuleFabric(reactContext))
|
|
13
23
|
}
|
|
14
24
|
|
|
15
|
-
override fun
|
|
16
|
-
return
|
|
25
|
+
override fun getModule(name: String, reactContext: ReactApplicationContext): NativeModule? {
|
|
26
|
+
return when (name) {
|
|
27
|
+
SpallaPlayerModule.NAME -> SpallaPlayerModuleFabric(reactContext)
|
|
28
|
+
else -> null
|
|
29
|
+
}
|
|
17
30
|
}
|
|
31
|
+
|
|
18
32
|
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
package com.spallaplayer
|
|
2
|
+
|
|
3
|
+
import android.content.Context
|
|
4
|
+
import android.util.AttributeSet
|
|
5
|
+
import android.view.View
|
|
6
|
+
|
|
7
|
+
class SpallaPlayerView : View {
|
|
8
|
+
constructor(context: Context?) : super(context)
|
|
9
|
+
constructor(context: Context?, attrs: AttributeSet?) : super(context, attrs)
|
|
10
|
+
constructor(context: Context?, attrs: AttributeSet?, defStyleAttr: Int) : super(
|
|
11
|
+
context,
|
|
12
|
+
attrs,
|
|
13
|
+
defStyleAttr
|
|
14
|
+
)
|
|
15
|
+
}
|