Skip to content

Latest commit

 

History

History
593 lines (379 loc) · 23.3 KB

API.md

File metadata and controls

593 lines (379 loc) · 23.3 KB

API Documentation

Methods Index

* [Listeners](#listeners)

Url

from the Web

. http:/..../video.mp4 . https:/..../video.mp4

from Asset

  • iOS Plugin . "public/assets/video/video.mp4"

  • Android Plugin . "public/assets/video/video.mp4" not anymore the resource/raw folder

  • Web & Electron Plugins . "assets/video/video.mp4"

from Application Folder

  • iOS Plugin . application/files/video.mp4 is corresponding to : /data/Containers/Data/Applications/YOUR_APPLICATION/Documents/files/video.mp4

  • Android Plugin . application/files/video.mp4 is corresponding to : /data/user/0/YOUR_APPLICATION_PACKAGE/files/video.mp4

from your Device Media

  • iOS & Android Plugin only . internal

from DCIM folder

  • Android Plugin . file:///sdcard/DCIM/Camera/YOUR_VIDEO . file:///storage/extSdCard/DCIM/Camera/YOUR_VIDEO

  • iOS Plugin . file:///var/mobile/Media/DCIM/100APPLE/YOUR_VIDEO . file:///var/mobile/Containers/Data/Application/YOUR_APPLICATION_ID/tmp/YOUR_VIDEO

Subtitle (Android, iOS Only)

Supported Formats

  • Android Plugin . WebVTT .vtt extension . TTML/SMPTE .ttml, .dfxp, .xml extensions . SubRip .srt extension . SubStationAlpha .ssa, .ass extensions

  • iOS Plugin . WebVTT .vtt extension

from the Web

. http:/..../video.vtt . https:/..../video.vtt

from Asset

  • Android Plugin . "public/assets/video/video.srt"

  • iOS Plugin . "public/assets/video/video.vtt"

from Application Folder

  • Android Plugin . application/files/video.vtt is corresponding to : /data/user/0/YOUR_APPLICATION_PACKAGE/files//video.vtt

  • iOS Plugin . application/files/video.vtt is corresponding to : /data/Containers/Data/Applications/YOUR_APPLICATION/Documents/files/video.vtt

from Internal (Gallery, DCIM)

  • Android plugin .for API higher than 28 add the following in the app manifest file

        <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" android:maxSdkVersion="32"/>
    

    and you will be prompted for authorization to access media files.

Chromecast Support

Android Only

Chromecast explanation

The cast option is enabled by default, otherwise you can disable it with the option chromecast = false in InitPlayer options.

Cast button will only be available if your cast devices are connected in the same WIFI network, if not, the button won't be visible.

Some videos won't work with Cast, as not every video format is supported.

When you start casting, the video controllers will be available to control your cast. If you exit the app or close the video, the cast will end automatically.

Cast title will be the same as title and smallTitle, if these are not added, then it will be blank

Android Quirks

Since 3.7.2, you need to add few things in your Android project to get the plugin working.

  • build.gradle (app)
dependencies {
    ...
    implementation 'com.google.android.gms:play-services-cast-framework:21.2.0'
}
  • AndroidManifest.xml
<application>
    ...
    <meta-data
        android:name="com.google.android.gms.cast.framework.OPTIONS_PROVIDER_CLASS_NAME"
        android:value="com.google.android.exoplayer2.ext.cast.DefaultCastOptionsProvider" />
</application>
  • MainActivity.java
import android.os.Bundle;

import com.google.android.gms.cast.framework.CastContext;


public class MainActivity extends BridgeActivity {
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    CastContext.getSharedInstance(this); // <--- add this
  }
}

Methods

echo(...)

echo(options: capEchoOptions) => Promise<capVideoPlayerResult>

Echo

Param Type
options capEchoOptions

Returns: Promise<capVideoPlayerResult>


initPlayer(...)

initPlayer(options: capVideoPlayerOptions) => Promise<capVideoPlayerResult>

Initialize a video player

Param Type
options capVideoPlayerOptions

Returns: Promise<capVideoPlayerResult>


isPlaying(...)

isPlaying(options: capVideoPlayerIdOptions) => Promise<capVideoPlayerResult>

Return if a given playerId is playing

Param Type
options capVideoPlayerIdOptions

Returns: Promise<capVideoPlayerResult>


play(...)

play(options: capVideoPlayerIdOptions) => Promise<capVideoPlayerResult>

Play the current video from a given playerId

Param Type
options capVideoPlayerIdOptions

Returns: Promise<capVideoPlayerResult>


pause(...)

pause(options: capVideoPlayerIdOptions) => Promise<capVideoPlayerResult>

Pause the current video from a given playerId

Param Type
options capVideoPlayerIdOptions

Returns: Promise<capVideoPlayerResult>


getDuration(...)

getDuration(options: capVideoPlayerIdOptions) => Promise<capVideoPlayerResult>

Get the duration of the current video from a given playerId

Param Type
options capVideoPlayerIdOptions

Returns: Promise<capVideoPlayerResult>


getCurrentTime(...)

getCurrentTime(options: capVideoPlayerIdOptions) => Promise<capVideoPlayerResult>

Get the current time of the current video from a given playerId

Param Type
options capVideoPlayerIdOptions

Returns: Promise<capVideoPlayerResult>


setCurrentTime(...)

setCurrentTime(options: capVideoTimeOptions) => Promise<capVideoPlayerResult>

Set the current time to seek the current video to from a given playerId

Param Type
options capVideoTimeOptions

Returns: Promise<capVideoPlayerResult>


getVolume(...)

getVolume(options: capVideoPlayerIdOptions) => Promise<capVideoPlayerResult>

