react-native-spalla-player 0.13.2 → 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 +33 -39
- 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/package.json
CHANGED
|
@@ -1,21 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-spalla-player",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Spalla
|
|
5
|
-
"
|
|
6
|
-
"
|
|
7
|
-
"module": "./lib/module/index.js",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Spalla Player for React Native",
|
|
5
|
+
"main": "./lib/module/index.js",
|
|
6
|
+
"types": "./lib/typescript/src/index.d.ts",
|
|
8
7
|
"exports": {
|
|
9
8
|
".": {
|
|
10
|
-
"
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
"types": "./lib/typescript/commonjs/src/index.d.ts",
|
|
16
|
-
"default": "./lib/commonjs/index.js"
|
|
17
|
-
}
|
|
18
|
-
}
|
|
9
|
+
"source": "./src/index.tsx",
|
|
10
|
+
"types": "./lib/typescript/src/index.d.ts",
|
|
11
|
+
"default": "./lib/module/index.js"
|
|
12
|
+
},
|
|
13
|
+
"./package.json": "./package.json"
|
|
19
14
|
},
|
|
20
15
|
"files": [
|
|
21
16
|
"src",
|
|
@@ -24,6 +19,7 @@
|
|
|
24
19
|
"ios",
|
|
25
20
|
"cpp",
|
|
26
21
|
"*.podspec",
|
|
22
|
+
"react-native.config.js",
|
|
27
23
|
"!ios/build",
|
|
28
24
|
"!android/build",
|
|
29
25
|
"!android/gradle",
|
|
@@ -37,12 +33,12 @@
|
|
|
37
33
|
],
|
|
38
34
|
"scripts": {
|
|
39
35
|
"example": "yarn workspace react-native-spalla-player-example",
|
|
40
|
-
"test": "jest",
|
|
41
|
-
"typecheck": "tsc",
|
|
42
|
-
"lint": "eslint \"**/*.{js,ts,tsx}\"",
|
|
43
36
|
"clean": "del-cli android/build example/android/build example/android/app/build example/ios/build lib",
|
|
44
37
|
"prepare": "bob build",
|
|
45
|
-
"
|
|
38
|
+
"typecheck": "tsc",
|
|
39
|
+
"lint": "eslint \"**/*.{js,ts,tsx}\"",
|
|
40
|
+
"test": "jest",
|
|
41
|
+
"release": "release-it --only-version"
|
|
46
42
|
},
|
|
47
43
|
"keywords": [
|
|
48
44
|
"react-native",
|
|
@@ -51,40 +47,41 @@
|
|
|
51
47
|
],
|
|
52
48
|
"repository": {
|
|
53
49
|
"type": "git",
|
|
54
|
-
"url": "git+https://github.com/
|
|
50
|
+
"url": "git+https://github.com/rojas/react-native-spalla-player.git"
|
|
55
51
|
},
|
|
56
52
|
"author": "Rogerio Shimizu <roja@bunker79.com> (https://github.com/rojas)",
|
|
57
53
|
"license": "MIT",
|
|
58
54
|
"bugs": {
|
|
59
|
-
"url": "https://github.com/
|
|
55
|
+
"url": "https://github.com/rojas/react-native-spalla-player/issues"
|
|
60
56
|
},
|
|
61
|
-
"homepage": "https://github.com/
|
|
57
|
+
"homepage": "https://github.com/rojas/react-native-spalla-player#readme",
|
|
62
58
|
"publishConfig": {
|
|
63
59
|
"registry": "https://registry.npmjs.org/"
|
|
64
60
|
},
|
|
65
61
|
"devDependencies": {
|
|
66
|
-
"@commitlint/config-conventional": "^
|
|
67
|
-
"@
|
|
68
|
-
"@
|
|
69
|
-
"@
|
|
70
|
-
"@
|
|
71
|
-
"@
|
|
72
|
-
"
|
|
73
|
-
"
|
|
74
|
-
"
|
|
75
|
-
"
|
|
76
|
-
"
|
|
62
|
+
"@commitlint/config-conventional": "^19.8.1",
|
|
63
|
+
"@eslint/compat": "^1.3.2",
|
|
64
|
+
"@eslint/eslintrc": "^3.3.1",
|
|
65
|
+
"@eslint/js": "^9.35.0",
|
|
66
|
+
"@react-native/babel-preset": "0.83.0",
|
|
67
|
+
"@react-native/eslint-config": "0.83.0",
|
|
68
|
+
"@release-it/conventional-changelog": "^10.0.1",
|
|
69
|
+
"@types/jest": "^29.5.14",
|
|
70
|
+
"@types/react": "^19.2.0",
|
|
71
|
+
"commitlint": "^19.8.1",
|
|
72
|
+
"del-cli": "^6.0.0",
|
|
73
|
+
"eslint": "^9.35.0",
|
|
74
|
+
"eslint-config-prettier": "^10.1.8",
|
|
75
|
+
"eslint-plugin-prettier": "^5.5.4",
|
|
77
76
|
"jest": "^29.7.0",
|
|
78
|
-
"
|
|
79
|
-
"
|
|
80
|
-
"react
|
|
81
|
-
"react-native
|
|
82
|
-
"
|
|
83
|
-
"
|
|
84
|
-
"
|
|
85
|
-
|
|
86
|
-
"resolutions": {
|
|
87
|
-
"@types/react": "^18.2.44"
|
|
77
|
+
"lefthook": "^2.0.3",
|
|
78
|
+
"prettier": "^2.8.8",
|
|
79
|
+
"react": "19.2.0",
|
|
80
|
+
"react-native": "0.83.0",
|
|
81
|
+
"react-native-builder-bob": "0.38.0",
|
|
82
|
+
"release-it": "^19.0.4",
|
|
83
|
+
"turbo": "^2.5.6",
|
|
84
|
+
"typescript": "^5.9.2"
|
|
88
85
|
},
|
|
89
86
|
"peerDependencies": {
|
|
90
87
|
"react": "*",
|
|
@@ -93,7 +90,48 @@
|
|
|
93
90
|
"workspaces": [
|
|
94
91
|
"example"
|
|
95
92
|
],
|
|
96
|
-
"packageManager": "yarn@
|
|
93
|
+
"packageManager": "yarn@4.11.0",
|
|
94
|
+
"react-native-builder-bob": {
|
|
95
|
+
"source": "src",
|
|
96
|
+
"output": "lib",
|
|
97
|
+
"targets": [
|
|
98
|
+
[
|
|
99
|
+
"module",
|
|
100
|
+
{
|
|
101
|
+
"esm": true
|
|
102
|
+
}
|
|
103
|
+
],
|
|
104
|
+
[
|
|
105
|
+
"typescript",
|
|
106
|
+
{
|
|
107
|
+
"project": "tsconfig.build.json"
|
|
108
|
+
}
|
|
109
|
+
]
|
|
110
|
+
]
|
|
111
|
+
},
|
|
112
|
+
"codegenConfig": {
|
|
113
|
+
"name": "SpallaPlayerViewSpec",
|
|
114
|
+
"type": "all",
|
|
115
|
+
"jsSrcsDir": "src",
|
|
116
|
+
"android": {
|
|
117
|
+
"javaPackageName": "com.spallaplayer"
|
|
118
|
+
},
|
|
119
|
+
"ios": {
|
|
120
|
+
"componentProvider": {
|
|
121
|
+
"SpallaPlayerView": "SpallaPlayerView"
|
|
122
|
+
},
|
|
123
|
+
"modulesProvider": {
|
|
124
|
+
"SpallaPlayerModule": "SpallaPlayerModule"
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
},
|
|
128
|
+
"prettier": {
|
|
129
|
+
"quoteProps": "consistent",
|
|
130
|
+
"singleQuote": true,
|
|
131
|
+
"tabWidth": 2,
|
|
132
|
+
"trailingComma": "es5",
|
|
133
|
+
"useTabs": false
|
|
134
|
+
},
|
|
97
135
|
"jest": {
|
|
98
136
|
"preset": "react-native",
|
|
99
137
|
"modulePathIgnorePatterns": [
|
|
@@ -119,69 +157,21 @@
|
|
|
119
157
|
},
|
|
120
158
|
"plugins": {
|
|
121
159
|
"@release-it/conventional-changelog": {
|
|
122
|
-
"preset":
|
|
123
|
-
|
|
124
|
-
}
|
|
125
|
-
},
|
|
126
|
-
"eslintConfig": {
|
|
127
|
-
"root": true,
|
|
128
|
-
"extends": [
|
|
129
|
-
"@react-native",
|
|
130
|
-
"prettier"
|
|
131
|
-
],
|
|
132
|
-
"rules": {
|
|
133
|
-
"react/react-in-jsx-scope": "off",
|
|
134
|
-
"prettier/prettier": [
|
|
135
|
-
"error",
|
|
136
|
-
{
|
|
137
|
-
"quoteProps": "consistent",
|
|
138
|
-
"singleQuote": true,
|
|
139
|
-
"tabWidth": 2,
|
|
140
|
-
"trailingComma": "es5",
|
|
141
|
-
"useTabs": false
|
|
160
|
+
"preset": {
|
|
161
|
+
"name": "angular"
|
|
142
162
|
}
|
|
143
|
-
|
|
163
|
+
}
|
|
144
164
|
}
|
|
145
165
|
},
|
|
146
|
-
"eslintIgnore": [
|
|
147
|
-
"node_modules/",
|
|
148
|
-
"lib/"
|
|
149
|
-
],
|
|
150
|
-
"prettier": {
|
|
151
|
-
"quoteProps": "consistent",
|
|
152
|
-
"singleQuote": true,
|
|
153
|
-
"tabWidth": 2,
|
|
154
|
-
"trailingComma": "es5",
|
|
155
|
-
"useTabs": false
|
|
156
|
-
},
|
|
157
|
-
"react-native-builder-bob": {
|
|
158
|
-
"source": "src",
|
|
159
|
-
"output": "lib",
|
|
160
|
-
"targets": [
|
|
161
|
-
[
|
|
162
|
-
"commonjs",
|
|
163
|
-
{
|
|
164
|
-
"esm": true
|
|
165
|
-
}
|
|
166
|
-
],
|
|
167
|
-
[
|
|
168
|
-
"module",
|
|
169
|
-
{
|
|
170
|
-
"esm": true
|
|
171
|
-
}
|
|
172
|
-
],
|
|
173
|
-
[
|
|
174
|
-
"typescript",
|
|
175
|
-
{
|
|
176
|
-
"project": "tsconfig.build.json",
|
|
177
|
-
"esm": true
|
|
178
|
-
}
|
|
179
|
-
]
|
|
180
|
-
]
|
|
181
|
-
},
|
|
182
166
|
"create-react-native-library": {
|
|
183
|
-
"type": "view
|
|
184
|
-
"languages": "kotlin-
|
|
185
|
-
"
|
|
167
|
+
"type": "fabric-view",
|
|
168
|
+
"languages": "kotlin-objc",
|
|
169
|
+
"tools": [
|
|
170
|
+
"eslint",
|
|
171
|
+
"jest",
|
|
172
|
+
"lefthook",
|
|
173
|
+
"release-it"
|
|
174
|
+
],
|
|
175
|
+
"version": "0.56.0"
|
|
186
176
|
}
|
|
187
177
|
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { TurboModule, CodegenTypes } from 'react-native';
|
|
2
|
+
import { TurboModuleRegistry } from 'react-native';
|
|
3
|
+
|
|
4
|
+
export interface Spec extends TurboModule {
|
|
5
|
+
play(tag: CodegenTypes.Int32): void;
|
|
6
|
+
pause(tag: CodegenTypes.Int32): void;
|
|
7
|
+
seekTo(tag: CodegenTypes.Int32, time: number): void;
|
|
8
|
+
selectSubtitle(tag: CodegenTypes.Int32, subtitle: string | null): void;
|
|
9
|
+
selectPlaybackRate(tag: CodegenTypes.Int32, rate: number): void;
|
|
10
|
+
unmount(tag: CodegenTypes.Int32): void;
|
|
11
|
+
initialize(token: string, applicationId: string): void;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export default TurboModuleRegistry.getEnforcing<Spec>('SpallaPlayerModule');
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import {
|
|
2
|
+
codegenNativeComponent,
|
|
3
|
+
type ViewProps,
|
|
4
|
+
type CodegenTypes,
|
|
5
|
+
type HostComponent,
|
|
6
|
+
codegenNativeCommands,
|
|
7
|
+
} from 'react-native';
|
|
8
|
+
|
|
9
|
+
// Define a single comprehensive event payload interface
|
|
10
|
+
interface PlayerEventPayload {
|
|
11
|
+
event: string;
|
|
12
|
+
time?: CodegenTypes.Double;
|
|
13
|
+
duration?: CodegenTypes.Double;
|
|
14
|
+
isLive?: boolean;
|
|
15
|
+
subtitles?: string[];
|
|
16
|
+
subtitle?: string;
|
|
17
|
+
rate?: CodegenTypes.Float;
|
|
18
|
+
message?: string;
|
|
19
|
+
error?: string;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface NativeProps extends ViewProps {
|
|
23
|
+
contentId?: string;
|
|
24
|
+
muted?: boolean;
|
|
25
|
+
startTime?: CodegenTypes.Double;
|
|
26
|
+
subtitle?: string | null;
|
|
27
|
+
playbackRate?: CodegenTypes.Float;
|
|
28
|
+
hideUI?: boolean;
|
|
29
|
+
onPlayerEvent?: CodegenTypes.BubblingEventHandler<PlayerEventPayload>;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export interface NativeCommands {
|
|
33
|
+
play: (viewRef: React.ElementRef<HostComponent<any>>) => void;
|
|
34
|
+
pause: (viewRef: React.ElementRef<HostComponent<any>>) => void;
|
|
35
|
+
seekTo: (
|
|
36
|
+
viewRef: React.ElementRef<HostComponent<any>>,
|
|
37
|
+
time: CodegenTypes.Double
|
|
38
|
+
) => void;
|
|
39
|
+
selectSubtitle: (
|
|
40
|
+
viewRef: React.ElementRef<HostComponent<any>>,
|
|
41
|
+
subtitle: string | null
|
|
42
|
+
) => void;
|
|
43
|
+
selectPlaybackRate: (
|
|
44
|
+
viewRef: React.ElementRef<HostComponent<any>>,
|
|
45
|
+
rate: CodegenTypes.Float
|
|
46
|
+
) => void;
|
|
47
|
+
unmount: (viewRef: React.ElementRef<HostComponent<any>>) => void;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export const Commands: NativeCommands = codegenNativeCommands<NativeCommands>({
|
|
51
|
+
supportedCommands: [
|
|
52
|
+
'play',
|
|
53
|
+
'pause',
|
|
54
|
+
'seekTo',
|
|
55
|
+
'selectSubtitle',
|
|
56
|
+
'selectPlaybackRate',
|
|
57
|
+
'unmount',
|
|
58
|
+
],
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
export default codegenNativeComponent<NativeProps>('SpallaPlayerView');
|
package/src/index.tsx
CHANGED
|
@@ -1,28 +1,22 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
type ViewStyle,
|
|
5
|
-
NativeModules,
|
|
6
|
-
findNodeHandle,
|
|
7
|
-
} from 'react-native';
|
|
2
|
+
import { type ViewStyle } from 'react-native';
|
|
3
|
+
import { Commands } from './SpallaPlayerViewNativeComponent';
|
|
8
4
|
|
|
9
|
-
|
|
5
|
+
// Import the appropriate component based on architecture
|
|
6
|
+
const isFabricEnabled = (global as any)?.nativeFabricUIManager != null;
|
|
10
7
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
startTime: number;
|
|
15
|
-
subtitle?: String | null;
|
|
16
|
-
playbackRate?: allowedPlaybackRates;
|
|
17
|
-
hideUI?: boolean;
|
|
18
|
-
ref?: (ref: any) => void;
|
|
19
|
-
}
|
|
8
|
+
const RNSpallaPlayer = isFabricEnabled
|
|
9
|
+
? require('./SpallaPlayerViewNativeComponent').default
|
|
10
|
+
: require('react-native').requireNativeComponent('RNSpallaPlayer');
|
|
20
11
|
|
|
21
|
-
|
|
22
|
-
|
|
12
|
+
// Import the appropriate module
|
|
13
|
+
const RNSpallaPlayerModule = isFabricEnabled
|
|
14
|
+
? require('./NativeSpallaPlayerModule').default
|
|
15
|
+
: require('react-native').NativeModules.RNSpallaPlayer;
|
|
23
16
|
|
|
24
|
-
|
|
17
|
+
type allowedPlaybackRates = 0.25 | 0.5 | 1.0 | 1.25 | 1.5 | 2.0;
|
|
25
18
|
|
|
19
|
+
// Event interfaces (keep these as they are)
|
|
26
20
|
interface PlayerEventTimeUpdate {
|
|
27
21
|
event: 'timeUpdate';
|
|
28
22
|
time: number;
|
|
@@ -76,11 +70,11 @@ interface Props {
|
|
|
76
70
|
autoplay?: boolean;
|
|
77
71
|
startTime?: number;
|
|
78
72
|
subtitle?: String | null;
|
|
79
|
-
playbackRate?:
|
|
73
|
+
playbackRate?: allowedPlaybackRates;
|
|
80
74
|
onPlayerEvent?: (event: {
|
|
81
75
|
nativeEvent:
|
|
82
|
-
| PlayerEventTimeUpdate
|
|
83
76
|
| PlayerEvent
|
|
77
|
+
| PlayerEventTimeUpdate
|
|
84
78
|
| PlayerEventDurationUpdate
|
|
85
79
|
| PlayerEventSubtitlesAvailable
|
|
86
80
|
| PlayerEventSubtitleSelected
|
|
@@ -89,71 +83,66 @@ interface Props {
|
|
|
89
83
|
}) => void;
|
|
90
84
|
}
|
|
91
85
|
|
|
92
|
-
export const
|
|
93
|
-
|
|
94
|
-
RNSpallaPlayerModule.play(handle);
|
|
95
|
-
};
|
|
96
|
-
|
|
97
|
-
export const pause = (ref: any) => {
|
|
98
|
-
const handle = findNodeHandle(ref);
|
|
99
|
-
RNSpallaPlayerModule.pause(handle);
|
|
100
|
-
};
|
|
101
|
-
|
|
102
|
-
export const seekTo = (ref: any, time: number) => {
|
|
103
|
-
const handle = findNodeHandle(ref);
|
|
104
|
-
RNSpallaPlayerModule.seekTo(handle, time);
|
|
86
|
+
export const initialize = (token: string, applicationId: string | null) => {
|
|
87
|
+
RNSpallaPlayerModule.initialize(token, applicationId);
|
|
105
88
|
};
|
|
106
89
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
_setRef = (ref: any) => {
|
|
113
|
-
this._player = ref;
|
|
114
|
-
};
|
|
115
|
-
|
|
116
|
-
render() {
|
|
117
|
-
const { style, startTime, playbackRate, hideUI } = this.props;
|
|
118
|
-
|
|
119
|
-
return (
|
|
120
|
-
<RNSpallaPlayer
|
|
121
|
-
{...this.props}
|
|
122
|
-
ref={this._setRef}
|
|
123
|
-
style={style}
|
|
124
|
-
startTime={startTime ?? 0}
|
|
125
|
-
playbackRate={playbackRate ?? 1.0}
|
|
126
|
-
hideUI={hideUI ?? false}
|
|
127
|
-
>
|
|
128
|
-
{this.props.children}
|
|
129
|
-
</RNSpallaPlayer>
|
|
130
|
-
);
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
play = () => {
|
|
134
|
-
const handle = findNodeHandle(this._player);
|
|
135
|
-
RNSpallaPlayerModule.play(handle);
|
|
136
|
-
};
|
|
137
|
-
|
|
138
|
-
pause = () => {
|
|
139
|
-
const handle = findNodeHandle(this._player);
|
|
140
|
-
RNSpallaPlayerModule.pause(handle);
|
|
141
|
-
};
|
|
142
|
-
|
|
143
|
-
seekTo = (time: number) => {
|
|
144
|
-
const handle = findNodeHandle(this._player);
|
|
145
|
-
RNSpallaPlayerModule.seekTo(handle, time);
|
|
146
|
-
};
|
|
147
|
-
|
|
148
|
-
componentWillUnmount() {
|
|
149
|
-
const handle = findNodeHandle(this._player);
|
|
150
|
-
RNSpallaPlayerModule.unmount(handle);
|
|
151
|
-
}
|
|
90
|
+
export interface SpallaPlayerRef {
|
|
91
|
+
play(): void;
|
|
92
|
+
pause(): void;
|
|
93
|
+
seekTo(time: number): void;
|
|
152
94
|
}
|
|
153
95
|
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
96
|
+
const SpallaPlayer = React.forwardRef<SpallaPlayerRef, Props>((props, ref) => {
|
|
97
|
+
const playerRef = React.useRef(null);
|
|
98
|
+
|
|
99
|
+
React.useImperativeHandle(
|
|
100
|
+
ref,
|
|
101
|
+
() => ({
|
|
102
|
+
play: () => {
|
|
103
|
+
if (playerRef.current) {
|
|
104
|
+
Commands.play(playerRef.current);
|
|
105
|
+
}
|
|
106
|
+
},
|
|
107
|
+
pause: () => {
|
|
108
|
+
console.log('Calling pause command');
|
|
109
|
+
if (playerRef.current) {
|
|
110
|
+
Commands.pause(playerRef.current);
|
|
111
|
+
}
|
|
112
|
+
},
|
|
113
|
+
seekTo: (time: number) => {
|
|
114
|
+
if (playerRef.current) {
|
|
115
|
+
Commands.seekTo(playerRef.current, time);
|
|
116
|
+
}
|
|
117
|
+
},
|
|
118
|
+
}),
|
|
119
|
+
[]
|
|
120
|
+
);
|
|
121
|
+
|
|
122
|
+
React.useEffect(() => {
|
|
123
|
+
const currentRef = playerRef.current;
|
|
124
|
+
return () => {
|
|
125
|
+
if (currentRef) {
|
|
126
|
+
Commands.unmount(currentRef);
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
}, []);
|
|
130
|
+
|
|
131
|
+
return (
|
|
132
|
+
<RNSpallaPlayer
|
|
133
|
+
{...props}
|
|
134
|
+
ref={playerRef}
|
|
135
|
+
style={props.style}
|
|
136
|
+
startTime={props.startTime ?? 0}
|
|
137
|
+
playbackRate={props.playbackRate ?? 1.0}
|
|
138
|
+
hideUI={props.hideUI ?? false}
|
|
139
|
+
>
|
|
140
|
+
{props.children}
|
|
141
|
+
</RNSpallaPlayer>
|
|
142
|
+
);
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
SpallaPlayer.displayName = 'SpallaPlayer';
|
|
157
146
|
|
|
158
147
|
export default SpallaPlayer;
|
|
159
148
|
export { default as SpallaCastButton } from './components/CastButton';
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
package com.spallaplayer
|
|
2
|
-
|
|
3
|
-
import android.content.Context
|
|
4
|
-
import android.widget.FrameLayout
|
|
5
|
-
import com.spalla.sdk.android.core.player.view.SpallaPlayerView
|
|
6
|
-
import android.view.ViewGroup;
|
|
7
|
-
|
|
8
|
-
class SpallaPlayerContainerView(context: Context) : ViewGroup(context) {
|
|
9
|
-
val spallaPlayerView: SpallaPlayerView = SpallaPlayerView(context)
|
|
10
|
-
|
|
11
|
-
init {
|
|
12
|
-
addView(spallaPlayerView) // Add SpallaPlayerView as a child of this container
|
|
13
|
-
// You might need to set layout params for spallaPlayerView here
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
override fun onLayout(changed: Boolean, l: Int, t: Int, r: Int, b: Int) {
|
|
17
|
-
for (i in 0 until childCount) {
|
|
18
|
-
val child = getChildAt(i)
|
|
19
|
-
child.layout(0, 0, width, height)
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
|
|
24
|
-
val width = MeasureSpec.getSize(widthMeasureSpec)
|
|
25
|
-
val height = MeasureSpec.getSize(heightMeasureSpec)
|
|
26
|
-
for (i in 0 until childCount) {
|
|
27
|
-
val child = getChildAt(i)
|
|
28
|
-
child.measure(
|
|
29
|
-
MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY),
|
|
30
|
-
MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY)
|
|
31
|
-
)
|
|
32
|
-
}
|
|
33
|
-
setMeasuredDimension(width, height)
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
}
|
package/ios/RNSpallaPlayer.m
DELETED
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
#import <React/RCTViewManager.h>
|
|
2
|
-
#import <React/RCTUIManager.h>
|
|
3
|
-
#import <react_native_spalla_player-Swift.h>
|
|
4
|
-
@import SpallaSDK;
|
|
5
|
-
|
|
6
|
-
@interface RCT_EXTERN_MODULE(RNSpallaPlayer, RCTViewManager)
|
|
7
|
-
|
|
8
|
-
RCT_EXPORT_VIEW_PROPERTY(contentId, NSString)
|
|
9
|
-
|
|
10
|
-
RCT_EXPORT_VIEW_PROPERTY(muted, BOOL)
|
|
11
|
-
|
|
12
|
-
RCT_EXPORT_VIEW_PROPERTY(hideUI, BOOL)
|
|
13
|
-
|
|
14
|
-
RCT_EXPORT_VIEW_PROPERTY(startTime, NSNumber)
|
|
15
|
-
|
|
16
|
-
RCT_EXPORT_VIEW_PROPERTY(subtitle, NSString)
|
|
17
|
-
|
|
18
|
-
RCT_EXPORT_VIEW_PROPERTY(playbackRate, NSNumber)
|
|
19
|
-
|
|
20
|
-
RCT_EXPORT_METHOD(play: (nonnull NSNumber *) reactTag {
|
|
21
|
-
|
|
22
|
-
[self.bridge.uiManager addUIBlock:^(RCTUIManager *uiManager, NSDictionary<NSNumber *,UIView *> *viewRegistry) {
|
|
23
|
-
UIView *view = viewRegistry[reactTag];
|
|
24
|
-
if (!view || ![view isKindOfClass:[SpallaPlayerWrapper class]]) {
|
|
25
|
-
RCTLogError(@"Cannot find NativeView with tag #%@", reactTag);
|
|
26
|
-
return;
|
|
27
|
-
} else {
|
|
28
|
-
[(SpallaPlayerWrapper *)view play];
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
}];
|
|
32
|
-
})
|
|
33
|
-
|
|
34
|
-
RCT_EXPORT_METHOD(pause: (nonnull NSNumber *) reactTag {
|
|
35
|
-
[self.bridge.uiManager addUIBlock:^(RCTUIManager *uiManager, NSDictionary<NSNumber *,UIView *> *viewRegistry) {
|
|
36
|
-
UIView *view = viewRegistry[reactTag];
|
|
37
|
-
if (!view || ![view isKindOfClass:[SpallaPlayerWrapper class]]) {
|
|
38
|
-
RCTLogError(@"Cannot find NativeView with tag #%@", reactTag);
|
|
39
|
-
return;
|
|
40
|
-
} else {
|
|
41
|
-
[(SpallaPlayerWrapper *)view pause];
|
|
42
|
-
}
|
|
43
|
-
}];
|
|
44
|
-
})
|
|
45
|
-
|
|
46
|
-
RCT_EXPORT_METHOD(seekTo: (nonnull NSNumber *) reactTag time:(float)time) {
|
|
47
|
-
[self.bridge.uiManager addUIBlock:^(RCTUIManager *uiManager, NSDictionary<NSNumber *,UIView *> *viewRegistry) {
|
|
48
|
-
UIView *view = viewRegistry[reactTag];
|
|
49
|
-
if (!view || ![view isKindOfClass:[SpallaPlayerWrapper class]]) {
|
|
50
|
-
RCTLogError(@"Cannot find NativeView with tag #%@", reactTag);
|
|
51
|
-
return;
|
|
52
|
-
} else {
|
|
53
|
-
[(SpallaPlayerWrapper *)view seekToTime: time];
|
|
54
|
-
}
|
|
55
|
-
}];
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
RCT_EXPORT_METHOD(selectSubtitle: (nonnull NSNumber *) reactTag subtitle:(NSString *)subtitle) {
|
|
59
|
-
[self.bridge.uiManager addUIBlock:^(RCTUIManager *uiManager, NSDictionary<NSNumber *,UIView *> *viewRegistry) {
|
|
60
|
-
UIView *view = viewRegistry[reactTag];
|
|
61
|
-
if (!view || ![view isKindOfClass:[SpallaPlayerWrapper class]]) {
|
|
62
|
-
RCTLogError(@"Cannot find NativeView with tag #%@", reactTag);
|
|
63
|
-
return;
|
|
64
|
-
} else {
|
|
65
|
-
[(SpallaPlayerWrapper *)view selectSubtitle: subtitle];
|
|
66
|
-
}
|
|
67
|
-
}];
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
RCT_EXPORT_METHOD(selectPlaybackRate: (nonnull NSNumber *) reactTag rate:(NSNumber *)rate) {
|
|
71
|
-
[self.bridge.uiManager addUIBlock:^(RCTUIManager *uiManager, NSDictionary<NSNumber *,UIView *> *viewRegistry) {
|
|
72
|
-
UIView *view = viewRegistry[reactTag];
|
|
73
|
-
if (!view || ![view isKindOfClass:[SpallaPlayerWrapper class]]) {
|
|
74
|
-
RCTLogError(@"Cannot find NativeView with tag #%@", reactTag);
|
|
75
|
-
return;
|
|
76
|
-
} else {
|
|
77
|
-
[(SpallaPlayerWrapper *)view selectPlaybackRate: rate.doubleValue];
|
|
78
|
-
}
|
|
79
|
-
}];
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
RCT_EXPORT_METHOD(initialize: (nonnull NSString *) token: (NSString *) applicationId) {
|
|
83
|
-
dispatch_async(dispatch_get_main_queue(), ^{
|
|
84
|
-
[SpallaPlayerWrapper initializeWithToken: token applicationId: applicationId];
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
RCT_EXPORT_METHOD(unmount: (nonnull NSNumber *) reactTag {
|
|
89
|
-
[self.bridge.uiManager addUIBlock:^(RCTUIManager *uiManager, NSDictionary<NSNumber *,UIView *> *viewRegistry) {
|
|
90
|
-
UIView *view = viewRegistry[reactTag];
|
|
91
|
-
if (!view || ![view isKindOfClass:[SpallaPlayerWrapper class]]) {
|
|
92
|
-
RCTLogError(@"Cannot find NativeView with tag #%@", reactTag);
|
|
93
|
-
return;
|
|
94
|
-
} else {
|
|
95
|
-
[(SpallaPlayerWrapper *)view unmount];
|
|
96
|
-
}
|
|
97
|
-
}];
|
|
98
|
-
})
|
|
99
|
-
|
|
100
|
-
RCT_EXPORT_VIEW_PROPERTY(onPlayerEvent, RCTBubblingEventBlock)
|
|
101
|
-
|
|
102
|
-
@end
|
package/ios/RNSpallaPlayer.swift
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
#import <React/RCTViewManager.h>
|