4.4.0 • Published 6 months ago

@youon/react-native-player v4.4.0

Weekly downloads
102
License
MIT
Repository
-
Last release
6 months ago

@youon/react-native-player

npm

YouOn's react native player with integration

Dependencies

  • "@youon/player-api-wrapper": "^0.1.0",
  • "luxon": "^1.12.0",
  • "prop-types": "^15.7.2",
  • "react-native-device-info": "^2.1.3",
  • "react-native-google-analytics": "^1.3.2",
  • "react-native-slider": "^0.11.0",
  • "react-native-svg": "^13.0.0",
  • "react-native-video": "^5.2.1",
  • "react-xml-parser": "^1.1.2"
  • "react-native-google-cast" : "^3.3.0"
  • "tinycolor2": "^1.4.1"

Usage

import { Player , PlayerLive } from '@youon/react-native-player';

class ReactComponent extends Component {
    ...

    render(){
       return( <Player />
               <PlayerLive />);
    }

}

Player Component

Props
Proprequiredtypedescription
publicIdtruenumberstringVideo public ID
apikeytruestringAPI Key,
apitokentruestringAPI TOKEN,
apiHosttruestringAPI HOST,
posterfalsestringVideo Poster
titlefalsestringVideo Title
startVideoAtfalsenumberseconds where video start to play,
envfalsestring('dev', 'prod')API environment
toggleResizeModeOnFullscreenfalsebool
playInBackgroundfalsebool
playWhenInactivefalsebool
showOnStartfalsebool
gafalsestringGoggle Analytics ID (UA-XXXXX-X)
pausedfalsebool
repeatfalsebool
volumefalsenumber
mutedfalsebool
ratefalsenumber
onLoadStartfalsefunc
onTimedMetadatafalsefunc
onBufferfalsefunc
onStepBackwardsfalsefunc
onStepForwardsfalsefunc
onLoadfalsefunc
onErrorfalsefunc
onEndfalsefunc
onProgressfalsefunc
onPausedChangefalsefunc
controlsfalseobject
previewfalsebool
showPosterAfterPreviewfalsebool
onEndPreviewfalsefunc
themefalseobj{ baseColor,textColor,backgroundColor,liveColor }
playlistfalsearray{ id, image, title, publicId }
playlistIndexfalsenumber
onPlaylistVideoChangefalsefunc({ id, image, title, publicId },index)=>{}

methods

togglePlayPause

muted(muted) - set Muted volume

seek(time) - seek time in player

setFullscreen(fullscreen) - set Fullscreen

play() - play video if not already playing

pause() - pause video if not already paused

paused() - check if video is paused

controls

Controls object has a specific structure

The player controls are divided into 3 areas, Header , MainControls and controlBar, aka, top, middle, and center

the loading control will always appear on center

with the plugins object you can insert a plugin into one of the 3 areas

    controls: {
        header: [  { type: PlayerPlugin , props: {} }, ...  ],
        mainControls: [  { type: PlayerPlugin , props: {} },  ... ],
        controlBar: [ { type: PlayerPlugin , props: {} }, ...  ],
        loading : { type: PlayerPlugin , props: {} },
        plugins: {
            header: [
                { type: PlayerPlugin , props: {} }, ...
            ],
            mainControls: [
                { type: PlayerPlugin , props: {} }, ...
            ],
            controlBar: [
                { type: PlayerPlugin , props: {} }, ...
            ],
            other: [
                { type: MultiTapSeek, props: { step: 10 } },
            ]
        }
    },
Default Props
Player.defaultProps =  {
    title:                          '',
    startVideoAt:                   0,
    toggleResizeModeOnFullscreen:   false,
    playInBackground:               false,
    playWhenInactive:               false,
    showOnStart:                    false,
    paused:                         false,
    repeat:                         false,
    volume:                         1,
    muted:                          false,
    rate:                           1,
    env:                            'dev',
    playlist:                       [],
    playlistIndex:                  0,
    theme: {
            baseColor: "#00A6F0",
            textColor: "#fff",
            backgroundColor: "#000",
            liveColor: "#ee8e31",
        },
    onPlaylistVideoChange:          null,
    controls: {
        header: [
            { type: BackButton , props : {} },
            { type: HeaderTitle, props : {} },
            { type: CastButton ,  props: {}}
        ],
        mainControls: [
            { type: BackwardSkipButton, props: { step: 10 } },
            { type: BigPlayPauseButton , props: {} },
            { type: ForwardSkipButton , props: { step: 10 } },
        ],
        controlBar: [
            { type: PlayerTime, props : {} },
            { type: Spacer , props: {}},
            { type: ShareButton ,  props : {} },
            { type: MuteButton , props: {}},
            { type: PlaylistButton ,  props : {} },
            { type: ProgressBar, props : {} },
            
        ],
        loading : { type: PlayerLoading , props: {} },
        plugins: {
            header: [

            ],
            mainControls: [
                
            ],
            controlBar: [

            ],
            other: [
                { type: OnScreenGraphicsPlugin, props: {} },
                { type: MultiTapSeek, props: { step: 10 } },
                { type : PlaylistModal ,  props : {} },
                
            ]
        }
    },
    plugins : []
};

