vdocipher-rn-bridge 1.12.2 → 1.13.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 CHANGED
@@ -1,4 +1,11 @@
1
1
  ## Changelog
2
+ ### 1.13.0
3
+ * Updated VdoCipher android sdk dependency to 1.19.3
4
+ * Added support for setting aspect ratio and resize mode
5
+
6
+
7
+ ### 1.12.3
8
+ * Adding typescript support
2
9
 
3
10
  ### 1.12.2
4
11
  * Bug fix
@@ -3,10 +3,17 @@
3
3
  */
4
4
  import React, { Component } from 'react';
5
5
  import { requireNativeComponent} from 'react-native';
6
+ import { InferProps } from 'prop-types';
7
+ import { VdoPropTypes, VideoQuality, CaptionLanguage } from './type';
6
8
 
7
- class VdoPlayerSupportView extends Component {
9
+ const VdoViewPropTypes = VdoPropTypes;
10
+ type MyProps = InferProps<typeof VdoViewPropTypes>;
8
11
 
9
- constructor(props) {
12
+ class VdoPlayerSupportView extends Component<MyProps> {
13
+ _propRef: number;
14
+ _root: any;
15
+
16
+ constructor(props: MyProps) {
10
17
  super(props);
11
18
  this._propRef = 1;
12
19
  }
@@ -15,7 +22,7 @@ class VdoPlayerSupportView extends Component {
15
22
  this._root.setNativeProps({fullscreen: false});
16
23
  }
17
24
 
18
- seek = seekTargetMs => {
25
+ seek = (seekTargetMs: number) => {
19
26
  if (this._root) {
20
27
  this._root.setNativeProps({seek: seekTargetMs});
21
28
  }
@@ -39,7 +46,7 @@ class VdoPlayerSupportView extends Component {
39
46
  }
40
47
  }
41
48
 
42
- setVideoQuality = videoQuality => {
49
+ setVideoQuality = (videoQuality: VideoQuality) => {
43
50
  if (this._root) {
44
51
  this._root.setNativeProps({videoQuality: videoQuality});
45
52
  }
@@ -51,7 +58,7 @@ class VdoPlayerSupportView extends Component {
51
58
  }
52
59
  }
53
60
 
54
- setCaptionLanguage = captionLanguage => {
61
+ setCaptionLanguage = (captionLanguage: CaptionLanguage) => {
55
62
  if (this._root) {
56
63
  this._root.setNativeProps({captionLanguage: captionLanguage});
57
64
  }
@@ -63,20 +70,27 @@ class VdoPlayerSupportView extends Component {
63
70
  }
64
71
  }
65
72
 
73
+ setResizeMode = (resizeMode: String) => {
74
+ if (this._root) {
75
+ this._root.setNativeProps({resizeMode: resizeMode});
76
+ }
77
+ }
78
+
79
+ setAspectRatio = (aspectRatio: number) => {
80
+ if (this._root) {
81
+ this._root.setNativeProps({aspectRatio: aspectRatio});
82
+ }
83
+ }
84
+
66
85
  render() {
67
86
  return (
68
- <RCTVdoPlayerView ref={component => this._root = component}
87
+ <RCTVdoPlayerView ref={(component: any) => this._root = component}
69
88
  {...this.props}
70
89
  />
71
- )
90
+ );
72
91
  }
73
92
  }
74
93
 
75
- var RCTVdoPlayerView = requireNativeComponent('RCTVdoPlayerView', VdoPlayerSupportView, {
76
- nativeOnly: {
77
- onInitSuccess: true,
78
- onInitFailure: true,
79
- }
80
- });
94
+ var RCTVdoPlayerView = requireNativeComponent('RCTVdoPlayerView');
81
95
 
82
96
  export default VdoPlayerSupportView;
@@ -3,9 +3,17 @@
3
3
  */
4
4
  import React, { Component } from 'react';
5
5
  import {requireNativeComponent, Platform} from 'react-native';
6
+ import { InferProps } from 'prop-types';
7
+ import { VdoPropTypes } from './type';
8
+
9
+ const VdoViewPropTypes = VdoPropTypes;
10
+ type MyProps = InferProps<typeof VdoViewPropTypes>;
6
11
 
7
- class VdoPlayerUIView extends Component {
8
- constructor(props) {
12
+ class VdoPlayerUIView extends Component<MyProps> {
13
+ _propRef: number;
14
+ _root: any;
15
+ _tvEventHandler: any;
16
+ constructor(props: MyProps) {
9
17
  super(props);
10
18
  this._propRef = 1;
11
19
  }
@@ -31,7 +39,7 @@
31
39
  _enableTVEventHandler() {
32
40
  const {TVEventHandler} = require('react-native');
33
41
  this._tvEventHandler = new TVEventHandler();
34
- this._tvEventHandler.enable(this, function (cmp, evt) {
42
+ this._tvEventHandler.enable(this, function (cmp: any, evt: any) {
35
43
  if (cmp._vdoPlayerView) {
36
44
  if (evt && evt.eventType === "right") {
37
45
  cmp._vdoPlayerView.setKeyDownEvent({action: 0, code: 22});
@@ -56,12 +64,12 @@
56
64
  delete this._tvEventHandler;
57
65
  }
58
66
  }
59
-
67
+
60
68
  handleBackButtonClick() {
61
69
  this._root.setNativeProps({fullscreen: false});
62
70
  }
63
71
 
64
- seek = seekTargetMs => {
72
+ seek = (seekTargetMs: number) => {
65
73
  if (this._root) {
66
74
  this._root.setNativeProps({seek: seekTargetMs});
67
75
  }
@@ -85,26 +93,33 @@
85
93
  }
86
94
  }
87
95
 
88
- setKeyDownEvent = (keyDownEvent) => {
96
+ setKeyDownEvent = (keyDownEvent: any) => {
89
97
  if (this._root) {
90
98
  this._root.setNativeProps({keyDownEvent: keyDownEvent});
91
99
  }
92
100
  }
93
-
94
- render() {
95
- return (
96
- <RCTVdoPlayerUIView ref={component => this._root = component}
97
- {...this.props}
98
- />
99
- );
100
- }
101
+
102
+ setResizeMode = (resizeMode: String) => {
103
+ if (this._root) {
104
+ this._root.setNativeProps({resizeMode: resizeMode});
105
+ }
106
+ }
107
+
108
+ setAspectRatio = (aspectRatio: number) => {
109
+ if (this._root) {
110
+ this._root.setNativeProps({aspectRatio: aspectRatio});
111
+ }
112
+ }
113
+
114
+ render() {
115
+ return (
116
+ <RCTVdoPlayerUIView ref={(component: any) => this._root = component}
117
+ {...this.props}
118
+ />
119
+ );
120
+ }
101
121
  }
102
122
 
103
- var RCTVdoPlayerUIView = requireNativeComponent('RCTVdoPlayerUIView', VdoPlayerUIView, {
104
- nativeOnly: {
105
- onInitSuccess: true,
106
- onInitFailure: true,
107
- }
108
- });
123
+ var RCTVdoPlayerUIView = requireNativeComponent('RCTVdoPlayerUIView');
109
124
 
110
125
  export default VdoPlayerUIView;
@@ -0,0 +1,338 @@
1
+ /**
2
+ * VdoPlayerView component that can be dropped into a layout for video playback.
3
+ */
4
+ import React, { Component, Fragment } from 'react';
5
+ import { InferProps } from 'prop-types';
6
+ import { BackHandler, NativeModules, StyleSheet, Dimensions} from 'react-native';
7
+ import VdoPlayerSupportView from './VdoPlayerSupportView';
8
+ import VdoPlayerUIView from './VdoPlayerUIView';
9
+ import * as VdoType from './type';
10
+ const { TrackSelection } = NativeModules;
11
+
12
+ const VdoViewPropTypes = VdoType.VdoPropTypes;
13
+
14
+ type MyProps = InferProps<typeof VdoViewPropTypes>;
15
+ type MyState = {
16
+ fullscreen: boolean;
17
+ isInitialPortrait: boolean;
18
+ isInPictureInPictureMode: false;
19
+ };
20
+
21
+ class VdoPlayerView extends Component<MyProps, MyState> {
22
+ _propRef: number;
23
+ _vdoPlayerView: any;
24
+ static propTypes: typeof VdoViewPropTypes;
25
+
26
+ constructor(props: MyProps) {
27
+ super(props);
28
+ this.state = {
29
+ fullscreen: false,
30
+ isInitialPortrait: true,
31
+ isInPictureInPictureMode: false
32
+ }
33
+ this.handleBackButtonClick = this.handleBackButtonClick.bind(this);
34
+ this._propRef = 1;
35
+ }
36
+
37
+ componentDidMount() {
38
+ BackHandler.addEventListener('hardwareBackPress', this.handleBackButtonClick);
39
+ if (this.props.style?.resizeMode) {
40
+ this._vdoPlayerView.setResizeMode(this.props.style.resizeMode);
41
+ }
42
+ }
43
+
44
+ componentWillUnmount() {
45
+ BackHandler.removeEventListener('hardwareBackPress', this.handleBackButtonClick);
46
+ }
47
+
48
+ handleBackButtonClick() {
49
+ if (!this.state.isInPictureInPictureMode && this.state.fullscreen && this.state.isInitialPortrait) {
50
+ this._vdoPlayerView.handleBackButtonClick();
51
+ return true;
52
+ }
53
+ }
54
+
55
+ seek = (seekTargetMs: number) => {
56
+ if (this._vdoPlayerView) {
57
+ this._vdoPlayerView.seek(seekTargetMs);
58
+ }
59
+ }
60
+
61
+ enterFullscreen = () => {
62
+ if (this._vdoPlayerView) {
63
+ this._vdoPlayerView.enterFullscreen();
64
+ }
65
+ }
66
+
67
+ exitFullscreen = () => {
68
+ if (this._vdoPlayerView) {
69
+ this._vdoPlayerView.exitFullscreen();
70
+ }
71
+ }
72
+
73
+ getPlaybackProperties = () => {
74
+ if (this._vdoPlayerView) {
75
+ this._vdoPlayerView.getPlaybackProperties();
76
+ }
77
+ }
78
+
79
+ isAdaptive = async() => {
80
+ return new Promise(async(resolve) => { await TrackSelection.isAdaptive((isAdaptive: boolean) => {
81
+ resolve(isAdaptive);
82
+ });
83
+ });
84
+ }
85
+
86
+ getVideoQualities = async() => {
87
+ return new Promise(async(resolve) => { await TrackSelection.getVideoQualities((videoQualities: Array<VdoType.VideoQuality>) => {
88
+ resolve(videoQualities);
89
+ });
90
+ });
91
+ }
92
+
93
+ getSelectedVideoQuality = async() => {
94
+ return new Promise(async(resolve) => { await TrackSelection.getSelectedVideoQuality((selectedVideoQuality: VdoType.VideoQuality) => {
95
+ resolve(selectedVideoQuality);
96
+ });
97
+ });
98
+ }
99
+
100
+ setVideoQuality = (videoQuality: VdoType.VideoQuality) => {
101
+ if (this._vdoPlayerView) {
102
+ this._vdoPlayerView.setVideoQuality(videoQuality);
103
+ }
104
+ }
105
+
106
+ enableAdaptiveVideo = () => {
107
+ if (this._vdoPlayerView) {
108
+ this._vdoPlayerView.enableAdaptiveVideo();
109
+ }
110
+ }
111
+
112
+ getSelectedAudioQuality = async() => {
113
+ return new Promise(async(resolve) => { await TrackSelection.getSelectedAudioQuality((selectedAudioQuality: VdoType.AudioQuality) => {
114
+ resolve(selectedAudioQuality);
115
+ });
116
+ });
117
+ }
118
+
119
+ getCaptionLanguages = async() => {
120
+ return new Promise(async(resolve) => { await TrackSelection.getCaptionLanguages((captionLanguages: Array<VdoType.CaptionLanguage>) => {
121
+ resolve(captionLanguages);
122
+ });
123
+ });
124
+ }
125
+
126
+ getSelectedCaptionLanguage = async() => {
127
+ return new Promise(async(resolve) => { await TrackSelection.getSelectedCaptionLanguage((selectedCaptionLanguage: VdoType.CaptionLanguage) => {
128
+ resolve(selectedCaptionLanguage);
129
+ });
130
+ });
131
+ }
132
+
133
+ setCaptionLanguage = (captionLanguage: VdoType.CaptionLanguage) => {
134
+ if (this._vdoPlayerView) {
135
+ this._vdoPlayerView.setCaptionLanguage(captionLanguage);
136
+ }
137
+ }
138
+
139
+ disableCaptions = () => {
140
+ if (this._vdoPlayerView) {
141
+ this._vdoPlayerView.disableCaptions();
142
+ }
143
+ }
144
+
145
+ getDuration = async() => {
146
+ return new Promise(async(resolve) => { await TrackSelection.getDuration((duration: number) => {
147
+ resolve(duration);
148
+ });
149
+ });
150
+ }
151
+
152
+ setAspectRatio = (aspectRatio: number) => {
153
+ if (this._vdoPlayerView) {
154
+ this._vdoPlayerView.setAspectRatio(aspectRatio);
155
+ }
156
+ }
157
+
158
+ _onInitSuccess = (event: any) => {
159
+ if (this.props.onInitializationSuccess) {
160
+ this.props.onInitializationSuccess(event.nativeEvent);
161
+ }
162
+ }
163
+
164
+ _onInitFailure = (event: any) => {
165
+ if (this.props.onInitializationFailure) {
166
+ this.props.onInitializationFailure(event.nativeEvent);
167
+ }
168
+ }
169
+
170
+ _onLoading = (embedInfo: VdoType.EmbedInfo | VdoType.OfflineEmbedInfo, event: any) => {
171
+ if (this.props.onLoading) {
172
+ this.props.onLoading({embedInfo, ...event.nativeEvent});
173
+ }
174
+ }
175
+
176
+ _onLoaded = (embedInfo: VdoType.EmbedInfo | VdoType.OfflineEmbedInfo, event: any) => {
177
+ if (this.props.onLoaded) {
178
+ this.props.onLoaded({embedInfo, ...event.nativeEvent});
179
+ }
180
+ }
181
+
182
+ _onLoadError = (embedInfo: VdoType.EmbedInfo | VdoType.OfflineEmbedInfo, event: any) => {
183
+ if (this.props.onLoadError) {
184
+ this.props.onLoadError({embedInfo, ...event.nativeEvent});
185
+ }
186
+ }
187
+
188
+ _onPlayerStateChanged = (event: any) => {
189
+ if (this.props.onPlayerStateChanged) {
190
+ this.props.onPlayerStateChanged(event.nativeEvent);
191
+ }
192
+ }
193
+
194
+ _onProgress = (event: any) => {
195
+ if (this.props.onProgress) {
196
+ this.props.onProgress(event.nativeEvent);
197
+ }
198
+ }
199
+
200
+ _onBufferUpdate = (event: any) => {
201
+ if (this.props.onBufferUpdate) {
202
+ this.props.onBufferUpdate(event.nativeEvent);
203
+ }
204
+ }
205
+
206
+ _onPlaybackSpeedChanged = (event: any) => {
207
+ if (this.props.onPlaybackSpeedChanged) {
208
+ this.props.onPlaybackSpeedChanged(event.nativeEvent.playbackSpeed);
209
+ }
210
+ }
211
+
212
+ _onTracksChanged = (event: any) => {
213
+ if (this.props.onTracksChanged) {
214
+ this.props.onTracksChanged(event.nativeEvent);
215
+ }
216
+ }
217
+
218
+ _onMediaEnded = (embedInfo: VdoType.EmbedInfo | VdoType.OfflineEmbedInfo, event: any) => {
219
+ if (this.props.onMediaEnded) {
220
+ this.props.onMediaEnded({embedInfo, ...event.nativeEvent});
221
+ }
222
+ }
223
+
224
+ _onError = (embedInfo: VdoType.EmbedInfo | VdoType.OfflineEmbedInfo, event: any) => {
225
+ if (this.props.onError) {
226
+ this.props.onError({embedInfo, ...event.nativeEvent});
227
+ }
228
+ }
229
+
230
+ _onPlaybackProperties = (event: any) => {
231
+ if (this.props.onPlaybackProperties) {
232
+ this.props.onPlaybackProperties(event.nativeEvent);
233
+ }
234
+ }
235
+
236
+ _onEnterFullscreen = () => {
237
+ this.setState({
238
+ fullscreen: true
239
+ });
240
+
241
+ if (this.props.onEnterFullscreen) {
242
+ this.props.onEnterFullscreen();
243
+ }
244
+ }
245
+
246
+ _onExitFullscreen = () => {
247
+ this.setState({
248
+ fullscreen: false
249
+ });
250
+
251
+ if (this.props.onExitFullscreen) {
252
+ this.props.onExitFullscreen();
253
+ }
254
+ }
255
+
256
+ _onIsInitialPortrait =(event: any) => {
257
+ this.setState({
258
+ isInitialPortrait: event.nativeEvent.isInitialPortrait
259
+ });
260
+ }
261
+
262
+ _onPictureInPictureModeChanged = (event: any) => {
263
+ this.setState({
264
+ isInPictureInPictureMode: event.nativeEvent.isInPictureInPictureMode
265
+ });
266
+ if (this.props.onPictureInPictureModeChanged) {
267
+ this.props.onPictureInPictureModeChanged(event.nativeEvent);
268
+ }
269
+ }
270
+
271
+ render() {
272
+ return (
273
+ <Fragment>
274
+ {
275
+ this.props.showNativeControls === false ? (
276
+ <VdoPlayerSupportView ref={vdoPlayerView => this._vdoPlayerView = vdoPlayerView}
277
+ {...this.props}
278
+ onInitSuccess={this._onInitSuccess}
279
+ onInitFailure={this._onInitFailure}
280
+ onVdoLoading={((embedInfo: VdoType.EmbedInfo | VdoType.OfflineEmbedInfo) => (event: any) => this._onLoading(embedInfo, event))(this.props.embedInfo)}
281
+ onVdoLoaded={((embedInfo: VdoType.EmbedInfo | VdoType.OfflineEmbedInfo) => (event: any) => this._onLoaded(embedInfo, event))(this.props.embedInfo)}
282
+ onVdoLoadError={((embedInfo: VdoType.EmbedInfo | VdoType.OfflineEmbedInfo) => (event: any) => this._onLoadError(embedInfo, event))(this.props.embedInfo)}
283
+ onVdoPlayerStateChanged={this._onPlayerStateChanged}
284
+ onVdoProgress={this._onProgress}
285
+ onVdoBufferUpdate={this._onBufferUpdate}
286
+ onVdoPlaybackSpeedChanged={this._onPlaybackSpeedChanged}
287
+ onVdoTracksChanged={this._onTracksChanged}
288
+ onVdoMediaEnded={((embedInfo: VdoType.EmbedInfo | VdoType.OfflineEmbedInfo) => (event: any) => this._onMediaEnded(embedInfo, event))(this.props.embedInfo)}
289
+ onVdoError={((embedInfo: VdoType.EmbedInfo | VdoType.OfflineEmbedInfo) => (event: any) => this._onError(embedInfo, event))(this.props.embedInfo)}
290
+ onVdoPlaybackProperties={this._onPlaybackProperties}
291
+ onVdoEnterFullscreen={this._onEnterFullscreen}
292
+ onVdoExitFullscreen={this._onExitFullscreen}
293
+ onIsInitialPortrait={this._onIsInitialPortrait}
294
+ onVdoPictureInPictureModeChanged={this._onPictureInPictureModeChanged}
295
+ />
296
+ ) :
297
+ (
298
+ <VdoPlayerUIView ref={vdoPlayerView => this._vdoPlayerView = vdoPlayerView}
299
+ {...this.props}
300
+ style={this.props.style ? [this.props.style, styles.playerWithUserStyles] : styles.player}
301
+ onInitSuccess={this._onInitSuccess}
302
+ onInitFailure={this._onInitFailure}
303
+ onVdoLoading={((embedInfo: VdoType.EmbedInfo | VdoType.OfflineEmbedInfo) => (event: any) => this._onLoading(embedInfo, event))(this.props.embedInfo)}
304
+ onVdoLoaded={((embedInfo: VdoType.EmbedInfo | VdoType.OfflineEmbedInfo) => (event: any) => this._onLoaded(embedInfo, event))(this.props.embedInfo)}
305
+ onVdoLoadError={((embedInfo: VdoType.EmbedInfo | VdoType.OfflineEmbedInfo) => (event: any) => this._onLoadError(embedInfo, event))(this.props.embedInfo)}
306
+ onVdoPlayerStateChanged={this._onPlayerStateChanged}
307
+ onVdoProgress={this._onProgress}
308
+ onVdoBufferUpdate={this._onBufferUpdate}
309
+ onVdoPlaybackSpeedChanged={this._onPlaybackSpeedChanged}
310
+ onVdoTracksChanged={this._onTracksChanged}
311
+ onVdoMediaEnded={((embedInfo: VdoType.EmbedInfo | VdoType.OfflineEmbedInfo) => (event: any) => this._onMediaEnded(embedInfo, event))(this.props.embedInfo)}
312
+ onVdoError={((embedInfo: VdoType.EmbedInfo | VdoType.OfflineEmbedInfo) => (event: any) => this._onError(embedInfo, event))(this.props.embedInfo)}
313
+ onVdoPlaybackProperties={this._onPlaybackProperties}
314
+ onVdoEnterFullscreen={this._onEnterFullscreen}
315
+ onVdoExitFullscreen={this._onExitFullscreen}
316
+ onIsInitialPortrait={this._onIsInitialPortrait}
317
+ onVdoPictureInPictureModeChanged={this._onPictureInPictureModeChanged}
318
+ />
319
+ )
320
+ }
321
+ </Fragment>
322
+ );
323
+ }
324
+ }
325
+
326
+ VdoPlayerView.propTypes = VdoViewPropTypes;
327
+
328
+ export default VdoPlayerView;
329
+
330
+ const styles = StyleSheet.create({
331
+ player: {
332
+ minHeight: (Dimensions.get('window').width / 16) * 9,
333
+ width: '100%',
334
+ },
335
+ playerWithUserStyles: {
336
+ minHeight: (Dimensions.get('window').width / 16) * 9
337
+ }
338
+ });
@@ -18,8 +18,8 @@ apply plugin: 'com.android.library'
18
18
  // TODO read from package.json
19
19
  // "releaseVersionName" must be the same as "version" in package.json
20
20
  // "releaseVersionCode" must increment by 1 with every release
21
- def releaseVersionName = "1.12.2"
22
- def releaseVersionCode = 13
21
+ def releaseVersionName = "1.13.0"
22
+ def releaseVersionCode = 15
23
23
 
24
24
  android {
25
25
  compileSdkVersion 33
@@ -86,5 +86,5 @@ repositories {
86
86
  dependencies {
87
87
  compileOnly 'com.facebook.react:react-native:+'
88
88
  implementation 'androidx.appcompat:appcompat:1.3.1'
89
- implementation 'com.vdocipher.aegis:vdocipher-android:1.19.1'
89
+ implementation 'com.vdocipher.aegis:vdocipher-android:1.19.3'
90
90
  }
@@ -24,9 +24,11 @@ import com.vdocipher.aegis.ui.view.VdoPlayerUIFragment;
24
24
  import android.os.Handler;
25
25
  import android.os.Bundle;
26
26
 
27
- import androidx.core.app.PictureInPictureModeChangedInfo;
28
27
  import androidx.core.util.Consumer;
29
28
  import android.graphics.Color;
29
+ import static com.vdocipher.rnbridge.Utils.*;
30
+ import com.vdocipher.aegis.player.PlayerHost;
31
+ import androidx.core.app.PictureInPictureModeChangedInfo;
30
32
 
31
33
 
32
34
  public class ReactVdoPlayerUIView extends FrameLayout implements LifecycleEventListener, Consumer<Configuration> {
@@ -50,6 +52,8 @@ public class ReactVdoPlayerUIView extends FrameLayout implements LifecycleEventL
50
52
 
51
53
  private Consumer<PictureInPictureModeChangedInfo> pictureModeChangedInfoConsumer;
52
54
 
55
+ private int resizeMode = PlayerHost.RESIZE_MODE_FIT;
56
+
53
57
  public ReactVdoPlayerUIView(ThemedReactContext context) {
54
58
  super(context);
55
59
  themedReactContext = context;
@@ -67,18 +71,21 @@ public class ReactVdoPlayerUIView extends FrameLayout implements LifecycleEventL
67
71
  eventEmitter.isInitialPortrait();
68
72
  }
69
73
 
74
+ setPictureInPictureSupport();
75
+
70
76
  }
71
77
 
72
78
  private void initializePlayer() {
73
79
  if (vdoPlayerUIFragment != null) {
74
80
  new Handler().postDelayed(() -> {
75
81
  if (fragmentManager != null && !fragmentManager.isDestroyed()) {
76
- fragmentManager.beginTransaction().replace(getId(), vdoPlayerUIFragment, VdoPlayerUIFragment.class.getName()).commitNow();
82
+ fragmentManager.beginTransaction().replace(getId(), vdoPlayerUIFragment, "VdoPlayerUIFragmentRN").commitNow();
77
83
  }
78
84
  vdoPlayerControlView = vdoPlayerUIFragment.requireView().findViewById(R.id.vdo_player_control_view);
79
85
  // initialize the playerFragment; a VdoPlayer instance will be received
80
86
  // in onInitializationSuccess() callback
81
87
  vdoPlayerUIFragment.initialize(initializationListener);
88
+ vdoPlayerUIFragment.setResizeMode(this.resizeMode);
82
89
  }, 200);
83
90
  }
84
91
  }
@@ -138,15 +145,23 @@ public class ReactVdoPlayerUIView extends FrameLayout implements LifecycleEventL
138
145
  }
139
146
 
140
147
  public void setPictureInPictureSupport() {
141
- if (vdoPlayerUIFragment != null) {
142
- vdoPlayerUIFragment.setPictureInPictureSupport(true);
148
+ if (!isRunningOnTv(activity)) {
143
149
  pictureModeChangedInfoConsumer = pictureInPictureModeChangedInfo ->
144
150
  {
145
151
  eventEmitter.onPictureInPictureModeChanged(pictureInPictureModeChangedInfo.isInPictureInPictureMode());
146
152
  };
147
-
148
153
  activity.addOnPictureInPictureModeChangedListener(pictureModeChangedInfoConsumer);
149
154
  }
155
+ }
156
+
157
+ public void setResizeMode(String resizeModeName) {
158
+ this.resizeMode = resizeModeIntFromName(resizeModeName);
159
+ }
160
+
161
+ public void setAspectRatio(float aspectRatio) {
162
+ if( vdoPlayerUIFragment != null) {
163
+ vdoPlayerUIFragment.setAspectRatio(aspectRatio);
164
+ }
150
165
  }
151
166
 
152
167
  @Override
@@ -232,7 +247,6 @@ public class ReactVdoPlayerUIView extends FrameLayout implements LifecycleEventL
232
247
  Log.d(TAG, "init success");
233
248
  vdoPlayer = player;
234
249
  vdoPlayer.addPlaybackEventListener(playbackListener);
235
-
236
250
  eventEmitter.initSuccess(restored);
237
251
 
238
252
  // load pending params
@@ -63,7 +63,6 @@ public class ReactVdoPlayerUIViewManager extends ViewGroupManager<ReactVdoPlayer
63
63
  embedInfo.getString("safetyNetApiKey") : null;
64
64
  boolean allowAdbDebugging = !embedInfo.hasKey("allowAdbDebugging") ||
65
65
  embedInfo.getBoolean("allowAdbDebugging");
66
- boolean setPictureInPictureSupport = embedInfo.hasKey("setPictureInPictureSupport") && embedInfo.getBoolean("setPictureInPictureSupport");
67
66
 
68
67
  VdoInitParams.Builder builder = new VdoInitParams.Builder();
69
68
 
@@ -115,10 +114,6 @@ public class ReactVdoPlayerUIViewManager extends ViewGroupManager<ReactVdoPlayer
115
114
  }
116
115
 
117
116
  initParams = builder.build();
118
-
119
- if (setPictureInPictureSupport) {
120
- vdoPlayerView.setPictureInPictureSupport();
121
- }
122
117
 
123
118
  vdoPlayerView.load(initParams);
124
119
  }
@@ -153,4 +148,14 @@ public class ReactVdoPlayerUIViewManager extends ViewGroupManager<ReactVdoPlayer
153
148
  public void setKeyDownEvent(ReactVdoPlayerUIView vdoPlayerView, ReadableMap eventMap) {
154
149
  vdoPlayerView.setKeyDownEvent(new KeyEvent(eventMap.getInt("action"), eventMap.getInt("code")));
155
150
  }
151
+
152
+ @ReactProp(name = "resizeMode")
153
+ public void setResizeMode(ReactVdoPlayerUIView vdoPlayerView, String resizeMode) {
154
+ vdoPlayerView.setResizeMode(resizeMode);
155
+ }
156
+
157
+ @ReactProp(name = "aspectRatio")
158
+ public void setAspectRatio(ReactVdoPlayerUIView vdoPlayerView, float aspectRatio) {
159
+ vdoPlayerView.setAspectRatio(aspectRatio);
160
+ }
156
161
  }