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

apply interface onProgressProps at base.d.ts #1342

Merged
merged 5 commits into from
Jul 15, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
37 changes: 26 additions & 11 deletions types/base.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import { Component, ReactElement, CSSProperties, ComponentType, ReactNode } from 'react'
import {
Component,
ReactElement,
CSSProperties,
ComponentType,
ReactNode
} from 'react'
import ReactPlayer from './lib'

interface SourceProps {
Expand All @@ -7,6 +13,13 @@ interface SourceProps {
type?: string
}

export interface OnProgressProps {
played: number
playedSeconds: number
loaded: number
loadedSeconds: number
}

export interface BaseReactPlayerProps {
url?: string | string[] | SourceProps[] | MediaStream
playing?: boolean
Expand All @@ -25,8 +38,8 @@ export interface BaseReactPlayerProps {
pip?: boolean
stopOnUnmount?: boolean
light?: boolean | string
fallback?: ReactElement;
wrapper?: ComponentType<{children: ReactNode}>;
fallback?: ReactElement
wrapper?: ComponentType<{ children: ReactNode }>
onReady?: (player: ReactPlayer) => void
onStart?: () => void
onPlay?: () => void
Expand All @@ -37,19 +50,21 @@ export interface BaseReactPlayerProps {
onClickPreview?: (event: any) => void
onEnablePIP?: () => void
onDisablePIP?: () => void
onError?: (error: any, data?: any, hlsInstance?: any, hlsGlobal?: any) => void
onError?: (
error: any,
data?: any,
hlsInstance?: any,
hlsGlobal?: any
) => void
onDuration?: (duration: number) => void
onSeek?: (seconds: number) => void
onProgress?: (state: {
played: number
playedSeconds: number
loaded: number
loadedSeconds: number
}) => void
onProgress?: (state: OnProgressProps) => void
[otherProps: string]: any
}

export default class BaseReactPlayer<T extends BaseReactPlayerProps> extends Component<T, any> {
export default class BaseReactPlayer<
T extends BaseReactPlayerProps
> extends Component<T, any> {
static canPlay (url: string): boolean;
static canEnablePIP (url: string): boolean;
static addCustomPlayer (player: ReactPlayer): void;
Expand Down