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.
@@ -22,7 +22,6 @@ import com.vdocipher.aegis.player.VdoPlayer.PlaybackEventListener;
22
22
  import com.vdocipher.aegis.player.VdoInitParams;
23
23
  import com.vdocipher.aegis.ui.view.VdoPlayerUIFragment;
24
24
  import android.media.AudioManager;
25
- import android.app.UiModeManager;
26
25
  import android.content.Context;
27
26
 
28
27
  import androidx.core.app.PictureInPictureModeChangedInfo;
@@ -59,7 +58,6 @@ public class ReactVdoPlayerView extends FrameLayout implements LifecycleEventLis
59
58
  private float pendingPlaybackSpeed = 0;
60
59
  private boolean fullscreen = false;
61
60
 
62
- private boolean hasPictureInPictureSupport = false;
63
61
  private MediaSessionCompat mSession;
64
62
  public static final long MEDIA_ACTIONS_PLAY_PAUSE =
65
63
  PlaybackStateCompat.ACTION_PLAY
@@ -76,6 +74,8 @@ public class ReactVdoPlayerView extends FrameLayout implements LifecycleEventLis
76
74
  private Track[] selectedTracks;
77
75
  private Handler mainHandler;
78
76
 
77
+ private int resizeMode = PlayerHost.RESIZE_MODE_FIT;
78
+
79
79
  public ReactVdoPlayerView(ThemedReactContext context) {
80
80
  super(context);
81
81
  context.addLifecycleEventListener(this);
@@ -93,6 +93,7 @@ public class ReactVdoPlayerView extends FrameLayout implements LifecycleEventLis
93
93
  eventEmitter.isInitialPortrait();
94
94
  }
95
95
 
96
+ setPictureInPictureSupport();
96
97
  audioManager = (AudioManager) activity.getSystemService(Context.AUDIO_SERVICE);
97
98
 
98
99
  }
@@ -106,6 +107,7 @@ public class ReactVdoPlayerView extends FrameLayout implements LifecycleEventLis
106
107
  // initialize the playerFragment; a VdoPlayer instance will be received
107
108
  // in onInitializationSuccess() callback
108
109
  vdoPlayerUIFragment.initialize(initializationListener);
110
+ vdoPlayerUIFragment.setResizeMode(this.resizeMode);
109
111
  }, 200);
110
112
  }
111
113
  }
@@ -115,7 +117,7 @@ public class ReactVdoPlayerView extends FrameLayout implements LifecycleEventLis
115
117
  */
