0.5.2 • Published 7 months ago

rn-media-player v0.5.2

Weekly downloads
-
License
MIT
Repository
github
Last release
7 months ago

rn-media-player

Introduction

This library is specifically designed for the React Native developer community, aiming to provide a robust and highly performant video player solution. By utilizing native components, our goal is to maximize the performance and efficiency of video playback in React Native applications. Maintaining the fluidity and responsiveness that users expect from native video experiences.

table of contents

Installation

npm install rn-media-player
yarn add rn-media-player

Usage

import { Video } from "rn-media-player";

// ...
const source = {
  url: "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4"
  title: "Big Buck Bunny"
}

<Video source={source} />

API Reference

This section provides detailed information about the props, methods, and events supported by the VideoPlayer component.

Configurations

PropertyDescriptionTypeDefault
sourceObject attribute where to pass url and title of the video.Object{url: "" title: ""}
thumbnailFramesSecondsQuantity preview frames generated per seconds.Number1
enterInFullScreenWhenDeviceRotatedEnter full screen when rotate device.Booleanfalse
autoPlayEnable/Disable auto play on playback init.Booleantrue
loopEnable/Disable loop on playback finish.Booleanfalse
pausedPauses playback.Booleanfalse
rateAble to change playback rate.Number1
startTimeInitial time of playback.Number0
resizeModeResizes of playback.EResizeModecontain
tapToSeekValueValue to seek player with backward or forward.Number15
suffixLabelTapToSeekenable/disable loop on playback finish.Booleanfalse
lockControlslock controls playback - WIP.Booleanfalse
speedsObject with data to display speeds into settings and initial speed selected.Objectspeeds
qualitiesObject with data to display qualities into settings and initial quality selected.Objectnull
settingsObject with data to display settings.Objectsettings
controlsPropsConfigure controls properties.Objectcontrols
Settings
PropertyDescriptionType
namevalue to settings display.String
enabledenable or disable to display into interface.Boolean
{
  data: [
    {
      name: 'Qualities',
      enabled: true,
    },
    {
      name: 'Playback Speeds',
      enabled: true,
    },
    {
      name: 'More Options',
      enabled: true,
    },
  ],
}
Speeds
PropertyDescriptionType
namevalue to display in settings.String
valuevalue to pass to playback speed.String
enabledenable or disable to display into interface.Boolean
{
    initialSelected: 'Normal',
    data: [
        {
            name: '0.5x',
            value: '0.5',
            enabled: true,
        },
        {
            name: 'Normal',
            value: '1',
            enabled: true,
        },
        {
            name: '1.5x',
            value: '1.5',
            enabled: true,
        },
    ],
}
Controls
PropertyDescriptionTypeDetails
loadingCustomizes the loading indicator.Object{ color?: string; }
playbackControls the appearance of playback elements.Object{ color?: string; }
seekSliderStyles the seek slider.ObjectDetailed below
settingsStyles the settings control.Object{ color?: string; }
fullScreenCustomizes the full-screen button appearance.Object{ color?: string; }
downloadConfigures the download button and related UI.ObjectDetailed below
toastStyles toast notifications within the player.ObjectDetailed below
headerStyles the video player header.ObjectDetailed below
Detailed Configuration Options

Note: This library accepts color specifications in hexadecimal format only. Please ensure that all color properties are provided as hex codes.

seekSlider

  • maximumTrackColor: Color of the slider track (string)
  • minimumTrackColor: Color of the slider track before the thumb (string)
  • seekableTintColor: Color of the track showing seekable range (string)
  • thumbImageColor: Color of the slider thumb (string)
  • thumbnailBorderColor: Border color of the thumbnail on the slider (string)
  • thumbnailTimeCodeColor: Color of the time code on the thumbnail (string)

timeCodes

  • currentTimeColor: Color of the current playback time (string)
  • durationColor: Color of the total duration (string)
  • slashColor: Color of the slash between current time and duration (string)

download

  • color: Color of the download icon (string)
  • progressBarColor: Color of the progress bar frame (string)
  • progressBarFillColor: Fill color of the progress bar (string)
  • messageDelete: Message displayed on deleting (string)
  • messageDownload: Message displayed during downloading (string)
  • labelDelete: Label for delete button (string)
  • labelCancel: Label for cancel button (string)
  • labelDownload: Label for download button (string)

toast

  • label: Text label for the toast (string)
  • backgroundColor: Background color of the toast (string)
  • labelColor: Color of the label text (string)

header

  • leftButtonColor: Color of the left button in the header (string)
  • titleColor: Color of the title in the header (string)
Events
PropertyDescriptionTypeDetails
onSettingsCallback tap settings.FuncVoid
onGoBackCallback tap goBack.FuncVoid
onPlaybackSpeedCallback tap playback speed on settings.FuncVoid
onQualityCallback tap quality on settings.FuncVoid
onFullScreenCallback tap full screen.FuncVoid
onBufferCompletedCallback with NativeSyntheticEvent when buffer is completed.FuncDetailed below
onVideoDownloadedCallback with NativeSyntheticEvent when video is downloaded.FuncDetailed below
onBufferCallback with NativeSyntheticEvent when video is buffering.FuncDetailed below
onLoadedCallback with NativeSyntheticEvent when video is loaded.FuncDetailed below
onVideoProgressCallback with NativeSyntheticEvent when video is in-progress.FuncDetailed below
onPlayPauseCallback with NativeSyntheticEvent when video is playing or paused.FuncDetailed below
onCompletedCallback with NativeSyntheticEvent when video is completed.FuncDetailed below
onErrorCallback with NativeSyntheticEvent when video has ocurred error.FuncDetailed below
Detailed Events

Notes to access events must be use callback params ex:

  <Video
    // ...rest code
    onCompleted={(event)  => event.nativeEvent.xxxx}
  />

onBufferCompleted : Called when the video has completed buffering.

: - Parameters:

  • completed (boolean): True if buffering is complete and playback can continue.

onVideoDownloaded : Called when the video download status changes.

: - Parameters:

  • downloaded (boolean): Indicates whether the video has been fully downloaded.
  • status (string): Status message of the download.
  • error (any): Error object if the download failed.

onBuffer : Indicates changes in the buffering state of the video.

: - Parameters:

  • buffering (boolean): True if the video is currently buffering.

onLoaded : Called when the video is loaded and ready to play.

: - Parameters:

  • duration (Float): The total duration of the video.

onVideoProgress : Called periodically during playback to indicate buffering progress and play progress.

: - Parameters:

  • buffering (Float): Current buffering state as a float value.
  • progress (Float): Current progress of the video playback as a float value.

onPlayPause : Called when the play or pause action is triggered.

: - Parameters:

  • isPlaying (boolean): True if the video is currently playing.

onCompleted : Called when the video playback has completed.

: - Parameters:

  • completed (boolean): True if the video has finished playing.

onError : Called when there is an error during video playback.

: - Parameters:

  • code (number): Error code identifying the type of error.
  • userInfo (string): General information about the error.
  • description (string): Detailed description of what caused the error.
  • failureReason (string): The reason for the video playback failure.
  • fixSuggestion (string): Suggested fix for the error.

License

MIT

0.5.0

8 months ago

0.4.1

8 months ago

0.4.0

8 months ago

0.5.2

7 months ago

0.5.1

8 months ago

0.3.0

9 months ago

0.3.2

9 months ago

0.3.1

9 months ago

0.2.1

10 months ago

0.2.0

10 months ago

0.2.3

9 months ago

0.2.2

9 months ago

0.1.0

1 year ago

0.0.1

1 year ago