react-native-aliyun-vod

0.0.4 • Public • Published

react-native-aliyun-vod

A react-native wrapper around aliyun video player

Check the example for more details

Installation

Using npm:

npm install --save react-native-aliyun-vod

or yarn:

yarn add --save react-native-aliyun-vod
Standard Method

React Native 0.60 and above

Run pod install in the ios directory.

React Native 0.59 and below

Run react-native link react-native-aliyun-vod to link library.

Manually Method

iOS

https://facebook.github.io/react-native/docs/linking-libraries-ios

Android

android/settings.gradle

include ':react-native-aliyun-vod'
project(':react-native-aliyun-vod').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-apsara-video/android')

MainApplication.java

@Override
protected List<ReactPackage> getPackages() {
    return Arrays.asList(
            new MainReactPackage(),
            new ApsaraPlayerPackage()
    );
}

Usage example

import React from 'react'
import ApsaraVideo from 'react-native-aliyun-vod';

const uriSource = { auth: undefined, sts: undefined, uri: "https://player.alicdn.com/video/aliyunmedia.mp4" }

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

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

export default class extends React.Component {
  render() {
    return (
      <ApsaraVideo
        ref={ref => {
          this.player = ref
        })
        source={uriSource}
        paused={true}
        onLoad={this._onLoad}
        onSeek={this._onSeek}
        onError={this._onError}
        onProgress={}
      />
    )
  }
};

Component props

prop default type description
paused false Boolean Whether the video is paused
repeat false Boolean Whether to repeat the video
muted false Boolean Whether the audio is muted
volume 1 Boolean Adjust the volume
source none Object Source of the video
onLoad none Function Callback function that is called when the video is loaded
onSeek none Function Callback function that is called when a seek completes
onError none Function Function that is invoked when the video load fails
onProgress none Function Function that is invoked when the video is updates

Readme

Keywords

Package Sidebar

Install

npm i react-native-aliyun-vod

Weekly Downloads

0

Version

0.0.4

License

MIT

Unpacked Size

47.5 kB

Total Files

19

Last publish

Collaborators

  • dagouzhi