Skip to content

Commit

Permalink
Merge pull request #283 from bitmovin/fix-api-docs-problems
Browse files Browse the repository at this point in the history
Fix API docs problems
  • Loading branch information
rolandkakonyi authored Oct 11, 2023
2 parents ebb7495 + c73c55d commit 80a0b72
Show file tree
Hide file tree
Showing 9 changed files with 66 additions and 69 deletions.
2 changes: 2 additions & 0 deletions src/components/PlayerView/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ function dispatch(command: string, node: NodeHandle, ...args: any[]) {
/**
* Component that provides the Bitmovin Player UI and default UI handling to an attached `Player` instance.
* This component needs a `Player` instance to work properly so make sure one is passed to it as a prop.
*
* @param options configuration options
*/
export function PlayerView({
style,
Expand Down
3 changes: 3 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,6 @@ export * from './offline';
export * from './thumbnail';
export * from './remoteControlConfig';
export * from './bitmovinCastManager';
export * from './audioTrack';
export * from './media';
export * from './tweaksConfig';
31 changes: 30 additions & 1 deletion src/offline/offlineContentManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import NativeInstance from '../nativeInstance';
import { SourceConfig } from '../source';
import {
BitmovinNativeOfflineEventData,
handleBitmovinNativeOfflineEvent,
OfflineContentManagerListener,
OfflineEventType,
} from './offlineContentManagerListener';
import { OfflineContentConfig } from './offlineContentConfig';
import { OfflineDownloadRequest } from './offlineDownloadRequest';
Expand Down Expand Up @@ -39,6 +39,35 @@ interface NativeOfflineModule extends NativeModule {
const OfflineModule =
NativeModules.BitmovinOfflineModule as NativeOfflineModule;

const handleBitmovinNativeOfflineEvent = (
data: BitmovinNativeOfflineEventData,
listeners: Set<OfflineContentManagerListener>
) => {
listeners.forEach((listener) => {
if (!listener) return;

if (data.eventType === OfflineEventType.onCompleted) {
listener.onCompleted?.(data);
} else if (data.eventType === OfflineEventType.onError) {
listener.onError?.(data);
} else if (data.eventType === OfflineEventType.onProgress) {
listener.onProgress?.(data);
} else if (data.eventType === OfflineEventType.onOptionsAvailable) {
listener.onOptionsAvailable?.(data);
} else if (data.eventType === OfflineEventType.onDrmLicenseUpdated) {
listener.onDrmLicenseUpdated?.(data);
} else if (data.eventType === OfflineEventType.onDrmLicenseExpired) {
listener.onDrmLicenseExpired?.(data);
} else if (data.eventType === OfflineEventType.onSuspended) {
listener.onSuspended?.(data);
} else if (data.eventType === OfflineEventType.onResumed) {
listener.onResumed?.(data);
} else if (data.eventType === OfflineEventType.onCanceled) {
listener.onCanceled?.(data);
}
});
};

/**
* Provides the means to download and store sources locally that can be played back with a Player
* without an active network connection. An OfflineContentManager instance can be created via
Expand Down
29 changes: 0 additions & 29 deletions src/offline/offlineContentManagerListener.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,32 +156,3 @@ export interface OfflineContentManagerListener {
onResumed?: (e: OnResumedEvent) => void;
onCanceled?: (e: OnCanceledEvent) => void;
}

export const handleBitmovinNativeOfflineEvent = (
data: BitmovinNativeOfflineEventData,
listeners: Set<OfflineContentManagerListener>
) => {
listeners.forEach((listener) => {
if (!listener) return;

if (data.eventType === OfflineEventType.onCompleted) {
listener.onCompleted?.(data);
} else if (data.eventType === OfflineEventType.onError) {
listener.onError?.(data);
} else if (data.eventType === OfflineEventType.onProgress) {
listener.onProgress?.(data);
} else if (data.eventType === OfflineEventType.onOptionsAvailable) {
listener.onOptionsAvailable?.(data);
} else if (data.eventType === OfflineEventType.onDrmLicenseUpdated) {
listener.onDrmLicenseUpdated?.(data);
} else if (data.eventType === OfflineEventType.onDrmLicenseExpired) {
listener.onDrmLicenseExpired?.(data);
} else if (data.eventType === OfflineEventType.onSuspended) {
listener.onSuspended?.(data);
} else if (data.eventType === OfflineEventType.onResumed) {
listener.onResumed?.(data);
} else if (data.eventType === OfflineEventType.onCanceled) {
listener.onCanceled?.(data);
}
});
};
19 changes: 8 additions & 11 deletions src/subtitleTrack.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { MakeRequired } from './utils';

/**
* Supported subtitle/caption file formats.
*/
Expand All @@ -10,7 +8,7 @@ export enum SubtitleFormat {
}

/**
* Represents a custom subtitle track source that can be added to `SourceConfig.subtitleTracks`.
* Describes a subtitle track.
*/
export interface SubtitleTrack {
/**
Expand Down Expand Up @@ -48,13 +46,12 @@ export interface SubtitleTrack {
}

/**
* Helper type that represents an entry in `SourceConfig.subtitleTracks` list.
* A subtitle track that can be added to `SourceConfig.subtitleTracks`.
*
* Since `SubtitleTrack` has all of its properties as optionals for total compatibility with
* values that may be sent from native code, this type serves as a reinforcer of what properties
* should be required during the registration of an external subtitle track from JS.
*/
export type SideLoadedSubtitleTrack = MakeRequired<
SubtitleTrack,
'url' | 'label' | 'language' | 'format'
>;
export interface SideLoadedSubtitleTrack extends SubtitleTrack {
url: string;
label: string;
language: string;
format: SubtitleFormat;
}
32 changes: 20 additions & 12 deletions src/ui/custommessagehandler.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,22 @@
import { CustomMessageSender } from './custommessagesender';

export interface CustomMessageHandlerProps {
/**
* A function that will be called when the Player UI sends a synchronous message to the integration.
*/
onReceivedSynchronousMessage: (
message: string,
data: string | undefined
) => string | undefined;
/**
* A function that will be called when the Player UI sends an asynchronous message to the integration.
*/
onReceivedAsynchronousMessage: (
message: string,
data: string | undefined
) => void;
}

/**
* Android and iOS only.
* For Android it requires Player SDK version 3.39.0 or higher.
Expand All @@ -16,29 +33,20 @@ export class CustomMessageHandler {
data: string | undefined
) => void;

/** @internal */
customMessageSender?: CustomMessageSender;

/**
* Android and iOS only.
*
* Creates a new `CustomMessageHandler` instance to handle two-way communication between the integation and the Player UI.
*
* @param onReceivedSynchronousMessage - A function that will be called when the Player UI sends a synchronous message to the integration.
* @param onReceivedAsynchronousMessage - A function that will be called when the Player UI sends an asynchronous message to the integration.
* @param options - Configuration options for the `CustomMessageHandler` instance.
*/
constructor({
onReceivedSynchronousMessage,
onReceivedAsynchronousMessage,
}: {
onReceivedSynchronousMessage: (
message: string,
data: string | undefined
) => string | undefined;
onReceivedAsynchronousMessage: (
message: string,
data: string | undefined
) => void;
}) {
}: CustomMessageHandlerProps) {
this.onReceivedSynchronousMessage = onReceivedSynchronousMessage;
this.onReceivedAsynchronousMessage = onReceivedAsynchronousMessage;
}
Expand Down
1 change: 1 addition & 0 deletions src/ui/custommessagesender.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/** @internal */
export interface CustomMessageSender {
sendMessage(message: string, data: string | undefined): void;
}
15 changes: 0 additions & 15 deletions src/utils.ts

This file was deleted.

3 changes: 2 additions & 1 deletion typedoc.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@
"excludeExternals": true,
"includeVersion": true,
"entryPoints": ["./src"],
"exclude": ["./example/**/*"]
"exclude": ["./example/**/*"],
"treatWarningsAsErrors": true
}

0 comments on commit 80a0b72

Please sign in to comment.