Plugins

to create more Plugins you can extend the PlayerPlugin class

every plugin has access to all the player props

class PlayerPlugin extends Component {

  constructor(props) {
    super(props);
  }

  render() {
    return null;
  }
}

PlayerPlugin.propTypes = {
  volume:                         PropTypes.number,
  paused:                         PropTypes.bool,
  muted:                          PropTypes.bool,
  rate:                           PropTypes.number,
  source:                         PropTypes.object,
  fullscreen:                     PropTypes.bool,
  preview:                        PropTypes.bool,
  showPosterAfterPreview:         PropTypes.bool,
  onEndPreview:                   PropTypes.func, 
  currentTime:                    PropTypes.number,
  duration:                       PropTypes.number,
  player:                         PropTypes.object,
  publicId:                       PropTypes.oneOfType([
                                      PropTypes.string,
                                      PropTypes.number
                                  ]),
  apikey:                         PropTypes.string.isRequired,
  apitoken:                       PropTypes.string.isRequired,
  poster:                         PropTypes.string,
  title:                          PropTypes.string,
  mode:                           PropTypes.oneOf(['vod', 'live', 'dvr']),
  startVideoAt:                   PropTypes.number,
  env:                            PropTypes.string,
  BackImage:                      PropTypes.elementType,
  PlayIcon:                     PropTypes.elementType,
  ReplayIcon:                       PropTypes.elementType,
  PauseIcon:                            PropTypes.elementType,
}

PlayerPlugin.defaultProps = {}

currently Available Plugins

  • BackButton
  • PlayerTime
  • PlayerLoading
  • ControlButton
  • HeaderTitle
  • LiveButton
  • MultiTapSeek
  • BigPlayPauseButton
  • ForwardSkipButton
  • BackwardSkipButton
  • PlayPauseButton
  • ProgressBar
  • Spacer
  • MuteButton
  • FullscreenButton

Player Live

Props
Proprequiredtypedescription
publicIdtruenumberstringVideo public ID
apikeytruestringAPI Key,
apitokentruestringAPI TOKEN,
apiHosttruestringAPI HOST,
posterfalsestringVideo Poster
titlefalsestringVideo Title
envfalsestring('dev', 'prod')API environment
toggleResizeModeOnFullscreenfalsebool
playInBackgroundfalsebool
playWhenInactivefalsebool
showOnStartfalsebool
gafalsestringGoggle Analytics ID (UA-XXXXX-X)
pausedfalsebool
volumefalsenumber
mutedfalsebool
ratefalsenumber
onLoadStartfalsefunc
onBufferfalsefunc
onLoadfalsefunc
onErrorfalsefunc
onEndfalsefunc
onProgressfalsefunc
onPausedChangefalsefunc
themefalseobj{ baseColor,textColor,backgroundColor,liveColor }
controlsfalseobject
Default Props
PlayerLive.defaultProps =  {
    title:                          '',
    toggleResizeModeOnFullscreen:   false,
    playInBackground:               false,
    playWhenInactive:               false,
    showOnStart:                    false,
    paused:                         false,
    repeat:                         false,
    volume:                         1,
    muted:                          false,
    rate:                           1,
    env:                            'dev',
    theme:                          {
        baseColor: "#00A6F0",
        textColor: "#fff",
        backgroundColor: "#000",
        liveColor: "#ee8e31",
    },
    controls: {
        header: [
            { type: BackButton , props : {} },
            { type: HeaderTitle, props : {} },
            { type: CastButton ,  props: {}}
        ],
        mainControls: [
            { type: BigPlayPauseButton , props: {} },
        ],
        controlBar: [
            //{ type: PlayPauseButton, props: {} },
            { type: LiveButton , props : {} },
            { type: PlayerTime, props : {
                showCurrent : false,
                showDuration : false,
            } },
            { type: Spacer, props: {} },
            { type: ShareButton ,  props : {} },
            { type: MuteButton , props: {}},
            { type: ProgressBar, props : {} },

            
        ],
        loading : { type: PlayerLoading , props: {} },
        plugins: {
            header: [],
            mainControls: [],
            controlBar: [],
            other: [
                { type: OnScreenGraphicsPlugin, props: {} }
            ]
        }
    },
    plugins : []
};
4.4.0

