A Video Player Based on React Native Video

react-native-rn-videoplayer

  • You can slide up and down to change the volume, screen brightness, drag the progress bar to display the time to be changed, full-screen switching, cache progress, double-click the video to pause, and other functions, based on react-native-video

  • ps: Android changes the brightness without obtaining advanced permissions. It only changes the current active, that is, the brightness of the current page. After changing the brightness, returning to another page will restore the original brightness.

  • Version 2.x requires react-native >= 0.60.0

  • Version 1.3.2 requires react-native <= 0.59.9

Short book address

Video preview

  • gif preview ios and android

     

Getting started

npm install react-native-rn-videoplayer --save

- - android

Open up android/app/src/main/java/[...]/MainActivity.java

+import android.content.Intent; 
+import android.content.res.Configuration;
public class MainActivity extends ReactActivity {

   ...

+ @Override
+      public void onConfigurationChanged(Configuration newConfig) {
+        super.onConfigurationChanged(newConfig);
+        Intent intent = new Intent("onConfigurationChanged");
+        intent.putExtra("newConfig", newConfig);
+        this.sendBroadcast(intent);
+    }
    ...
}

- - iOS

Add the following to your project’s AppDelegate.m:

+#import "Orientation.h"

@implementation AppDelegate

// ...

+- (UIInterfaceOrientationMask)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window {
+  return [Orientation getOrientation];
+}

@end

RN >= 0.60

ios

  cd ios 

  pod install

Android.

Most of them are automatically linked. If you can’t find XX, you should link manually

  • settings.gradle
  rootProject.name = 'TestPack622'
  apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings)

+    include ':react-native-linear-gradient'
+    project(':react-native-linear-gradient').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-linear-gradient/android')
+    include ':react-native-svg'
+    project(':react-native-svg').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-svg/android')
+    include ':react-native-orientation-locker'
+    project(':react-native-orientation-locker').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-orientation-locker/android')
+    include ':react-native-video'
+    project(':react-native-video').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-video/android-exoplayer')
+    include ':react-native-system-setting'
+    project(':react-native-system-setting').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-system-setting/android')

  include ':app'
  • MainApplication.java
+  import com.horcrux.svg.SvgPackage;
+  import com.BV.LinearGradient.LinearGradientPackage; // <--- This!
+  import org.wonday.orientation.OrientationPackage;
+  import com.ninty.system.setting.SystemSettingPackage;
+  import com.brentvatne.react.ReactVideoPackage;

  ···
 @Override
      protected List<ReactPackage> getPackages() {
        @SuppressWarnings("UnnecessaryLocalVariable")
        List<ReactPackage> packages = new PackageList(this).getPackages();
        // Packages that cannot be autolinked yet can be added manually here, for example:
+          packages.add(new LinearGradientPackage());
+          packages.add(new SvgPackage());
+          packages.add(new OrientationPackage());
+          packages.add(new SystemSettingPackage());
+          packages.add(new ReactVideoPackage());
        return packages;
      }
      ···
  • app/build.gradle
dependencies {
+    implementation project(':react-native-svg')
+    implementation project(':react-native-linear-gradient')
+    implementation project(':react-native-orientation-locker')
+    implementation project(':react-native-system-setting')
+    implementation project(':react-native-video')
}

RN <= 0.59

react-native link react-native-linear-gradient
react-native link react-native-orientation-locker
react-native link react-native-svg
react-native link react-native-system-setting
react-native link react-native-video

Android

  1. Append the following lines to android/settings.gradle:
include ':react-native-rn-videoplayer'
project(':react-native-rn-videoplayer').projectDir = new File(rootProject.projectDir, 	'../node_modules/react-native-rn-videoplayer/android')
  1. Insert the following lines inside the dependencies block in android/app/build.gradle:
  compile project(':react-native-rn-videoplayer')
  1. Open up android/app/src/main/java/[...]/MainApplication.java
  • Add
import com.ngxu.videoplayer.RNVideoplayerPackage;

new RNVideoplayerPackage() //to the list returned by the `getPackages()` method

Usage

import Videoplayer from 'react-native-rn-videoplayer';

< VideoPlayer 
url = { "https://xxxxx.mp4" } 
navigation = { this . Props . Navigation } //Route the return button for small screen playback 
ref = { ( ref ) => this . Player = ref } 
poster = { "http:XXX.jpg" } //Video cover 
/ >

api

  • url video address

  • continuous Whether to enable the selection function when full screen is suitable for serials, the default is false

  continuous={true}
  • renderAllSeenList The list of episodes displayed after clicking the selection
