0.1.6 • Published 5 years ago

forviz-splitr-player v0.1.6

Weekly downloads
-
License
MIT
Repository
-
Last release
5 years ago

Forviz Splitr Player

A simple splitr player component built with React JS.

Table of content

Installation

Recommended using either yarn or npm for install.

# YARN
$ yarn add forviz-splitr-player

# NPM
$ npm install forviz-splitr-player --save

Components

There are 3 components; Player, withSplitr, and useSplitr.

Player component

Usage

import React from 'react'
import { Player } from 'forviz-splitr-player'

const medias = [
  {
    id: 'mediaId',
    type: 'video',  /* (video, image, url) */
    src: '/path/to/file.mp4',
    duration: 120,
    startAt: 0,
    endAt: 120,
    contentType: 'image/png' /* (video/mp4, image/jpg, image/png) */
    updated: '2019-03-04T11:06:48.420Z',
    title: 'File title'
  },
  {
    id: 'mediaId',
    type: 'video',  /* (video, image, url) */
    src: '/path/to/file.mp4',
    duration: 120,
    startAt: 0,
    endAt: 120,
    contentType: 'image/png' /* (video/mp4, image/jpg, image/png) */
    updated: '2019-03-04T11:06:48.420Z',
    title: 'File title'
  },
]

const dimension = {
  height: 360,
  width: 640,
  resize: 'contain',
  timer: true, /* set to false for hide the timer */
}

const Index = () => <Player medias={medias} {...dimension} />

export default Index

Properties

PropsDefaultTypeDescription
medias-arrayArray of Media object
height100%number, stringContainer height
width100%number, stringContainer width
resizecontainenumThe enum of contain and cover to resize the media.
timertrueboolIf set to true, the timer will appear in the top right of player component otherwise it will disappear.

Media object

VariableTypeDescription
idstringMedia id
titlestringMedia title
typeenumThe enum of video, image, and url.
srcstringPath to the file.
durationnumberThe duration time of each media. Disable when media type is video.
startAtnumberStart time of each media related to duration time. if set to 0, negative, or more than duration time of video, it'll use the start playback position of video.
endAtnumberEnd time of each media related to duration time. if set to 0, negative, or more than duaration time of video, it'll use the end playback position of the video.
contentTypeenumThe enum of video/mp4, image/jpg, and image/png.
updateddateUpdated date of the media.

withSplitr component

The component is a higher order component, which inject the medias data to <Player /> by providing a accountId and playlistId.

Usage

import React from 'react'
import { Player, withSplitr } from 'forviz-splitr-player'

const options = {
  accountId: 'mqdc',
  playlistId: '8gDTW1PENqEm9nmCX0MW',
  key: 'sampleKey',
}

const PlayerWithSplitr = withSplitr(options)(Player)

export default PlayerWithSplitr

Option object

VariableTypeDescription
accountIdstringAccount ID
playlistIdstringPlaylist ID
keystringAuthorise key

useSplitr

The custom hook called a medias data by providing accountId and playlistId.

Usage

import React from 'react'
import { Player, useSplitr } from 'forviz-splitr-player'

const dimension = {
  height: 360,
  width: 640,
  resize: 'contain',
}

const options = {
  accountId: 'mqdc',
  playlistId: '8gDTW1PENqEm9nmCX0MW',
  key: 'sampleKey',
}

const PlayerUseSplitr = () => {
  const [ medias, error ] = useSplitr(options)

  return (
    <Player 
      {...dimension} 
      medias={medias} 
      error={error} 
    />
  )
}

export default PlayerUseSplitr

Option object

VariableTypeDescription
accountIdstringAccount ID
playlistIdstringPlaylist ID
keystringAuthorise key

License

MIT

0.1.6

5 years ago

0.1.5

5 years ago

0.1.4

5 years ago

0.1.3

5 years ago

0.1.2

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago

0.0.28

5 years ago

0.0.27

5 years ago

0.0.26

5 years ago

0.0.25

5 years ago

0.0.24

5 years ago

0.0.23

5 years ago

0.0.22

5 years ago

0.0.21

5 years ago

0.0.20

5 years ago

0.0.19

5 years ago

0.0.18

5 years ago

0.0.17

5 years ago

0.0.16

5 years ago

0.0.15

5 years ago

0.0.14

5 years ago

0.0.13

5 years ago

0.0.12

5 years ago

0.0.11

5 years ago

0.0.10

5 years ago

0.0.9

5 years ago

0.0.8

5 years ago

0.0.7

5 years ago

0.0.6

5 years ago

0.0.5

5 years ago

0.0.4

5 years ago

0.0.3

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago