Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix API docs problems #283

Merged
merged 4 commits into from
Oct 11, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
}
});
};

Comment on lines +42 to +70
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was just moved to avoid exporting it.

/**
* 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);
}
});
};
47 changes: 36 additions & 11 deletions src/subtitleTrack.ts
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got rid of MakeRequired as we don't need it at all.

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,40 @@ 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 {
/**
zigavehovec marked this conversation as resolved.
Show resolved Hide resolved
* The URL to the timed file, e.g. WebVTT file.
*/
url: string;
/**
* The label for this track.
*/
label: string;
/**
* The unique identifier for this track. If no value is provided, a random UUIDv4 will be generated for it.
*/
identifier?: string;
/**
* Specifies the file format to be used by this track.
*/
format: SubtitleFormat;
/**
* If set to true, this track would be considered as default. Default is `false`.
*/
isDefault?: boolean;
/**
* Tells if a subtitle track is forced. If set to `true` it means that the player should automatically
* select and switch this subtitle according to the selected audio language. Forced subtitles do
* not appear in `Player.getAvailableSubtitles`.
*
* Default is `false`.
*/
isForced?: boolean;
/**
* The IETF BCP 47 language tag associated with this track, e.g. `pt`, `en`, `es` etc.
*/
language: string;
}
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
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got rid of MakeRequired as we don't need it at all.

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
}
Loading