@enact/ui
Version:
A collection of simplified unstyled cross-platform UI components for Enact
100 lines (94 loc) • 2.63 kB
TypeScript
// Type definitions for ui/Media
import * as React from "react";
type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;
type Merge<M, N> = Omit<M, Extract<keyof M, keyof N>> & N;
/**
* Generates a key representing the source node or nodes provided
*
* Example:
* ```
getKeyFromSource('path/file.mp4'); // 'path/file.mp4'
getKeyFromSource(
<source src="path/file.mp4" type="video/mp4" />
); // 'path/file.mp4'
getKeyFromSource([
<source src="path/file.mp4" type="video/mp4" />,
<source src="path/file.ogg" type="video/ogg" />,
]); // 'path/file.mp4+path/file.ogg'
```
*/
export function getKeyFromSource(
source: string | JSX.Element | JSX.Element[],
): string;
/**
* Maps standard media event `type` values to React-style callback prop names
*
* See
* ```
{
abort : 'onAbort',
canplay : 'onCanPlay',
canplaythrough : 'onCanPlayThrough',
durationchange : 'onDurationChange',
emptied : 'onEmptied',
encrypted : 'onEncrypted',
ended : 'onEnded',
error : 'onError',
loadeddata : 'onLoadedData',
loadedmetadata : 'onLoadedMetadata',
loadstart : 'onLoadStart',
pause : 'onPause',
play : 'onPlay',
playing : 'onPlaying',
progress : 'onProgress',
ratechange : 'onRateChange',
seeked : 'onSeeked',
seeking : 'onSeeking',
stalled : 'onStalled',
suspend : 'onSuspend',
timeupdate : 'onTimeUpdate',
volumechange : 'onVolumeChange',
waiting : 'onWaiting'
}
```
*/
export interface handledMediaEventsMap {}
export interface MediaProps {
/**
* A type of media component.
*/
mediaComponent: string | React.ComponentType;
/**
* An event map object for custom media events.
*
* List custom events that aren't standard to React. These will be directly added to the media
element and props matching their name will be executed as callback functions when the event fires.
*
* Example:
* ```
{'umsmediainfo': 'onUMSMediaInfo'} // `onUMSMediaInfo` prop function will execute when the `umsmediainfo` event happens
```
*/
customMediaEventsMap?: object;
/**
* A event map object for media events.
*/
mediaEventsMap?: object;
/**
* A function to be run when media updates.
*/
onUpdate?: Function;
/**
* Media sources passed as children to `mediaComponent`
*
* See:
*/
source?: any;
}
/**
* A component representation of HTMLMediaElement.
*/
export class Media extends React.Component<
Merge<React.HTMLProps<HTMLElement>, MediaProps>
> {}
export default Media;