···
<VideoPlayer
  url={"https://xxxxx.mp4"}
  ref={(ref)=>this.player=ref}
  renderAllSeenList={this.renderAllSeenList}
/>

···
  renderAllSeenList = () => (
  <View style={{ width: height / 2.5, backgroundColor: "rgba(0,0,0,0.6)", position: "absolute", top: 0, bottom: 0, right: 0, }}>
      <ScrollView>
        <Button 
          onPress={()=> { 
              const  newdata  =  this . state . data 
                    newdata . index  =  newindex // Episode number 
              //Update episode number and restart playing 
              this . setState ( {  data : newdata  } ,  ( )  =>  {  this . player . rePlay ( )  } ) 
          } }

        />  
      </ScrollView>      

    </View>
  )
  • NextBtnFun The method of the next episode button in full screen. When it is the last episode, the value should be changed to false, and the button should be grayed out
const  { data }  =  this . state 
//data.index is the number of episodes 
//When the 
number of episodes currently played is the same as the total number of episodes, reset nextBtnFun to false nextBtnFun = { 
  data.index == data.datalist[data.datalist.length - 1].num - 1 ? false : this.nextBtnFun
  }
  • The icon of the favorite button in the upper right corner of storeComponent
  storeComponent={()=><Image/>}
  • moreSetting The icon of the more button in the upper right corner
  moreSetting={()=><Image/>}
  • setPaused play pause
  this . player . setPaused ( true ) //true pause; false play;

  <VideoPlayer
   ref={(ref)=>this.player=ref}
  >
  • reLoad
  this.player.reLoad()

  <VideoPlayer
   ref={(ref)=>this.player=ref}
  >
  • onSmallBack When the video is a small window, click the callback of the back button. You can add the function func to return to the previous page here.
  • onStore Click the callback func of the favorite button in the upper right corner
  • onMoreFun Click the callback func of the More button in the upper right corner
  • onWindowChange callback func for window change
  < VideoPlayer 
    onWindowChange = { ( e ) => { } } //e: "full" full screen "small" small screen 
  >
  • onLoad The callback that the video can start playing after loading successfully inherits react-native-veideo
  • onSeek The callback after adjusting the progress inherits the onSeek of react-native-video
  • onEnd The callback after playback inherits the onSeek of react-native-video
  • Whether onBuffer is waiting to be loaded, the video can be fetched and it is stuck showing loading or the video can be played to hide the loading callback. Inherit the onBuffer of react-native-video
  • poster video cover image The cover image displayed when the video cannot be played is not the loading frame inherits the react-native-video poster eg:poster={" http://i1.hdslb.com/bfs/archive/784013a39c59aede1ee9e775ec271790dfd7dc4b.jpg@ 320w_200h.jpg"}
  • … Inherit all the methods and properties of react-native-video
  • changeWindows() switch full screen or small screen
  • changeWindows(boolean) true full screen, false small screen
  • Example:
  <VideoPlayer ref={(ref)=>this.player=ref}/>
  this.player.changeWindows(true); // 全屏

Exposure method

import {NgxuSetting} from 'react-native-rn-videoplayer'

Show or hide the virtual buttons at the bottom of Android

const Setting = new NgxuSetting()
Setting.hideAndroidBottom()
Setting.showAndroidBottom()

Get the phone system brightness

const Setting = new NgxuSetting()
Setting.getBrightness((e)=>{consoloe.log(e)})

Change ios system brightness android current app brightness

  • Android only changes the current active brightness and does not modify the system brightness. Modifying the system brightness is very troublesome. It requires the user to manually open the phone settings, app permission settings, and manually open the advanced permissions of “Allow to modify system settings”
  • ios is to change the system brightness, you can
   const Setting = new NgxuSetting()
   Setting.SetBrightness(1)//0-1之间

Download Details:

Author: ngxu

Live Demo: https://streamja.com/embed/ZJk5P

GitHub: https://github.com/ngxu/react-native-rn-videoplayer

#react-native #react #mobile-apps

What is GEEK

Buddha Community

A Video Player Based on React Native Video
Autumn  Blick

Autumn Blick

1598839687

How native is React Native? | React Native vs Native App Development

If you are undertaking a mobile app development for your start-up or enterprise, you are likely wondering whether to use React Native. As a popular development framework, React Native helps you to develop near-native mobile apps. However, you are probably also wondering how close you can get to a native app by using React Native. How native is React Native?

In the article, we discuss the similarities between native mobile development and development using React Native. We also touch upon where they differ and how to bridge the gaps. Read on.

A brief introduction to React Native

Let’s briefly set the context first. We will briefly touch upon what React Native is and how it differs from earlier hybrid frameworks.

