Skip to main content

VideoPlayer

A component that provides playback of video.

Submit feedback
github
import { VideoPlayer } from '@uhg-abyss/mobile/ui/VideoPlayer';

Setup

VideoPlayer requires react-native-video to be install as a dependency. To start, follow the react-native-video installation directions.

Basic usage

VideoPlayer can be used with a single source prop. In this configuration it will use the native controls in iOS, and abyss specific controls for Android.

VideoPlayer is built around react-native-video, and thus has the ability to consume any prop available in react-native-video except fullscreen.

<VideoPlayer source={video} />

Customization

You can use the thumbnail prop to display a custom thumbnail before the video is started.

<VideoPlayer
source={video}
thumbnail={
<Brandmark size={300} affiliate="uhc" variant="lockup" color="blue" />
}
/>
VideoPlayer custom thumbnail

Subtitles/CC

Be sure to add closed captions to your video via the textTrack prop.

Closed Captions are required for accessibility. You can provide multiple text tracks, and select the default one using the selectedTextTrack prop.

<VideoPlayer
source={TestVid}
videoTitle="Test Video"
selectedTextTrack={{ type: 'index', value: 0 }}
textTracks={[
{
title: 'english',
language: 'en',
uri: 'https://bitdash-a.akamaihd.net/content/sintel/subtitles/subtitles_en.vtt',
},
]}
/>

Accessibility

  • Closed Captions is required for all videos.
  • Be sure to provide an videoTitle prop to the VideoPlayer component. This will be used as the A11y title for the video.
  • It is recommended to provide a text transcript on the same page as the video player.

VideoPlayer Props

Prop NameTypeDefaultDescription
onEndfunction-Callback ran on video end
onLoadfunction-Callback ran on video load
sourceuri-The video source
thumbnailnode-Override that will place a custom video thumbnail over the video
videoTitlestring-The A11y title for the video

VideoPlayer Classes

Class NameDescription
abyss-video-player-android-controls-back-buttonVideoPlayer android controls skip back button
abyss-video-player-android-controls-back-button-iconVideoPlayer android controls skip back button icon
abyss-video-player-android-controls-bottom-wrapperVideoPlayer android controls bottom wrapper (time slider, CC, fullscreen & duration)
abyss-video-player-android-controls-center-wrapperVideoPlayer android controls center wrapper (skip & play/pause buttons)
abyss-video-player-android-controls-close-buttonVideoPlayer android controls close button
abyss-video-player-android-controls-close-button-iconVideoPlayer android controls close button icon
abyss-video-player-android-controls-duration-current-textVideoPlayer android controls current time text
abyss-video-player-android-controls-duration-remaining-textVideoPlayer android controls duration left time wrapper
abyss-video-player-android-controls-forward-buttonVideoPlayer android controls skip forward button
abyss-video-player-android-controls-forward-button-iconVideoPlayer android controls skip forward button
abyss-video-player-android-controls-full-screen-buttonVideoPlayer android controls full screen button
abyss-video-player-android-controls-full-screen-button-iconVideoPlayer android controls full screen button icon
abyss-video-player-android-controls-overlayVideoPlayer android controls overlay
abyss-video-player-android-controls-pause-buttonVideoPlayer android controls play/pause button
abyss-video-player-android-controls-pause-button-iconVideoPlayer android controls play/pause button icon
abyss-video-player-android-controls-slider-backgroundVideoPlayer android controls slider background
abyss-video-player-android-controls-slider-foregroundVideoPlayer android controls slider foreground
abyss-video-player-android-controls-slider-thumbVideoPlayer android controls slider thumb
abyss-video-player-android-controls-subtitle-buttonVideoPlayer android controls subtitle button
abyss-video-player-android-controls-subtitle-button-iconVideoPlayer android controls subtitle button icon
abyss-video-player-android-controls-time-wrapperVideoPlayer android controls duration time wrapper
abyss-video-player-duration-textVideoPlayer duration text
abyss-video-player-duration-wrapperVideoPlayer duration text wrapper
abyss-video-player-full-screen-wrapperWrapper for the full screen modal (Modal for android | View for iOS)
abyss-video-player-play-buttonVideoPlayer Play button
abyss-video-player-play-button-iconVideoPlayer Play button icon
abyss-video-player-rootVideoPlayer root
abyss-video-player-thumbnail-custom-wrapperVideoPlayer custom thumbnail wrapper
abyss-video-player-thumbnail-duration-textVideoPlayer thumbnail duration text
abyss-video-player-thumbnail-overlayVideoPlayer thumbnail overlay
abyss-video-player-thumbnail-play-buttonVideoPlayer thumbnail play/pause button
abyss-video-player-thumbnail-wrapperVideoPlayer thumbnail wrapper
abyss-video-player-videoVideo component
abyss-video-player-wrapperFullscreen wrapper for the video component

'VideoPlayer' Tokens

Token NameValue
video-player.color.surface.overlay
rgba(50, 51, 52, .4)
Table of Contents