react-native-theoplayer 2.10.0 → 2.11.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/CHANGELOG.md +17 -1
- package/README.md +11 -9
- package/android/src/main/java/com/theoplayer/PlayerEventEmitter.kt +1 -1
- package/android/src/main/java/com/theoplayer/player/PlayerModule.kt +10 -0
- package/android/src/main/java/com/theoplayer/presentation/PipUtils.kt +16 -9
- package/android/src/main/java/com/theoplayer/track/TextTrackStyleAdapter.kt +79 -0
- package/android/src/main/java/com/theoplayer/util/ViewResolver.kt +6 -0
- package/ios/THEOplayerRCTBridge.m +3 -0
- package/ios/THEOplayerRCTPlayerAPI.swift +52 -0
- package/ios/THEOplayerRCTTypeUtils.swift +15 -0
- package/ios/ads/THEOplayerRCTAdsAPI+DAI.swift +1 -1
- package/ios/ads/THEOplayerRCTSourceDescriptionBuilder+Ads.swift +1 -1
- package/ios/ads/THEOplayerRCTView+AdsConfig.swift +1 -1
- package/ios/backgroundAudio/THEOplayerRCTNowPlayingManager.swift +3 -3
- package/lib/commonjs/api/track/TextTrackStyle.js +29 -0
- package/lib/commonjs/api/track/TextTrackStyle.js.map +1 -1
- package/lib/commonjs/internal/adapter/track/NamedColors.json +143 -0
- package/lib/commonjs/internal/adapter/track/TextTrackStyleAdapter.js +118 -22
- package/lib/commonjs/internal/adapter/track/TextTrackStyleAdapter.js.map +1 -1
- package/lib/commonjs/internal/adapter/web/WebMediaSession.js +1 -1
- package/lib/commonjs/internal/adapter/web/WebMediaSession.js.map +1 -1
- package/lib/module/api/track/TextTrackStyle.js +23 -0
- package/lib/module/api/track/TextTrackStyle.js.map +1 -1
- package/lib/module/internal/adapter/track/NamedColors.json +143 -0
- package/lib/module/internal/adapter/track/TextTrackStyleAdapter.js +117 -22
- package/lib/module/internal/adapter/track/TextTrackStyleAdapter.js.map +1 -1
- package/lib/module/internal/adapter/web/WebMediaSession.js +1 -1
- package/lib/module/internal/adapter/web/WebMediaSession.js.map +1 -1
- package/lib/typescript/api/track/TextTrackStyle.d.ts +43 -5
- package/lib/typescript/internal/adapter/track/TextTrackStyleAdapter.d.ts +26 -8
- package/package.json +1 -1
- package/react-native-theoplayer.podspec +1 -1
- package/src/api/track/TextTrackStyle.ts +45 -5
- package/src/internal/adapter/track/NamedColors.json +143 -0
- package/src/internal/adapter/track/TextTrackStyleAdapter.ts +132 -21
- package/src/internal/adapter/web/WebMediaSession.ts +1 -1
|
@@ -1,55 +1,166 @@
|
|
|
1
1
|
import type { EdgeStyle, TextTrackStyle, THEOplayerView } from 'react-native-theoplayer';
|
|
2
|
+
import { NativeModules } from 'react-native';
|
|
3
|
+
import NamedColors from './NamedColors.json';
|
|
4
|
+
|
|
5
|
+
const namedColorsMap = NamedColors as { [name: string]: string };
|
|
2
6
|
|
|
3
7
|
export class TextTrackStyleAdapter implements TextTrackStyle {
|
|
4
|
-
|
|
5
|
-
|
|
8
|
+
private _backgroundColor: string | undefined = undefined;
|
|
9
|
+
private _edgeStyle: EdgeStyle | undefined = undefined;
|
|
10
|
+
private _fontColor: string | undefined = undefined;
|
|
11
|
+
private _fontFamily: string | undefined = undefined;
|
|
12
|
+
private _fontSize: string | undefined = undefined;
|
|
13
|
+
private _windowColor: string | undefined = undefined;
|
|
14
|
+
private _marginBottom: number | undefined = undefined;
|
|
15
|
+
private _marginTop: number | undefined = undefined;
|
|
16
|
+
private _marginLeft: number | undefined = undefined;
|
|
17
|
+
private _marginRight: number | undefined = undefined;
|
|
18
|
+
|
|
19
|
+
constructor(private readonly _view: THEOplayerView) {}
|
|
6
20
|
|
|
7
21
|
get backgroundColor(): string | undefined {
|
|
8
|
-
|
|
9
|
-
return undefined;
|
|
22
|
+
return this._backgroundColor;
|
|
10
23
|
}
|
|
11
24
|
|
|
12
|
-
set backgroundColor(
|
|
13
|
-
|
|
25
|
+
set backgroundColor(color: string | undefined) {
|
|
26
|
+
this._backgroundColor = color;
|
|
27
|
+
NativeModules.PlayerModule.setTextTrackStyle(this._view.nativeHandle, {
|
|
28
|
+
backgroundColor: convertColorToRGBA(color),
|
|
29
|
+
});
|
|
14
30
|
}
|
|
15
31
|
|
|
16
32
|
get edgeStyle(): EdgeStyle | undefined {
|
|
17
|
-
return
|
|
33
|
+
return this._edgeStyle;
|
|
18
34
|
}
|
|
19
35
|
|
|
20
|
-
set edgeStyle(
|
|
21
|
-
|
|
36
|
+
set edgeStyle(style: EdgeStyle | undefined) {
|
|
37
|
+
this._edgeStyle = style;
|
|
38
|
+
NativeModules.PlayerModule.setTextTrackStyle(this._view.nativeHandle, {
|
|
39
|
+
edgeStyle: style,
|
|
40
|
+
});
|
|
22
41
|
}
|
|
23
42
|
|
|
24
43
|
get fontColor(): string | undefined {
|
|
25
|
-
return
|
|
44
|
+
return this._fontColor;
|
|
26
45
|
}
|
|
27
46
|
|
|
28
|
-
set fontColor(
|
|
29
|
-
|
|
47
|
+
set fontColor(color: string | undefined) {
|
|
48
|
+
this._fontColor = color;
|
|
49
|
+
NativeModules.PlayerModule.setTextTrackStyle(this._view.nativeHandle, {
|
|
50
|
+
fontColor: convertColorToRGBA(color),
|
|
51
|
+
});
|
|
30
52
|
}
|
|
31
53
|
|
|
32
54
|
get fontFamily(): string | undefined {
|
|
33
|
-
return
|
|
55
|
+
return this._fontFamily;
|
|
34
56
|
}
|
|
35
57
|
|
|
36
|
-
set fontFamily(
|
|
37
|
-
|
|
58
|
+
set fontFamily(family: string | undefined) {
|
|
59
|
+
this._fontFamily = family;
|
|
60
|
+
NativeModules.PlayerModule.setTextTrackStyle(this._view.nativeHandle, {
|
|
61
|
+
fontFamily: family,
|
|
62
|
+
});
|
|
38
63
|
}
|
|
39
64
|
|
|
40
65
|
get fontSize(): string | undefined {
|
|
41
|
-
return
|
|
66
|
+
return this._fontSize;
|
|
42
67
|
}
|
|
43
68
|
|
|
44
|
-
set fontSize(
|
|
45
|
-
|
|
69
|
+
set fontSize(size: string | undefined) {
|
|
70
|
+
this._fontSize = size;
|
|
71
|
+
NativeModules.PlayerModule.setTextTrackStyle(this._view.nativeHandle, {
|
|
72
|
+
fontSize: fromPercentage(size),
|
|
73
|
+
});
|
|
46
74
|
}
|
|
47
75
|
|
|
48
76
|
get windowColor(): string | undefined {
|
|
49
|
-
return
|
|
77
|
+
return this._windowColor;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
set windowColor(color: string | undefined) {
|
|
81
|
+
this._windowColor = color;
|
|
82
|
+
NativeModules.PlayerModule.setTextTrackStyle(this._view.nativeHandle, {
|
|
83
|
+
windowColor: convertColorToRGBA(color),
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
get marginBottom(): number | undefined {
|
|
88
|
+
return this._marginBottom;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
set marginBottom(margin: number | undefined) {
|
|
92
|
+
this._marginBottom = margin;
|
|
93
|
+
NativeModules.PlayerModule.setTextTrackStyle(this._view.nativeHandle, {
|
|
94
|
+
marginBottom: margin,
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
get marginLeft(): number | undefined {
|
|
99
|
+
return this._marginLeft;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
set marginLeft(margin: number | undefined) {
|
|
103
|
+
this._marginLeft = margin;
|
|
104
|
+
NativeModules.PlayerModule.setTextTrackStyle(this._view.nativeHandle, {
|
|
105
|
+
marginLeft: margin,
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
get marginRight(): number | undefined {
|
|
110
|
+
return this._marginRight;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
set marginRight(margin: number | undefined) {
|
|
114
|
+
this._marginRight = margin;
|
|
115
|
+
NativeModules.PlayerModule.setTextTrackStyle(this._view.nativeHandle, {
|
|
116
|
+
marginRight: margin,
|
|
117
|
+
});
|
|
50
118
|
}
|
|
51
119
|
|
|
52
|
-
|
|
53
|
-
|
|
120
|
+
get marginTop(): number | undefined {
|
|
121
|
+
return this._marginTop;
|
|
54
122
|
}
|
|
123
|
+
|
|
124
|
+
set marginTop(margin: number | undefined) {
|
|
125
|
+
this._marginTop = margin;
|
|
126
|
+
NativeModules.PlayerModule.setTextTrackStyle(this._view.nativeHandle, {
|
|
127
|
+
marginTop: margin,
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
interface BridgeColor {
|
|
133
|
+
r: number;
|
|
134
|
+
g: number;
|
|
135
|
+
b: number;
|
|
136
|
+
a: number;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
function convertColorToRGBA(color: string | undefined): BridgeColor | null {
|
|
140
|
+
if (!color) {
|
|
141
|
+
return null;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
color = color.replace('#', '');
|
|
145
|
+
|
|
146
|
+
if (namedColorsMap[color.toLowerCase()]) {
|
|
147
|
+
color = namedColorsMap[color.toLowerCase()];
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
const colorPattern = /^(?:#|0x)?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})?$/i;
|
|
151
|
+
const match = color.match(colorPattern);
|
|
152
|
+
|
|
153
|
+
if (!match) {
|
|
154
|
+
return null;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
const r = parseInt(match[1], 16);
|
|
158
|
+
const g = parseInt(match[2], 16);
|
|
159
|
+
const b = parseInt(match[3], 16);
|
|
160
|
+
const a = match[4] ? parseInt(match[4], 16) : 255;
|
|
161
|
+
return { r, g, b, a };
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
function fromPercentage(pct: string | undefined): number {
|
|
165
|
+
return pct ? parseFloat(pct) : 100;
|
|
55
166
|
}
|
|
@@ -102,7 +102,7 @@ export class WebMediaSession {
|
|
|
102
102
|
private updateMetadata = () => {
|
|
103
103
|
const source = this._player.source;
|
|
104
104
|
const metadata = source?.metadata;
|
|
105
|
-
const artwork = [
|
|
105
|
+
const artwork = [metadata?.displayIconUri, source?.poster, ...(metadata?.images ? metadata?.images : [])]
|
|
106
106
|
.filter((image) => image !== undefined)
|
|
107
107
|
.map((image) => {
|
|
108
108
|
if (typeof image === 'string') {
|