Native Media Player for iOS, Android and Browser. Based on the great work of @jepiqueau
- iOS
- AVPlayer
- Android
- ExoPlayer3
- Web
- Vidstack
npm install @eduardoroth/media-player
npx cap sync
create(...)
play(...)
pause(...)
getDuration(...)
getCurrentTime(...)
setCurrentTime(...)
isPlaying(...)
isMuted(...)
setVisibilityBackgroundForPiP(...)
mute(...)
getVolume(...)
setVolume(...)
getRate(...)
setRate(...)
remove(...)
removeAll()
addListener('MediaPlayer:Ready', ...)
addListener('MediaPlayer:Play', ...)
addListener('MediaPlayer:Pause', ...)
addListener('MediaPlayer:Ended', ...)
addListener('MediaPlayer:Removed', ...)
addListener('MediaPlayer:Seek', ...)
addListener('MediaPlayer:TimeUpdated', ...)
addListener('MediaPlayer:FullScreen', ...)
addListener('MediaPlayer:PictureInPicture', ...)
addListener('MediaPlayer:isPlayingInBackground', ...)
removeAllListeners(...)
- Interfaces
- Type Aliases
create(options: MediaPlayerOptions) => Promise<MediaPlayerResult<string>>
Param | Type |
---|---|
options |
MediaPlayerOptions |
Returns: Promise<MediaPlayerResult<string>>
play(options: MediaPlayerIdOptions) => Promise<MediaPlayerResult<string>>
Param | Type |
---|---|
options |
MediaPlayerIdOptions |
Returns: Promise<MediaPlayerResult<string>>
pause(options: MediaPlayerIdOptions) => Promise<MediaPlayerResult<string>>
Param | Type |
---|---|
options |
MediaPlayerIdOptions |
Returns: Promise<MediaPlayerResult<string>>
getDuration(options: MediaPlayerIdOptions) => Promise<MediaPlayerResult<number>>
Param | Type |
---|---|
options |
MediaPlayerIdOptions |
Returns: Promise<MediaPlayerResult<number>>
getCurrentTime(options: MediaPlayerIdOptions) => Promise<MediaPlayerResult<number>>
Param | Type |
---|---|
options |
MediaPlayerIdOptions |
Returns: Promise<MediaPlayerResult<number>>
setCurrentTime(options: MediaPlayerSetCurrentTimeOptions) => Promise<MediaPlayerResult<number>>
Param | Type |
---|---|
options |
MediaPlayerSetCurrentTimeOptions |
Returns: Promise<MediaPlayerResult<number>>
isPlaying(options: MediaPlayerIdOptions) => Promise<MediaPlayerResult<boolean>>
Param | Type |
---|---|
options |
MediaPlayerIdOptions |
Returns: Promise<MediaPlayerResult<boolean>>
isMuted(options: MediaPlayerIdOptions) => Promise<MediaPlayerResult<boolean>>
Param | Type |
---|---|
options |
MediaPlayerIdOptions |
Returns: Promise<MediaPlayerResult<boolean>>
setVisibilityBackgroundForPiP(options: MediaPlayerSetVisibilityBackgroundForPiPOptions) => Promise<MediaPlayerResult<boolean>>
Param | Type |
---|---|
options |
MediaPlayerSetVisibilityBackgroundForPiPOptions |
Returns: Promise<MediaPlayerResult<boolean>>
mute(options: MediaPlayerIdOptions) => Promise<MediaPlayerResult<boolean>>
Param | Type |
---|---|
options |
MediaPlayerIdOptions |
Returns: Promise<MediaPlayerResult<boolean>>
getVolume(options: MediaPlayerIdOptions) => Promise<MediaPlayerResult<number>>
Param | Type |
---|---|
options |
MediaPlayerIdOptions |
Returns: Promise<MediaPlayerResult<number>>
setVolume(options: MediaPlayerSetVolumeOptions) => Promise<MediaPlayerResult<number>>
Param | Type |
---|---|
options |
MediaPlayerSetVolumeOptions |
Returns: Promise<MediaPlayerResult<number>>
getRate(options: MediaPlayerIdOptions) => Promise<MediaPlayerResult<number>>
Param | Type |
---|---|
options |
MediaPlayerIdOptions |
Returns: Promise<MediaPlayerResult<number>>
setRate(options: MediaPlayerSetRateOptions) => Promise<MediaPlayerResult<number>>
Param | Type |
---|---|
options |
MediaPlayerSetRateOptions |
Returns: Promise<MediaPlayerResult<number>>
remove(options: MediaPlayerIdOptions) => Promise<MediaPlayerResult<string>>
Param | Type |
---|---|
options |
MediaPlayerIdOptions |
Returns: Promise<MediaPlayerResult<string>>
removeAll() => Promise<MediaPlayerResult<string[]>>
Returns: Promise<MediaPlayerResult<string[]>>
addListener(event: 'MediaPlayer:Ready', listener: (event: { playerId: string; }) => void) => Promise<PluginListenerHandle>
Param | Type |
---|---|
event |
'MediaPlayer:Ready' |
listener |
(event: { playerId: string; }) => void |
Returns: Promise<PluginListenerHandle>
addListener(event: 'MediaPlayer:Play', listener: (event: { playerId: string; }) => void) => Promise<PluginListenerHandle>
Param | Type |
---|---|
event |
'MediaPlayer:Play' |
listener |
(event: { playerId: string; }) => void |
Returns: Promise<PluginListenerHandle>
addListener(event: 'MediaPlayer:Pause', listener: (event: { playerId: string; }) => void) => Promise<PluginListenerHandle>
Param | Type |
---|---|
event |
'MediaPlayer:Pause' |
listener |
(event: { playerId: string; }) => void |
Returns: Promise<PluginListenerHandle>
addListener(event: 'MediaPlayer:Ended', listener: (event: { playerId: string; }) => void) => Promise<PluginListenerHandle>
Param | Type |
---|---|
event |
'MediaPlayer:Ended' |
listener |
(event: { playerId: string; }) => void |
Returns: Promise<PluginListenerHandle>
addListener(event: 'MediaPlayer:Removed', listener: (event: { playerId: string; }) => void) => Promise<PluginListenerHandle>
Param | Type |
---|---|
event |
'MediaPlayer:Removed' |
listener |
(event: { playerId: string; }) => void |
Returns: Promise<PluginListenerHandle>
addListener(event: 'MediaPlayer:Seek', listener: (event: { playerId: string; previousTime: number | undefined; newTime: number; }) => void) => Promise<PluginListenerHandle>
Param | Type |
---|---|
event |
'MediaPlayer:Seek' |
listener |
(event: { playerId: string; previousTime: number; newTime: number; }) => void |
Returns: Promise<PluginListenerHandle>
addListener(event: 'MediaPlayer:TimeUpdated', listener: (event: { playerId: string; currentTime: number; }) => void) => Promise<PluginListenerHandle>
Param | Type |
---|---|
event |
'MediaPlayer:TimeUpdated' |
listener |
(event: { playerId: string; currentTime: number; }) => void |
Returns: Promise<PluginListenerHandle>
addListener(event: 'MediaPlayer:FullScreen', listener: (event: { playerId: string; isInFullScreen: boolean; }) => void) => Promise<PluginListenerHandle>
Param | Type |
---|---|
event |
'MediaPlayer:FullScreen' |
listener |
(event: { playerId: string; isInFullScreen: boolean; }) => void |
Returns: Promise<PluginListenerHandle>
addListener(event: 'MediaPlayer:PictureInPicture', listener: (event: { playerId: string; isInPictureInPicture: boolean; }) => void) => Promise<PluginListenerHandle>
Param | Type |
---|---|
event |
'MediaPlayer:PictureInPicture' |
listener |
(event: { playerId: string; isInPictureInPicture: boolean; }) => void |
Returns: Promise<PluginListenerHandle>
addListener(event: 'MediaPlayer:isPlayingInBackground', listener: (event: { playerId: string; isPlayingInBackground: boolean; }) => void) => Promise<PluginListenerHandle>
Param | Type |
---|---|
event |
'MediaPlayer:isPlayingInBackground' |
listener |
(event: { playerId: string; isPlayingInBackground: boolean; }) => void |
Returns: Promise<PluginListenerHandle>
removeAllListeners(options: MediaPlayerIdOptions) => Promise<void>
Param | Type |
---|---|
options |
MediaPlayerIdOptions |
Prop | Type |
---|---|
name |
string |
message |
string |
stack |
string |
Prop | Type |
---|---|
remove |
() => Promise<void> |
{ method: string; result: boolean; value?: ResultValueType; error?: Error; message?: string; }
{ playerId: string; url: string; ios?: MediaPlayerIosOptions; android?: MediaPlayerAndroidOptions; web?: MediaPlayerWebOptions; extra?: MediaPlayerExtraOptions; }
{ enableExternalPlayback?: boolean; enablePiP?: boolean; enableBackgroundPlay?: boolean; openInFullscreen?: boolean; automaticallyEnterPiP?: boolean; automaticallyHideBackgroundForPip?: boolean; fullscreenOnLandscape?: boolean; allowsVideoFrameAnalysis?: boolean; top?: number; left?: number; height?: number; width?: number; }
{ enableChromecast?: boolean; enablePiP?: boolean; enableBackgroundPlay?: boolean; openInFullscreen?: boolean; automaticallyEnterPiP?: boolean; fullscreenOnLandscape?: boolean; top?: number; start?: number; height?: number; width?: number; }
{ enableChromecast?: boolean; }
{ title?: string; subtitle?: string; poster?: string; artist?: string; rate?: number; subtitles?: MediaPlayerSubtitleOptions; autoPlayWhenReady?: boolean; loopOnEnd?: boolean; showControls?: boolean; headers?: { [key: string]: string; }; }
{ url: string; options?: { language?: string; foregroundColor?: string; backgroundColor?: string; fontSize?: number; }; }
{ playerId: string; }
{ playerId: string; time: number; }
{ playerId: string; isVisible: boolean; }
{ playerId: string; volume: number; }
{ playerId: string; rate: number; }