bitmovin-player-react-native
Advanced tools
Comparing version 0.9.2 to 0.10.0
233
lib/index.js
@@ -46,2 +46,5 @@ "use strict"; | ||
LoadingState: () => LoadingState, | ||
OfflineContentManager: () => OfflineContentManager, | ||
OfflineEventType: () => OfflineEventType, | ||
OfflineState: () => OfflineState, | ||
Player: () => Player, | ||
@@ -53,3 +56,5 @@ PlayerView: () => PlayerView, | ||
SubtitleFormat: () => SubtitleFormat, | ||
TimelineReferencePoint: () => TimelineReferencePoint, | ||
UserInterfaceType: () => UserInterfaceType, | ||
handleBitmovinNativeOfflineEvent: () => handleBitmovinNativeOfflineEvent, | ||
usePlayer: () => usePlayer | ||
@@ -684,2 +689,7 @@ }); | ||
})(LoadingState || {}); | ||
var TimelineReferencePoint = /* @__PURE__ */ ((TimelineReferencePoint2) => { | ||
TimelineReferencePoint2["START"] = "start"; | ||
TimelineReferencePoint2["END"] = "end"; | ||
return TimelineReferencePoint2; | ||
})(TimelineReferencePoint || {}); | ||
var Source = class extends NativeInstance { | ||
@@ -825,2 +835,12 @@ constructor() { | ||
/** | ||
* Loads the downloaded content from `OfflineContentManager` into the player. | ||
*/ | ||
__publicField(this, "loadOfflineContent", (offlineContentManager, options) => { | ||
PlayerModule.loadOfflineContent( | ||
this.nativeId, | ||
offlineContentManager.nativeId, | ||
options | ||
); | ||
}); | ||
/** | ||
* Loads the given `Source` into the player. | ||
@@ -1033,2 +1053,11 @@ */ | ||
}); | ||
/** | ||
* Sets the upper bitrate boundary for video qualities. All qualities with a bitrate | ||
* that is higher than this threshold will not be eligible for automatic quality selection. | ||
* | ||
* Can be set to `undefined` for no limitation. | ||
*/ | ||
__publicField(this, "setMaxSelectableBitrate", (bitrate) => { | ||
PlayerModule.setMaxSelectableBitrate(this.nativeId, bitrate || -1); | ||
}); | ||
} | ||
@@ -1102,2 +1131,201 @@ }; | ||
}; | ||
// src/offline/offlineState.ts | ||
var OfflineState = /* @__PURE__ */ ((OfflineState2) => { | ||
OfflineState2["Downloaded"] = "Downloaded"; | ||
OfflineState2["Downloading"] = "Downloading"; | ||
OfflineState2["Suspended"] = "Suspended"; | ||
OfflineState2["NotDownloaded"] = "NotDownloaded"; | ||
return OfflineState2; | ||
})(OfflineState || {}); | ||
// src/offline/offlineContentManager.ts | ||
var import_react_native12 = require("react-native"); | ||
// src/offline/offlineContentManagerListener.ts | ||
var OfflineEventType = /* @__PURE__ */ ((OfflineEventType2) => { | ||
OfflineEventType2["onCompleted"] = "onCompleted"; | ||
OfflineEventType2["onError"] = "onError"; | ||
OfflineEventType2["onProgress"] = "onProgress"; | ||
OfflineEventType2["onOptionsAvailable"] = "onOptionsAvailable"; | ||
OfflineEventType2["onDrmLicenseUpdated"] = "onDrmLicenseUpdated"; | ||
OfflineEventType2["onDrmLicenseExpired"] = "onDrmLicenseExpired"; | ||
OfflineEventType2["onSuspended"] = "onSuspended"; | ||
OfflineEventType2["onResumed"] = "onResumed"; | ||
OfflineEventType2["onCanceled"] = "onCanceled"; | ||
return OfflineEventType2; | ||
})(OfflineEventType || {}); | ||
var handleBitmovinNativeOfflineEvent = (data, listeners) => { | ||
listeners.forEach((listener) => { | ||
if (!listener) | ||
return; | ||
if (data.eventType === "onCompleted" /* onCompleted */) { | ||
listener.onCompleted?.(data); | ||
} else if (data.eventType === "onError" /* onError */) { | ||
listener.onError?.(data); | ||
} else if (data.eventType === "onProgress" /* onProgress */) { | ||
listener.onProgress?.(data); | ||
} else if (data.eventType === "onOptionsAvailable" /* onOptionsAvailable */) { | ||
listener.onOptionsAvailable?.(data); | ||
} else if (data.eventType === "onDrmLicenseUpdated" /* onDrmLicenseUpdated */) { | ||
listener.onDrmLicenseUpdated?.(data); | ||
} else if (data.eventType === "onDrmLicenseExpired" /* onDrmLicenseExpired */) { | ||
listener.onDrmLicenseExpired?.(data); | ||
} else if (data.eventType === "onSuspended" /* onSuspended */) { | ||
listener.onSuspended?.(data); | ||
} else if (data.eventType === "onResumed" /* onResumed */) { | ||
listener.onResumed?.(data); | ||
} else if (data.eventType === "onCanceled" /* onCanceled */) { | ||
listener.onCanceled?.(data); | ||
} | ||
}); | ||
}; | ||
// src/offline/offlineContentManager.ts | ||
var OfflineModule = import_react_native12.NativeModules.BitmovinOfflineModule; | ||
var OfflineContentManager = class extends NativeInstance { | ||
constructor(config) { | ||
super(config); | ||
__publicField(this, "isInitialized", false); | ||
__publicField(this, "isDestroyed", false); | ||
__publicField(this, "eventSubscription"); | ||
__publicField(this, "listeners", /* @__PURE__ */ new Set()); | ||
__publicField(this, "drm"); | ||
/** | ||
* Allocates the native `OfflineManager` instance and its resources natively. | ||
* Registers the `DeviceEventEmitter` listener to receive data from the native `OfflineContentManagerListener` callbacks | ||
*/ | ||
__publicField(this, "initialize", async () => { | ||
let initPromise = Promise.resolve(); | ||
if (!this.isInitialized && this.config) { | ||
this.eventSubscription = new import_react_native12.NativeEventEmitter( | ||
OfflineModule | ||
).addListener( | ||
"BitmovinOfflineEvent", | ||
(data) => { | ||
if (this.nativeId !== data?.nativeId) { | ||
return; | ||
} | ||
handleBitmovinNativeOfflineEvent(data, this.listeners); | ||
} | ||
); | ||
if (this.config.sourceConfig.drmConfig) { | ||
this.drm = new Drm(this.config.sourceConfig.drmConfig); | ||
this.drm.initialize(); | ||
} | ||
initPromise = OfflineModule.initWithConfig( | ||
this.nativeId, | ||
{ | ||
identifier: this.config.identifier, | ||
sourceConfig: this.config.sourceConfig | ||
}, | ||
this.drm?.nativeId | ||
); | ||
} | ||
this.isInitialized = true; | ||
return initPromise; | ||
}); | ||
/** | ||
* Adds a listener to the receive data from the native `OfflineContentManagerListener` callbacks | ||
* Returns a function that removes this listener from the `OfflineContentManager` that registered it. | ||
*/ | ||
__publicField(this, "addListener", (listener) => { | ||
this.listeners.add(listener); | ||
return () => { | ||
this.listeners.delete(listener); | ||
}; | ||
}); | ||
/** | ||
* Destroys the native `OfflineManager` and releases all of its allocated resources. | ||
*/ | ||
__publicField(this, "destroy", async () => { | ||
if (!this.isDestroyed) { | ||
this.isDestroyed = true; | ||
this.eventSubscription?.remove?.(); | ||
this.listeners.clear(); | ||
this.drm?.destroy(); | ||
return OfflineModule.release(this.nativeId); | ||
} | ||
return Promise.resolve(); | ||
}); | ||
/** | ||
* Gets the current state of the `OfflineContentManager` | ||
*/ | ||
__publicField(this, "state", async () => { | ||
return OfflineModule.getState(this.nativeId); | ||
}); | ||
/** | ||
* Loads the current `OfflineContentOptions`. | ||
* When the options are loaded the data will be passed to the `OfflineContentManagerListener.onOptionsAvailable`. | ||
*/ | ||
__publicField(this, "getOptions", async () => { | ||
return OfflineModule.getOptions(this.nativeId); | ||
}); | ||
/** | ||
* Enqueues downloads according to the `OfflineDownloadRequest`. | ||
* The promise will reject in the event of null or invalid request parameters. | ||
* The promise will reject when calling this method when download has already started or is completed. | ||
* The promise will resolve when the download has been queued. The download will is not finished when the promise resolves. | ||
*/ | ||
__publicField(this, "download", async (request) => { | ||
return OfflineModule.download(this.nativeId, request); | ||
}); | ||
/** | ||
* Resumes all suspended actions. | ||
*/ | ||
__publicField(this, "resume", async () => { | ||
return OfflineModule.resume(this.nativeId); | ||
}); | ||
/** | ||
* Suspends all active actions. | ||
*/ | ||
__publicField(this, "suspend", async () => { | ||
return OfflineModule.suspend(this.nativeId); | ||
}); | ||
/** | ||
* Cancels and deletes the active download. | ||
*/ | ||
__publicField(this, "cancelDownload", async () => { | ||
return OfflineModule.cancelDownload(this.nativeId); | ||
}); | ||
/** | ||
* Resolves how many bytes of storage are used by the offline content. | ||
*/ | ||
__publicField(this, "usedStorage", async () => { | ||
return OfflineModule.usedStorage(this.nativeId); | ||
}); | ||
/** | ||
* Deletes everything related to the related content ID. | ||
*/ | ||
__publicField(this, "deleteAll", async () => { | ||
return OfflineModule.deleteAll(this.nativeId); | ||
}); | ||
/** | ||
* Downloads the offline license. | ||
* When finished successfully, data will be passed to the `OfflineContentManagerListener.onDrmLicenseUpdated`. | ||
* Errors are transmitted to the `OfflineContentManagerListener.onError`. | ||
*/ | ||
__publicField(this, "downloadLicense", async () => { | ||
return OfflineModule.downloadLicense(this.nativeId); | ||
}); | ||
/** | ||
* Releases the currently held offline license. | ||
* When finished successfully data will be passed to the `OfflineContentManagerListener.onDrmLicenseUpdated`. | ||
* Errors are transmitted to the `OfflineContentManagerListener.onError`. | ||
* | ||
* @platform Android | ||
*/ | ||
__publicField(this, "releaseLicense", async () => { | ||
return OfflineModule.releaseLicense(this.nativeId); | ||
}); | ||
/** | ||
* Renews the already downloaded DRM license. | ||
* When finished successfully data will be passed to the `OfflineContentManagerListener.onDrmLicenseUpdated`. | ||
* Errors are transmitted to the `OfflineContentManagerListener.onError`. | ||
*/ | ||
__publicField(this, "renewOfflineLicense", async () => { | ||
return OfflineModule.renewOfflineLicense(this.nativeId); | ||
}); | ||
} | ||
}; | ||
// Annotate the CommonJS export names for ESM import in node: | ||
@@ -1113,2 +1341,5 @@ 0 && (module.exports = { | ||
LoadingState, | ||
OfflineContentManager, | ||
OfflineEventType, | ||
OfflineState, | ||
Player, | ||
@@ -1120,4 +1351,6 @@ PlayerView, | ||
SubtitleFormat, | ||
TimelineReferencePoint, | ||
UserInterfaceType, | ||
handleBitmovinNativeOfflineEvent, | ||
usePlayer | ||
}); |
{ | ||
"name": "bitmovin-player-react-native", | ||
"version": "0.9.2", | ||
"version": "0.10.0", | ||
"description": "Official React Native bindings for Bitmovin's mobile Player SDKs.", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -0,1 +1,2 @@ | ||
export * from './adaptationConfig'; | ||
export * from './advertising'; | ||
@@ -13,1 +14,2 @@ export * from './analytics'; | ||
export * from './ui'; | ||
export * from './offline'; |
@@ -10,2 +10,4 @@ import { NativeModules, Platform } from 'react-native'; | ||
import { TweaksConfig } from './tweaksConfig'; | ||
import { AdaptationConfig } from './adaptationConfig'; | ||
import { OfflineContentManager, OfflineSourceOptions } from './offline'; | ||
@@ -57,2 +59,6 @@ const PlayerModule = NativeModules.PlayerModule; | ||
analyticsConfig?: AnalyticsConfig; | ||
/** | ||
* Configures adaptation logic. | ||
*/ | ||
adaptationConfig?: AdaptationConfig; | ||
} | ||
@@ -200,2 +206,16 @@ | ||
/** | ||
* Loads the downloaded content from `OfflineContentManager` into the player. | ||
*/ | ||
loadOfflineContent = ( | ||
offlineContentManager: OfflineContentManager, | ||
options?: OfflineSourceOptions | ||
) => { | ||
PlayerModule.loadOfflineContent( | ||
this.nativeId, | ||
offlineContentManager.nativeId, | ||
options | ||
); | ||
}; | ||
/** | ||
* Loads the given `Source` into the player. | ||
@@ -434,2 +454,12 @@ */ | ||
}; | ||
/** | ||
* Sets the upper bitrate boundary for video qualities. All qualities with a bitrate | ||
* that is higher than this threshold will not be eligible for automatic quality selection. | ||
* | ||
* Can be set to `undefined` for no limitation. | ||
*/ | ||
setMaxSelectableBitrate = (bitrate: number | null) => { | ||
PlayerModule.setMaxSelectableBitrate(this.nativeId, bitrate || -1); | ||
}; | ||
} |
@@ -49,2 +49,36 @@ import { NativeModules } from 'react-native'; | ||
/** | ||
* Types of SourceOptions. | ||
*/ | ||
export interface SourceOptions { | ||
/** | ||
* The position where the stream should be started. | ||
* Number can be positive or negative depending on the used `TimelineReferencePoint`. | ||
* Invalid numbers will be corrected according to the stream boundaries. | ||
* For VOD this is applied at the time the stream is loaded, for LIVE when playback starts. | ||
*/ | ||
startOffset?: number; | ||
/** | ||
* Sets the Timeline reference point to calculate the startOffset from. | ||
* Default for live: `TimelineReferencePoint.END`. | ||
* Default for VOD: `TimelineReferencePoint.START`. | ||
*/ | ||
startOffsetTimelineReference?: TimelineReferencePoint; | ||
} | ||
/** | ||
Timeline reference point to calculate SourceOptions.startOffset from. | ||
Default for live: TimelineReferencePoint.EBD Default for VOD: TimelineReferencePoint.START. | ||
*/ | ||
export enum TimelineReferencePoint { | ||
/** | ||
* Relative offset will be calculated from the beginning of the stream or DVR window. | ||
*/ | ||
START = 'start', | ||
/** | ||
* Relative offset will be calculated from the end of the stream or the live edge in case of a live stream with DVR window. | ||
*/ | ||
END = 'end', | ||
} | ||
/** | ||
* Represents a source configuration that be loaded into a player instance. | ||
@@ -90,2 +124,6 @@ */ | ||
metadata?: Record<string, string>; | ||
/** | ||
* The `SourceOptions` for this configuration. | ||
*/ | ||
options?: SourceOptions; | ||
} | ||
@@ -92,0 +130,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
702882
113
8744