react-native-ali-video-player
TypeScript icon, indicating that this package has built-in type declarations

1.0.5 • Public • Published

Installation

npm install react-native-ali-video-player

Usage

import VideoPlayer from 'react-native-ali-video-player';

const refPlayer = React.useRef<VideoPlayerHandler>(null);
const uriSource = { uri: "https://player.alicdn.com/video/aliyunmedia.mp4" }

const stsSource = {
  sts: {
    vid: 'YOUR_VID'
    region: 'YOUR_REGION',
    accessKeyId: 'YOUR_ACCESS_KEY_ID',
    accessKeySecret: 'YOUR_ACCESS_KEY_SECRET',
    securityToken: 'YOUR_SECURITY_TOKEN',
  },
}

const authSource = {
  auth: {
    vid: 'YOUR_VID'
    region: 'YOUR_REGION',
    playAuth: 'YOUR_PLAY_AUTH',
  },
}

<VideoPlayer
  ref={refPlayer}
  isHiddenBack
  isLandscape
  enableBackground={true}
  source={uriSource /* or stsSource or authSource */}
  setAutoPlay={true}
  showTiming={true}
  onCompletion={() => {
    console.log('onCompletion');
  }}
  onError={(error: any) => {
    console.log('error', error);
  }}
  onProgress={(error: any) => {
    console.log('onProgress', error);
  }}
  onAliBitrateReady={e => {
    console.log('onAliBitrateReady', e.nativeEvent.bitrates);
  }}
  onAliLoadingEnd={e => {
    console.log('onAliLoadingEnd', e);
  }}
  onBufferProgress={(progress: any) => {
    console.log('onBufferProgress', progress);
  }}
  onPrepare={(duration: any) => {
    console.log('onPrepare', duration);
  }}
  style={[styles.box, {width: layout.width, height: 200}]}
/>

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

MIT

Package Sidebar

Install

npm i react-native-ali-video-player

Weekly Downloads

1

Version

1.0.5

License

MIT

Unpacked Size

476 kB

Total Files

87

Last publish

Collaborators

  • lvnini