116
118
  public void cleanUp() {
117
119
  themedReactContext.removeLifecycleEventListener(this);
118
- if (hasPictureInPictureSupport && pictureModeChangedInfoConsumer != null) {
120
+ if (pictureModeChangedInfoConsumer != null) {
119
121
  activity.removeOnPictureInPictureModeChangedListener(pictureModeChangedInfoConsumer);
120
122
  }
121
123
  if (vdoPlayer != null) {
@@ -195,8 +197,7 @@ public class ReactVdoPlayerView extends FrameLayout implements LifecycleEventLis
195
197
  }
196
198
 
197
199
  public void setPictureInPictureSupport() {
198
- if (!isRunningOnTv()) {
199
- hasPictureInPictureSupport = true;
200
+ if (!isRunningOnTv(activity)) {
200
201
  pictureModeChangedInfoConsumer = pictureInPictureModeChangedInfo ->
201
202
  {
202
203
  eventEmitter.onPictureInPictureModeChanged(pictureInPictureModeChangedInfo.isInPictureInPictureMode());
@@ -206,6 +207,16 @@ public class ReactVdoPlayerView extends FrameLayout implements LifecycleEventLis
206
207
  }
207
208
  }
208
209
 
210
+ public void setResizeMode(String resizeModeName) {
211
+ this.resizeMode = resizeModeIntFromName(resizeModeName);
212
+ }
213
+
214
+ public void setAspectRatio(float aspectRatio) {
215
+ if( vdoPlayerUIFragment != null) {
216
+ vdoPlayerUIFragment.setAspectRatio(aspectRatio);
217
+ }
218
+ }
219
+
209
220
  private void initializeMediaSession() {
210
221
  mSession = new MediaSessionCompat(activity, TAG);
211
222
  mSession.setActive(true);
@@ -384,11 +395,6 @@ public class ReactVdoPlayerView extends FrameLayout implements LifecycleEventLis
384
395
  eventEmitter.setViewId(id);
385
396
  }
386
397
 
387
- private boolean isRunningOnTv() {
388
- UiModeManager uiModeManager = (UiModeManager) activity.getSystemService(Context.UI_MODE_SERVICE);
389
- return uiModeManager.getCurrentModeType() == Configuration.UI_MODE_TYPE_TELEVISION;
390
- }
391
-
392
398
  @Override
393
399
  protected void onAttachedToWindow() {
394
400
  Log.d(TAG, "onAttachedToWindow");
@@ -469,9 +475,7 @@ public class ReactVdoPlayerView extends FrameLayout implements LifecycleEventLis
469
475
  pendingInitParams = null;
470
476
  }
471
477
 
472
- if (hasPictureInPictureSupport) {
473
- initializeMediaSession();
474
- }
478
+ initializeMediaSession();
475
479
  }
476
480
 
477
481
  @Override
@@ -528,9 +532,7 @@ private final VdoPlayer.PlaybackEventListener playbackListener = new VdoPlayer.P
528
532
  // We are playing the video now. Update the media session state and the PiP
529
533
  // window will update the actions.
530
534
 
531
- if (hasPictureInPictureSupport) {
532
- updatePlaybackState(playing ? PlaybackStateCompat.STATE_PLAYING : PlaybackStateCompat.STATE_PAUSED, vdoPlayer.getCurrentTime(), vdoPlayer.getPlaybackSpeed());
533
- }
535
+ updatePlaybackState(playing ? PlaybackStateCompat.STATE_PLAYING : PlaybackStateCompat.STATE_PAUSED, vdoPlayer.getCurrentTime(), vdoPlayer.getPlaybackSpeed());
534
536
 
535
537
  if (playing) {
536
538
  //Request audio focus and notify other players to stop playback.
@@ -70,7 +70,6 @@ public class ReactVdoPlayerViewManager extends ViewGroupManager<ReactVdoPlayerVi
70
70
  embedInfo.getString("safetyNetApiKey") : null;
71
71
  boolean allowAdbDebugging = !embedInfo.hasKey("allowAdbDebugging") ||
72
72
  embedInfo.getBoolean("allowAdbDebugging");
73
- boolean setPictureInPictureSupport = embedInfo.hasKey("setPictureInPictureSupport") && embedInfo.getBoolean("setPictureInPictureSupport");
74
73
 
75
74
  VdoInitParams.Builder builder = new VdoInitParams.Builder();
76
75
 
@@ -119,10 +118,6 @@ public class ReactVdoPlayerViewManager extends ViewGroupManager<ReactVdoPlayerVi
119
118
  }
120
119
 
121
120
  initParams = builder.build();
122
-
123
- if (setPictureInPictureSupport) {
124
- vdoPlayerView.setPictureInPictureSupport();
125
- }
126
121
 
127
122
  vdoPlayerView.load(initParams);
128
123
  }
@@ -177,4 +172,14 @@ public class ReactVdoPlayerViewManager extends ViewGroupManager<ReactVdoPlayerVi
177
172
  void onVideoPlayerViewInitialised(ReactVdoPlayerView vdoPlayerView);
178
173
  }
179
174
 
175
+ @ReactProp(name = "resizeMode")
176
+ public void setResizeMode(ReactVdoPlayerView vdoPlayerView, String resizeMode) {
177
+ vdoPlayerView.setResizeMode(resizeMode);
178
+ }
179
+
180
+ @ReactProp(name = "aspectRatio")
181
+ public void setAspectRatio(ReactVdoPlayerView vdoPlayerView, float aspectRatio) {
182
+ vdoPlayerView.setAspectRatio(aspectRatio);
183
+ }
184
+
180
185
  }