Get the volume of the current video from a given playerId

Param Type
options capVideoPlayerIdOptions

Returns: Promise<capVideoPlayerResult>


setVolume(...)

setVolume(options: capVideoVolumeOptions) => Promise<capVideoPlayerResult>

Set the volume of the current video to from a given playerId

Param Type
options capVideoVolumeOptions

Returns: Promise<capVideoPlayerResult>


getMuted(...)

getMuted(options: capVideoPlayerIdOptions) => Promise<capVideoPlayerResult>

Get the muted of the current video from a given playerId

Param Type
options capVideoPlayerIdOptions

Returns: Promise<capVideoPlayerResult>


setMuted(...)

setMuted(options: capVideoMutedOptions) => Promise<capVideoPlayerResult>

Set the muted of the current video to from a given playerId

Param Type
options capVideoMutedOptions

Returns: Promise<capVideoPlayerResult>


setRate(...)

setRate(options: capVideoRateOptions) => Promise<capVideoPlayerResult>

Set the rate of the current video from a given playerId

Param Type
options capVideoRateOptions

Returns: Promise<capVideoPlayerResult>


getRate(...)

getRate(options: capVideoPlayerIdOptions) => Promise<capVideoPlayerResult>

Get the rate of the current video from a given playerId

Param Type
options capVideoPlayerIdOptions

Returns: Promise<capVideoPlayerResult>


stopAllPlayers()

stopAllPlayers() => Promise<capVideoPlayerResult>

Stop all players playing

Returns: Promise<capVideoPlayerResult>


showController()

showController() => Promise<capVideoPlayerResult>

Show controller

Returns: Promise<capVideoPlayerResult>


isControllerIsFullyVisible()

isControllerIsFullyVisible() => Promise<capVideoPlayerResult>

isControllerIsFullyVisible

Returns: Promise<capVideoPlayerResult>


exitPlayer()

exitPlayer() => Promise<capVideoPlayerResult>

Exit player

Returns: Promise<capVideoPlayerResult>


Interfaces

capVideoPlayerResult

Prop Type Description
result boolean result set to true when successful else false
method string method name
value any value returned
message string message string

capEchoOptions

Prop Type Description
value string String to be echoed

capVideoPlayerOptions

Prop Type Description
mode string Player mode - "fullscreen" - "embedded" (Web only)
url string The url of the video to play
subtitle string The url of subtitle associated with the video
language string The language of subtitle see https://github.com/libyal/libfwnt/wiki/Language-Code-identifiers
subtitleOptions SubTitleOptions SubTitle Options
playerId string Id of DIV Element parent of the player
rate number Initial playing rate
exitOnEnd boolean Exit on VideoEnd (iOS, Android) default: true
loopOnEnd boolean Loop on VideoEnd when exitOnEnd false (iOS, Android) default: false
pipEnabled boolean Picture in Picture Enable (iOS, Android) default: true
bkmodeEnabled boolean Background Mode Enable (iOS, Android) default: true
showControls boolean Show Controls Enable (iOS, Android) default: true
displayMode string Display Mode ["all", "portrait", "landscape"] (iOS, Android) default: "all"
componentTag string Component Tag or DOM Element Tag (React app)
width number Player Width (mode "embedded" only)
height number Player height (mode "embedded" only)
headers { [key: string]: string; } Headers for the request (iOS, Android) by Manuel García Marín (https://github.com/PhantomPainX)
title string Title shown in the player (Android) by Manuel García Marín (https://github.com/PhantomPainX)
smallTitle string Subtitle shown below the title in the player (Android) by Manuel García Marín (https://github.com/PhantomPainX)
accentColor string ExoPlayer Progress Bar and Spinner color (Android) by Manuel García Marín (https://github.com/PhantomPainX) Must be a valid hex color code default: #FFFFFF
chromecast boolean Chromecast enable/disable (Android) by Manuel García Marín (https://github.com/PhantomPainX) default: true
artwork string Artwork url to be shown in Chromecast player by Manuel García Marín (https://github.com/PhantomPainX) default: ""

SubTitleOptions

Prop Type Description
foregroundColor string Foreground Color in RGBA (default rgba(255,255,255,1)
backgroundColor string Background Color in RGBA (default rgba(0,0,0,1)
fontSize number Font Size in pixels (default 16)

capVideoPlayerIdOptions

Prop Type Description
playerId string Id of DIV Element parent of the player

capVideoTimeOptions

Prop Type Description
playerId string Id of DIV Element parent of the player
seektime number Video time value you want to seek to

capVideoVolumeOptions

Prop Type Description
playerId string Id of DIV Element parent of the player
volume number Volume value between [0 - 1]

capVideoMutedOptions

Prop Type Description
playerId string Id of DIV Element parent of the player
muted boolean Muted value true or false

capVideoRateOptions

Prop Type Description
playerId string Id of DIV Element parent of the player
rate number Rate value

Listeners

The listeners are attached to the plugin not anymore to the DOM document element.

Listener Type Description
jeepCapVideoPlayerReady capVideoListener Emitted when the video start to play
jeepCapVideoPlayerPlay capVideoListener Emitted when the video start to play
jeepCapVideoPlayerPause capVideoListener Emitted when the video is paused
jeepCapVideoPlayerEnded capVideoListener Emitted when the video has ended
jeepCapVideoPlayerExit capExitListener Emitted when the Exit button is clicked

capVideoListener

Prop Type Description
playerId string Id of DIV Element parent of the player
currentTime number Video current time when listener trigerred

capExitListener

Prop Type Description
dismiss boolean Dismiss value true or false
currentTime number Video current time when listener trigerred