React Native is a popular JavaScript framework that Facebook has created. You can use this open-source framework to code natively rendering Android and iOS mobile apps. You can use it to develop web apps too.

Facebook has developed React Native based on React, its JavaScript library. The first release of React Native came in March 2015. At the time of writing this article, the latest stable release of React Native is 0.62.0, and it was released in March 2020.

Although relatively new, React Native has acquired a high degree of popularity. The “Stack Overflow Developer Survey 2019” report identifies it as the 8th most loved framework. Facebook, Walmart, and Bloomberg are some of the top companies that use React Native.

The popularity of React Native comes from its advantages. Some of its advantages are as follows:

  • Performance: It delivers optimal performance.
  • Cross-platform development: You can develop both Android and iOS apps with it. The reuse of code expedites development and reduces costs.
  • UI design: React Native enables you to design simple and responsive UI for your mobile app.
  • 3rd party plugins: This framework supports 3rd party plugins.
  • Developer community: A vibrant community of developers support React Native.

Why React Native is fundamentally different from earlier hybrid frameworks

Are you wondering whether React Native is just another of those hybrid frameworks like Ionic or Cordova? It’s not! React Native is fundamentally different from these earlier hybrid frameworks.

React Native is very close to native. Consider the following aspects as described on the React Native website:

  • Access to many native platforms features: The primitives of React Native render to native platform UI. This means that your React Native app will use many native platform APIs as native apps would do.
  • Near-native user experience: React Native provides several native components, and these are platform agnostic.
  • The ease of accessing native APIs: React Native uses a declarative UI paradigm. This enables React Native to interact easily with native platform APIs since React Native wraps existing native code.

Due to these factors, React Native offers many more advantages compared to those earlier hybrid frameworks. We now review them.

#android app #frontend #ios app #mobile app development #benefits of react native #is react native good for mobile app development #native vs #pros and cons of react native #react mobile development #react native development #react native experience #react native framework #react native ios vs android #react native pros and cons #react native vs android #react native vs native #react native vs native performance #react vs native #why react native #why use react native

Juned Ghanchi

1621573085

React Native App Developers India, React Native App Development Company

Expand your user base by using react-native apps developed by our expert team for various platforms like Android, Android TV, iOS, macOS, tvOS, the Web, Windows, and UWP.

We help businesses to scale up the process and achieve greater performance by providing the best react native app development services. Our skilled and experienced team’s apps have delivered all the expected results for our clients across the world.

To achieve growth for your business, hire react native app developers in India. You can count on us for all the technical services and support.

#react native app development company india #react native app developers india #hire react native developers india #react native app development company #react native app developers #hire react native developers

Hire Dedicated React Native Developer

Have you ever thought of having your own app that runs smoothly over multiple platforms?

React Native is an open-source cross-platform mobile application framework which is a great option to create mobile apps for both Android and iOS. Hire Dedicated React Native Developer from top React Native development company, HourlyDeveloper.io to design a spectacular React Native application for your business.

Consult with experts:- https://bit.ly/2A8L4vz

#hire dedicated react native developer #react native development company #react native development services #react native development #react native developer #react native

Hire Dedicated React Native Developers - WebClues Infotech

Being one of the emerging frameworks for app development the need to develop react native apps has increased over the years.

Looking for a react native developer?

Worry not! WebClues infotech offers services to Hire React Native Developers for your app development needs. We at WebClues Infotech offer a wide range of Web & Mobile App Development services based o your business or Startup requirement for Android and iOS apps.

WebClues Infotech also has a flexible method of cost calculation for hiring react native developers such as Hourly, Weekly, or Project Basis.

Want to get your app idea into reality with a react native framework?

Get in touch with us.

Hire React Native Developer Now: https://www.webcluesinfotech.com/hire-react-native-app-developer/

For inquiry: https://www.webcluesinfotech.com/contact-us/

Email: sales@webcluesinfotech.com

#hire react native developers #hire dedicated react native developers #hire react native developer #hiring a react native developer #hire freelance react native developers #hire react native developers in 1 hour

Factors affecting the cost of hiring a React Native developer in USA - TopDevelopers.co

Want to develop app using React Native? Here are the tips that will help to reduce the cost of react native app development for you.
Cost is a major factor in helping entrepreneurs take decisions about investing in developing an app and the decision to hire react native app developers in USA can prove to be fruitful in the long run. Using react native for app development ensures a wide range of benefits to your business. Understanding your business and working on the aspects to strengthen business processes through a cost-efficient mobile app will be the key to success.

#best react native development companies from the us #top react native app development companies in usa #cost of hiring a react native developer in usa #top-notch react native developer in usa #best react native developers usa #react native