@@ -12,6 +12,11 @@ import com.vdocipher.aegis.offline.DownloadOptions;
12
12
  import com.vdocipher.aegis.offline.DownloadStatus;
13
13
  import com.vdocipher.aegis.offline.VdoDownloadManager;
14
14
  import com.vdocipher.aegis.player.VdoPlayer;
15
+ import com.vdocipher.aegis.player.PlayerHost;
16
+ import android.app.UiModeManager;
17
+ import android.content.Context;
18
+ import android.content.res.Configuration;
19
+ import androidx.appcompat.app.AppCompatActivity;
15
20
 
16
21
  import java.util.List;
17
22
 
@@ -284,6 +289,19 @@ public class Utils {
284
289
  }
285
290
  }
286
291
 
292
+ public static int resizeModeIntFromName(String resizeModeName) {
293
+ switch (resizeModeName) {
294
+ case "contain":
295
+ return PlayerHost.RESIZE_MODE_FIT;
296
+ case "cover":
297
+ return PlayerHost.RESIZE_MODE_ZOOM;
298
+ case "stretch":
299
+ return PlayerHost.RESIZE_MODE_FILL;
300
+ default:
301
+ return PlayerHost.RESIZE_MODE_FIT;
302
+ }
303
+ }
304
+
287
305
  public static String digitalClockTime(int timeInMilliSeconds) {
288
306
  int totalSeconds = timeInMilliSeconds/1000;
289
307
  int hours = totalSeconds / (60 * 60);
@@ -366,4 +384,9 @@ public class Utils {
366
384
  return null;
367
385
  }
368
386
  }
387
+
388
+ public static boolean isRunningOnTv(AppCompatActivity activity) {
389
+ UiModeManager uiModeManager = (UiModeManager) activity.getSystemService(Context.UI_MODE_SERVICE);
390
+ return uiModeManager.getCurrentModeType() == Configuration.UI_MODE_TYPE_TELEVISION;
391
+ }
369
392
  }
@@ -0,0 +1,29 @@
1
+ import { NativeEventEmitter } from 'react-native';
2
+ import { DownloadStatus } from './type';
3
+
4
+ const eventEmitter = new NativeEventEmitter();
5
+
6
+ const nativeEvents = ['onQueued', 'onChanged', 'onCompleted', 'onFailed', 'onDeleted'];
7
+
8
+ nativeEvents.forEach((name) => {
9
+ eventEmitter.addListener(name, (event: {mediaId: string, downloadStatus: DownloadStatus}) => {
10
+ _emitEvent(name, event.mediaId, event.downloadStatus);
11
+ });
12
+ });
13
+
14
+ var _eventListeners: {[index: string]: any} = {};
15
+
16
+ var _emitEvent = (eventName: string, mediaId: string, downloadStatus: DownloadStatus) => {
17
+ if (!_eventListeners[eventName]) {
18
+ return;
19
+ }
20
+ _eventListeners[eventName].forEach((fn: (mediaId: string, downloadStatus: DownloadStatus) => void) => fn(mediaId, downloadStatus));
21
+ };
22
+
23
+ var addEventListener = (eventName: string, fn: (mediaId: string, downloadStatus: DownloadStatus) => void) => {
24
+ const list = _eventListeners[eventName] = _eventListeners[eventName] || [];
25
+ list.push(fn);
26
+ return () => list.splice(list.findIndex((f: (mediaId: string, downloadStatus: DownloadStatus) => void) => f === fn), 1);
27
+ };
28
+
29
+ export default addEventListener;
@@ -8,18 +8,19 @@
8
8
 
9
9
  import { NativeModules } from 'react-native';
10
10
  import addEventListener from './downloadMonitor';
11
+ import * as VdoTypes from './type';
11
12
 
12
13
  const { VdoDownload } = NativeModules;
13
14
 
