Git Product home page Git Product logo

alantoa / react-native-reanimated-player Goto Github PK

View Code? Open in Web Editor NEW
264.0 8.0 19.0 45.01 MB

▶️ An excellent video player controller that offers animation, performance, interactivity, and customization.

License: MIT License

JavaScript 1.58% TypeScript 79.79% Starlark 0.42% Java 4.87% Ruby 0.68% Objective-C 12.52% Swift 0.06% C 0.07%
react-native react-native-component react-native-community react-native-video react-native-video-controls react-native-video-player react-native-reanimated react-native-gesture-handler

react-native-reanimated-player's Introduction

React Native Reanimated Player

Reanimated v2 version npm npm runs with expo

100% written in Typescript video player component, interaction is like Youtube player.

⚠️ Expo

This is the react-native-video version, If you use Expo, please check out expo-reanimated-av-player!

Installation

First you have to follow installation instructions of:

If react-native-gesture-handler version >= 2:

yarn add react-native-reanimated-player

else use v1:

yarn add react-native-reanimated-player@1

Example usage

import VideoPlayer from 'react-native-reanimated-player';
import { useSharedValue } from 'react-native-reanimated';
export const Example = () => {
  const videoHeight = useSharedValue(0);
  const isFullScreen = useSharedValue(false);
  const { paused, setPaused } = useContext(false);

  return (
    <VideoPlayer
      source={uri}
      headerTitle={'Title in full screen mode'}
      onTapBack={() => {
        Alert.alert('onTapBack');
      }}
      onTapMore={() => {
        Alert.alert('onTapMore');
      }}
      onPausedChange={state => {
        Alert.alert(`onPausedChange: ${state}`);
        setPaused(state);
      }}
      videoHeight={videoHeight}
      paused={paused}
      isFullScreen={isFullScreen}
    />
  );
};

Features

  • 100% written in TypeScript.
  • 100% built upon react-native-reanimated and react-native-gusture-handler.
  • Support gestures switch full screen.
  • Support double tap seek to back or ahead.
  • ...

TODO list

  • Add more custom props
  • Add Previous & Next button
  • Rewrite the gesture section with react-native-gusture-handle V2
  • Add expo-av support
  • ...and more

Configuration

The <VideoPlayer/> component has the following configuration properties:

Name Type Description Required Default Value
theme object The slider theme color { // Color to fill the progress in the seekbar minimumTrackTintColor: string, // Color to fill the background in the seekbar maximumTrackTintColor: string, // Color to fill the cache in the seekbar cacheTrackTintColor: string, // Color to fill the bubble backgroundColor disableMinTrackTintColor: string, // Disabled color to fill the progress in the seekbar bubbleBackgroundColor: string }
showOnStart boolean control view init show false
onEnterFullscreen function on enter fullscreen callback undefined
onExitFullscreen function on exit fullscreen callback undefined
controlTimeout nubmer How long to hide the control view after showing 2000
videoDefaultHeight number video default height screenWidth * (9 / 16)
headerBarTitle string header bar title on fullscreen mode undefined
onTapBack function tap header bar Icon-'Back' callback undefined
navigation any navigation undefined
autoPlay boolean auto play false
onToggleAutoPlay function on toggle auto play undefined
onTapMore function tap headerbar Icon-'More' callback undefined
doubleTapInterval number double tap interval undefined
paused boolean video paused undefined
onPausedChange boolean on change video paused undefined
onTapPause function on tap video paused undefined
sliderProps object react-native-awesome-slider props undefined
videoHeight Animated.SharedValue video height width * (9 / 16);
customAnimationStyle Animated Viewstyle video height width * (9 / 16);
onCustomPanGesture PanGesture custom pan gesture width * (9 / 16);
isFullScreen Animated ShareValue fullScreen status undefined
disableControl boolean control view status undefined
renderBackIcon JSX custom back icon undefined
renderFullScreenBackIcon JSX custom full's fullscreen icon undefined
renderMore JSX custom more icon undefined
renderFullScreen JSX custom fullscreen icon undefined
children JSX child components to be rendered under video player controls undefined
onPostProgress function callback function that is called every progressUpdateInterval milliseconds with info about which position the media is currently playing undefined
onPostSeek function callback function that is called when a seek completes undefined

react-native-reanimated-player's People

Contributors

alantoa avatar khlling avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

react-native-reanimated-player's Issues

VideoPlayer's `onTapBack` property is not called when the button is clicked.

I tried to implement the logic below, I want to make the user go back to the previous screen when clicking on the backButton, but the event is not triggered!

My code:

export const VideoScreen = function (props: VideoScreenProps) {

  const navigation = useNavigation()

  const videoRef = React.useRef<VideoPlayerRef>();
  const videoHeight = useSharedValue(width * (9 / 16));
  const isFullScreen = useSharedValue(false);

  const [paused, setPaused] = useState(false);

  return (
    <SafeAreaProvider>
      <GestureHandlerRootView >
        <VideoPlayer
          ref={videoRef}
          navigation={navigation}
          theme={{
            minimumTrackTintColor: Colors.primary,
            bubbleBackgroundColor: Colors.primary,
          }}
          source={{
            uri: 'my url goes here!'
          }}
          onTapBack={() => {
            console.log('onTapBack') // <--------- does not print on the console when clicking on the backButton
            Alert.alert('onTapBack');
          }}
          headerBarTitle={'Darling in the Franxx'}
          onPausedChange={setPaused}
          videoHeight={videoHeight}
          paused={paused}
          isFullScreen={isFullScreen}
        />
      </GestureHandlerRootView>
    </SafeAreaProvider>
  );
}

Unable to resolve module lottie-react-native ?

Does it depend on lottie-react-native? I don't have lottie-react-native installed and I'm getting errors. Your documentation dependencies do not indicate that lottie-react-native is required

f you are sure the module exists, try these steps:

  1. Clear watchman watches: watchman watch-del-all
  2. Delete node_modules and run yarn install
  3. Reset Metro's cache: yarn start --reset-cache
  4. Remove the cache: rm -rf /tmp/metro-*
    1 | /* eslint-disable no-undef */

2 | import LottieView from 'lottie-react-native';
| ^

not working on android

hi, player controls are not working on android.

import React from "react";
import Navigators from "./src/navigators";
import Store from "./src/Store";
import { Provider } from "react-redux";
import {
initialWindowMetrics,
SafeAreaProvider,
} from "react-native-safe-area-context";
import VideoPlayer from "react-native-reanimated-player";
import { useSharedValue } from "react-native-reanimated";

export default () => {
const videoHeight = useSharedValue(300);
const isFullScreen = useSharedValue(false);

return (

<VideoPlayer
showOnStart={true}
source={{
uri: "https://famee.bitwork.tech/public/uploads/BkHyttGZb9.mp4",
}}
headerTitle={"Title in full screen mode"}
onTapBack={() => {
// Alert.alert('onTapBack');
}}
onTapMore={() => {
// Alert.alert('onTapMore');
}}
onPausedChange={(state) => {
//Alert.alert(onPausedChange: ${state});
//setPaused(state);
}}
videoHeight={videoHeight}
//paused={paused}
isFullScreen={isFullScreen}
disableControl={false}
/>

);
};

at start controls shows but after playing video, they disapears

Pressing FullScreen does nothing

Is there something extra we have to do to get the fullscreen button press to work? There currently is no feedback or output when you press the icon.

Fullscreen render issue

If we add some view above the player, the full screen render incorrectly.
Please check the screenshots for the same.

Simulator Screen Shot - iPhone 12 - 2023-06-09 at 06 16 18
Simulator Screen Shot - iPhone 12 - 2023-06-09 at 06 16 22

Not working with reanimated v3

hello, there is a bug with reanimated 3.

image

project detail:
"react": "18.2.0",
"react-native": "0.71.2",
"react-native-reanimated": "^3.0.2",
"react-native-reanimated-player": "^2.3.0",

Is there a way to render a child?

I wanted to add a proximity banner inside the component video.

My idea is to move to another screen

With a behavior similar to that of the youtube player.

image

doubleTapHandler, onStart never fires on Android

Firstly, I found this module from your react-native-awesome-slider. I've taken some time to look through the source code and example. It's great, using reanimated v2 for this kind of animation work is the way forward.

Whilst testing the example on an Android emulator I found that there is inconsistency between when singleTapHandler and doubleTapHandler when is fired. For example adding console.logs:

    const singleTapHandler = useAnimatedGestureHandler<
      GestureEvent<TapGestureHandlerEventPayload>
    >({
      onActive: () => {
        console.log('singleTapHandler')
        if (controlViewOpacity.value === 0) {
          controlViewOpacity.value = withTiming(1, controlAnimteConfig);
          setControlTimeout();
        } else {
          controlViewOpacity.value = withTiming(0, controlAnimteConfig);
        }
      },
    });

    const doubleTapHandler = useAnimatedGestureHandler<
      GestureEvent<TapGestureHandlerEventPayload>,
      {
        isAlive: boolean;
      }
    >({
      onStart: ({ x }, ctx) => {
        console.log('doubleTapHandler, onStart')
        if (x > leftDoubleTapBoundary && x < rightDoubleTapBoundary) {
          ctx.isAlive = false;
          return;
        } else {
          ctx.isAlive = true;
        }
      },
      onActive: ({ x, y, numberOfPointers }, ctx) => {
        console.log('doubleTapHandler, onActive')
        if (numberOfPointers !== 1) return;
        if (!ctx.isAlive) {
          resetControlTimeout();
          if (controlViewOpacity.value === 0) {
            showControlAnimation();
            return;
          }
        }

        if (x < leftDoubleTapBoundary) {
          doubleLeftOpacity.value = 1;
          rippleLeft.current?.onPress({ x, y });
          runOnJS(seekByStep)(true);
          return;
        }

        if (x > rightDoubleTapBoundary) {
          doubleRightOpacity.value = 1;
          rippleRight.current?.onPress({
            x: x - rightDoubleTapBoundary,
            y,
          });
          runOnJS(seekByStep)(false);

          return;
        }
      },
    });

If I tap the play button once:

  1. singleTapHandler
  2. doubleTapHandler, onStart

This is only one scenario I've observed but "doubleTapHandler, onStart'" is never logged out in all cases so you can never go 10s forward or backwards. Strangely this problem does not appear on the iOS simulator so my suspicion is that it might be to do with react-native-gesture-handler and its Android integration but I can't be sure as this module uses the v1 and the v2 changes are substantial (I noticed that you have v2 as on your todo).

Long story short have you seen this issue before and do you know what might be causing it?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.