6 months ago

4.3.0

10 months ago

4.2.1

1 year ago

3.1.2

1 year ago

4.2.0

1 year ago

4.1.0

2 years ago

4.1.1

2 years ago

4.0.1

2 years ago

4.0.0

2 years ago

3.1.1

2 years ago

3.1.0

3 years ago

2.0.14

3 years ago

3.0.4

4 years ago

3.0.3

4 years ago

3.0.2

4 years ago

3.0.1

4 years ago

3.0.6

4 years ago

3.0.5

4 years ago

3.0.0

4 years ago

2.0.13

4 years ago

2.0.11

4 years ago

2.0.12

4 years ago

2.0.10

4 years ago

2.0.7

4 years ago

2.0.9

4 years ago

2.0.8

4 years ago

2.0.6

5 years ago

2.0.5

5 years ago

2.0.4

5 years ago

2.0.3

5 years ago

2.0.2

5 years ago

2.0.1

5 years ago

2.0.1-rc0

5 years ago

2.0.1-rc2

5 years ago

2.0.1-rc1

5 years ago

2.0.1-rc4

5 years ago

2.0.1-rc3

5 years ago

2.0.0

5 years ago

2.0.0-rc0

5 years ago

1.2.0

5 years ago

1.2.0-rc13

5 years ago

1.2.0-rc12

5 years ago

1.2.0-rc11

5 years ago

1.2.0-rc9

5 years ago

1.2.0-rc10

5 years ago

1.2.0-rc8

5 years ago

1.2.0-rc7

5 years ago

1.2.0-rc6

5 years ago

1.2.0-rc5

5 years ago

1.2.0-rc4

5 years ago

1.2.0-rc3

5 years ago

1.2.0-rc2

5 years ago

1.2.0-rc

5 years ago

1.2.0-rc1

5 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.12

5 years ago

1.0.11

5 years ago

1.0.10

5 years ago

1.0.9

5 years ago

1.0.8

5 years ago

1.0.7

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago

0.9.15

5 years ago

0.9.14

6 years ago

0.9.13

6 years ago

0.9.12

6 years ago

0.9.11

6 years ago

0.9.10

6 years ago

0.9.9

6 years ago

0.9.8

6 years ago

0.9.7

6 years ago

0.9.6

6 years ago

0.9.5

6 years ago

0.9.4

6 years ago

0.9.3

6 years ago

0.9.2

6 years ago

0.9.1

6 years ago

0.9.0

6 years ago

0.8.12

6 years ago

0.8.11

6 years ago

0.8.10

6 years ago

0.8.9

6 years ago

0.8.8

6 years ago

0.8.7

6 years ago

0.8.6

6 years ago

0.8.5

6 years ago

0.8.4

6 years ago

0.8.3

6 years ago

0.8.2

6 years ago

0.8.1

6 years ago

0.8.0

6 years ago

0.7.3

6 years ago

0.7.2

6 years ago

0.7.1

6 years ago

0.7.0

6 years ago

0.6.1

6 years ago

0.6.0

6 years ago

0.5.0

6 years ago

0.4.7

6 years ago

0.4.6

6 years ago

0.4.5

6 years ago

0.4.4

6 years ago

0.4.3

6 years ago

0.4.2

6 years ago

0.4.1

6 years ago

0.4.0

6 years ago

0.3.0

6 years ago

0.2.9

6 years ago

0.2.8

6 years ago

0.2.7

6 years ago

0.2.6

6 years ago

0.2.5

6 years ago

0.2.4

6 years ago

0.2.3

6 years ago

0.2.1

6 years ago

0.2.0

6 years ago

0.1.5

6 years ago