14
- const getDownloadOptions = (optionParams) => {
15
+ const getDownloadOptions = (optionParams: VdoTypes.EmbedInfo) => {
15
16
 
16
17
  return new Promise(function(resolve, reject) {
17
18
  VdoDownload.getDownloadOptions(
18
19
  optionParams,
19
- (errorDescription) => {
20
+ (errorDescription: {errorCode: number, errorMsg: string, httpStatusCode: number}) => {
20
21
  reject(errorDescription);
21
22
  },
22
- (nativeId, downloadOptions) => {
23
+ (nativeId: string, downloadOptions: VdoTypes.DownloadOptions) => {
23
24
  resolve({
24
25
  downloadOptions,
25
26
  enqueue: getEnqueueFn(nativeId)
@@ -29,9 +30,9 @@ const getDownloadOptions = (optionParams) => {
29
30
  });
30
31
  };
31
32
 
32
- const getEnqueueFn = (nativeId) => (downloadOptions) => {
33
+ const getEnqueueFn = (nativeId: string) => (downloadOptions: {selections: Array<number>}) => {
33
34
 
34
- return new Promise(function(resolve, reject) {
35
+ return new Promise<void>(function(resolve, reject) {
35
36
  const requestOptions = {
36
37
  selections: downloadOptions.selections
37
38
  };
@@ -39,7 +40,7 @@ const getEnqueueFn = (nativeId) => (downloadOptions) => {
39
40
  VdoDownload.enqueueDownload(
40
41
  nativeId,
41
42
  requestOptions,
42
- (exception, msg) => {
43
+ (exception: string | null, msg: string) => {
43
44
  reject({exception, msg});
44
45
  },
45
46
  () => {
@@ -50,15 +51,15 @@ const getEnqueueFn = (nativeId) => (downloadOptions) => {
50
51
  });
51
52
  };
52
53
 
53
- const query = (queryFilters) => {
54
+ const query = (queryFilters: {mediaId: Array<string>, status: Array<string>}) => {
54
55
 
55
56
  return new Promise(function(resolve, reject) {
56
57
  VdoDownload.query(
57
58
  queryFilters,
58
- (exception, msg) => {
59
+ (exception: string, msg: string) => {
59
60
  reject({exception, msg});
60
61
  },
61
- (downloadStatusArray) => {
62
+ (downloadStatusArray: Array<VdoTypes.DownloadStatus>) => {
62
63
  // Query completed
63
64
  resolve(downloadStatusArray);
64
65
  }
@@ -66,12 +67,12 @@ const query = (queryFilters) => {
66
67
  });
67
68
  };
68
69
 
69
- const remove = (mediaIds) => {
70
+ const remove = (mediaIds: Array<string>) => {
70
71
 
71
- return new Promise(function(resolve, reject) {
72
+ return new Promise<void>(function(resolve, reject) {
72
73
  VdoDownload.remove(
73
74
  mediaIds,
74
- (exception, msg) => {
75
+ (exception: string, msg: string) => {
75
76
  reject({exception, msg});
76
77
  },
77
78
  () => {
@@ -82,6 +83,8 @@ const remove = (mediaIds) => {
82
83
  });
83
84
  };
84
85
 
86
+ export default VdoDownload;
87
+
85
88
  module.exports = {
86
89
  getDownloadOptions,
87
90
  query,
@@ -9,18 +9,20 @@
9
9
  * }
10
10
  * })
11
11
  */
12
- import { NativeModules } from 'react-native';
13
- import VdoPlayerView from './VdoPlayerView';
14
- import VdoDownload from './downloads';
15
-
16
- const { VdocipherRnBridge } = NativeModules;
17
-
18
- const startVideoScreen = (params) => {
19
- VdocipherRnBridge.startVideoScreen(params);
20
- }
21
-
22
- export {
23
- startVideoScreen,
24
- VdoPlayerView,
25
- VdoDownload
26
- }
12
+ import { NativeModules } from 'react-native';
13
+ import VdoPlayerView from './VdoPlayerView';
14
+ import VdoDownload from './downloads';
15
+ import { EmbedInfo } from './type';
16
+
17
+ const { VdocipherRnBridge } = NativeModules;
18
+
19
+ const startVideoScreen = (params: {embedInfo: EmbedInfo}) => {
20
+ VdocipherRnBridge.startVideoScreen(params);
21
+ }
22
+
23
+ export {
24
+ startVideoScreen,
25
+ VdoPlayerView,
26
+ VdoDownload
27
+ }
28
+
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vdocipher-rn-bridge",
3
- "version": "1.12.2",
3
+ "version": "1.13.0",
4
4
  "description": "React native bridge library that delegates to vdocipher native android SDK",
5
5
  "homepage": "https://www.vdocipher.com/docs/mobile/react-native/getting-started/",
6
6
  "scripts": {
@@ -22,12 +22,23 @@
22
22
  "android/build.gradle",
23
23
  "android/src",
24
24
  "ios",
25
- "VdoPlayerView.js",
26
- "VdoPlayerSupportView.js",
27
- "VdoPlayerUIView.js",
28
- "downloads.js",
29
- "downloadMonitor.js",
30
- "index.android.js",
31
- "index.ios.js"
32
- ]
25
+ "VdoPlayerView.tsx",
26
+ "VdoPlayerSupportView.tsx",
27
+ "VdoPlayerUIView.tsx",
28
+ "downloads.ts",
29
+ "downloadMonitor.ts",
30
+ "index.ts",
31
+ "tsconfig.json",
32
+ "type.ts"
33
+ ],
34
+ "devDependencies": {
35
+ "@tsconfig/react-native": "^2.0.3",
36
+ "@types/jest": "^29.4.0",
37
+ "@types/node": "^18.11.18",
38
+ "@types/prop-types": "^15.7.5",
39
+ "@types/react": "18.0.0",
40
+ "@types/react-native": "0.70",
41
+ "@types/react-test-renderer": "^18.0.0",
42
+ "typescript": "^4.9.4"
43
+ }
33
44
  }
package/tsconfig.json ADDED
@@ -0,0 +1,107 @@
1
+ {
2
+ "compilerOptions": {
3
+ /* Visit https://aka.ms/tsconfig to read more about this file */
4
+
5
+ /* Projects */
6
+ // "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */
7
+ // "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */
8
+ // "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */
9
+ // "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */
10
+ // "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */
11
+ // "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
12
+
13
+ /* Language and Environment */
14
+ "target": "ES6", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
15
+ // "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
16
+ "jsx": "react-native", /* Specify what JSX code is generated. */
17
+ // "experimentalDecorators": true, /* Enable experimental support for TC39 stage 2 draft decorators. */
18
+ // "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */
19
+ // "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */
20
+ // "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */
21
+ // "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */
22
+ // "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */
23
+ // "noLib": true, /* Disable including any library files, including the default lib.d.ts. */
24
+ // "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */
25
+ // "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */
26
+
27
+ /* Modules */
28
+ "module": "ES6", /* Specify what module code is generated. */
29
+ // "rootDir": "./", /* Specify the root folder within your source files. */
30
+ "moduleResolution": "node", /* Specify how TypeScript looks up a file from a given module specifier. */
31
+ // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
32
+ // "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
33
+ // "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
34
+ "typeRoots": ["./node_modules/@types"], /* Specify multiple folders that act like './node_modules/@types'. */
35
+ "types": ["node"], /* Specify type package names to be included without being referenced in a source file. */
36
+ // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
37
+ // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */
38
+ // "resolveJsonModule": true, /* Enable importing .json files. */
39
+ // "noResolve": true, /* Disallow 'import's, 'require's or '<reference>'s from expanding the number of files TypeScript should add to a project. */
40
+
41
+ /* JavaScript Support */
42
+ // "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */
43
+ // "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */
44
+ // "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */
45
+
46
+ /* Emit */
47
+ // "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */
48
+ // "declarationMap": true, /* Create sourcemaps for d.ts files. */
49
+ // "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */
50
+ // "sourceMap": true, /* Create source map files for emitted JavaScript files. */
51
+ // "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */
52
+ // "outDir": "./", /* Specify an output folder for all emitted files. */
53
+ // "removeComments": true, /* Disable emitting comments. */
54
+ "noEmit": true, /* Disable emitting files from a compilation. */
55
+ // "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
56
+ // "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types. */
57
+ // "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */
58
+ // "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */
59
+ // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
60
+ // "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */
61
+ // "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */
62
+ // "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */
63
+ // "newLine": "crlf", /* Set the newline character for emitting files. */
64
+ // "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */
65
+ // "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */
66
+ // "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */
67
+ // "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */
68
+ // "declarationDir": "./", /* Specify the output directory for generated declaration files. */
69
+ // "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */
70
+
71
+ /* Interop Constraints */
72
+ // "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */
73
+ "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */
74
+ "esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */
75
+ // "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */
76
+ "forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */
77
+
78
+ /* Type Checking */
79
+ "strict": true, /* Enable all strict type-checking options. */
80
+ "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */
81
+ "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */
82
+ // "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */
83
+ // "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */
84
+ // "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */
85
+ // "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */
86
+ // "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */
87
+ // "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */
88
+ // "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */
89
+ // "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */
90
+ // "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */
91
+ // "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */
92
+ // "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */
93
+ // "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */
94
+ // "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */
95
+ // "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */
96
+ // "allowUnusedLabels": true, /* Disable error reporting for unused labels. */
97
+ // "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */
98
+
99
+ /* Completeness */
100
+ // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
101
+ "skipLibCheck": true /* Skip type checking all .d.ts files. */
102
+ }
103
+ }
104
+
105
+ // {
106
+ // "extends": "@tsconfig/react-native/tsconfig.json"
107
+ // }
package/type.ts ADDED
@@ -0,0 +1,155 @@
1
+ import PropTypes from 'prop-types';
2
+
3
+ export interface EmbedInfo {
4
+ otp: string;
5
+ playbackInfo: string;
6
+ forceLowestBitrate?: boolean | null;
7
+ forceHighestSupportedBitrate?: boolean | null;
8
+ maxVideoBitrateKbps?: number | null;
9
+ bufferingGoalMs?: number | null;
10
+ enableAutoResume?: boolean | null;
11
+ safetyNetApiKey?: string | null;
12
+ preferredCaptionsLanguage?: string | null;
13
+ playerConfig?: string | null;
14
+ /**
15
+ * @deprecated
16
+ * This property is no longer required to enable PIP mode.
17
+ * Use {@link https://developer.android.com/reference/android/app/Activity#enterPictureInPictureMode(android.app.PictureInPictureParams)} at activity level instead.
18
+ */
19
+ setPictureInPictureSupport?: boolean | null;
20
+ }
21
+
22
+ export type OfflineEmbedInfo = {
23
+ offline: boolean;
24
+ mediaId: string;
25
+ enableAutoResume?: boolean | null;
26
+ safetyNetApiKey?: string | null;
27
+ preferredCaptionsLanguage?: string | null;
28
+ playerConfig?: string | null;
29
+ setPictureInPictureSupport?: boolean | null;
30
+ }
31
+
32
+ export interface MediaInfo {
33
+ mediaId: string;
34
+ type: string;
35
+ title: string;
36
+ description: string;
37
+ duration: number;
38
+ }
39
+
40
+ export interface DownloadOptions {
41
+ mediaId: string;
42
+ mediaInfo: MediaInfo;
43
+ availableTracks: Array<Track>;
44
+ }
45
+
46
+ export interface Track {
47
+ id: number;
48
+ type: string;
49
+ language: string;
50
+ bitrate: number;
51
+ width: number;
52
+ height: number;
53
+ label: string;
54
+ }
55
+
56
+ export interface DownloadStatus {
57
+ mediaInfo: MediaInfo;
58
+ localStorageFolder: string;
59
+ status: string;
60
+ reason: number;
61
+ reasonDescription: string;
62
+ totalSizeBytes: number;
63
+ bytesDownloaded: number;
64
+ downloadPercent: number;
65
+ poster: string;
66
+ lastModifiedTimestamp: number;
67
+ }
68
+
69
+ export interface VideoQuality {
70
+ id: number;
71
+ bitrate: number;
72
+ width: number;
73
+ height: number;
74
+ }
75
+
76
+ export interface AudioQuality {
77
+ id: number;
78
+ bitrate: number;
79
+ width: number;
80
+ height: number;
81
+ }
82
+
83
+ export interface CaptionLanguage {
84
+ id: number;
85
+ language: string;
86
+ label: string;
87
+ }
88
+
89
+ export const VdoPropTypes = {
90
+ /* Native only */
91
+ onInitSuccess: PropTypes.func,
92
+ onInitFailure: PropTypes.func,
93
+ onVdoLoading: PropTypes.func,
94
+ onVdoLoaded: PropTypes.func,
95
+ onVdoLoadError: PropTypes.func,
96
+ onVdoPlayerStateChanged: PropTypes.func,
97
+ onVdoProgress: PropTypes.func,
98
+ onVdoBufferUpdate: PropTypes.func,
99
+ onVdoPlaybackSpeedChanged: PropTypes.func,
100
+ onVdoTracksChanged: PropTypes.func,
101
+ onVdoMediaEnded: PropTypes.func,
102
+ onVdoError: PropTypes.func,
103
+ playbackProperties: PropTypes.number,
104
+ onVdoPlaybackProperties: PropTypes.func,
105
+ seek: PropTypes.number,
106
+ fullscreen: PropTypes.bool,
107
+ onVdoEnterFullscreen: PropTypes.func,
108
+ onVdoExitFullscreen: PropTypes.func,
109
+ onIsInitialPortrait: PropTypes.func,
110
+ onVdoPictureInPictureModeChanged: PropTypes.func,
111
+
112
+ /* Wrapper component public api */
113
+ embedInfo: PropTypes.oneOfType([
114
+ PropTypes.shape({
115
+ otp: PropTypes.string.isRequired,
116
+ playbackInfo: PropTypes.string.isRequired,
117
+ forceLowestBitrate: PropTypes.bool,
118
+ forceHighestSupportedBitrate: PropTypes.bool,
119
+ maxVideoBitrateKbps: PropTypes.number,
120
+ bufferingGoalMs: PropTypes.number,
121
+ enableAutoResume: PropTypes.bool,
122
+ safetyNetApiKey: PropTypes.string,
123
+ preferredCaptionsLanguage: PropTypes.string,
124
+ playerConfig: PropTypes.string,
125
+ }),
126
+ PropTypes.shape({
127
+ offline: PropTypes.bool.isRequired,
128
+ mediaId: PropTypes.string.isRequired,
129
+ enableAutoResume: PropTypes.bool,
130
+ safetyNetApiKey: PropTypes.string,
131
+ preferredCaptionsLanguage: PropTypes.string,
132
+ playerConfig: PropTypes.string,
133
+ })
134
+ ]).isRequired,
135
+ style: PropTypes.object,
136
+ showNativeControls: PropTypes.bool,
137
+ playWhenReady: PropTypes.bool,
138
+ playbackSpeed: PropTypes.number,
139
+ onInitializationSuccess: PropTypes.func,
140
+ onInitializationFailure: PropTypes.func,
141
+ onLoading: PropTypes.func,
142
+ onLoaded: PropTypes.func,
143
+ onLoadError: PropTypes.func,
144
+ onPlayerStateChanged: PropTypes.func,
145
+ onProgress: PropTypes.func,
146
+ onBufferUpdate: PropTypes.func,
147
+ onPlaybackSpeedChanged: PropTypes.func,
148
+ onTracksChanged: PropTypes.func,
149
+ onMediaEnded: PropTypes.func,
150
+ onError: PropTypes.func,
151
+ onPlaybackProperties: PropTypes.func,
152
+ onEnterFullscreen: PropTypes.func,
153
+ onExitFullscreen: PropTypes.func,
154
+ onPictureInPictureModeChanged: PropTypes.func,
155
+ }