All Projects → ammarahm-ed → Rn Floating Video Widget

ammarahm-ed / Rn Floating Video Widget

Licence: mit
React Native Module for Floating/Popup video player on Android.

Programming Languages

javascript
184084 projects - #8 most used programming language
java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Rn Floating Video Widget

Celluloid
A simple GTK+ frontend for mpv
Stars: ✭ 541 (+1445.71%)
Mutual labels:  video-player
Iina
The modern video player for macOS.
Stars: ✭ 28,688 (+81865.71%)
Mutual labels:  video-player
React Itinerary
Render react components based on time sequences such as video or audio files.
Stars: ✭ 13 (-62.86%)
Mutual labels:  video-player
Clappr
🎬 An extensible media player for the web.
Stars: ✭ 5,436 (+15431.43%)
Mutual labels:  video-player
Yuview
The Free and Open Source Cross Platform YUV Viewer with an advanced analytics toolset
Stars: ✭ 665 (+1800%)
Mutual labels:  video-player
Mpv.net
🎞 mpv.net is a modern media player for Windows that works just like mpv.
Stars: ✭ 737 (+2005.71%)
Mutual labels:  video-player
Vue Plyr
A Vue component for the plyr (https://github.com/sampotts/plyr) video & audio player.
Stars: ✭ 531 (+1417.14%)
Mutual labels:  video-player
Better Chrome Native Video
Add keyboard support to Chrome's native HTML5 video player.
Stars: ✭ 31 (-11.43%)
Mutual labels:  video-player
Videogular2
The HTML5 video player for Angular 2
Stars: ✭ 678 (+1837.14%)
Mutual labels:  video-player
Fluttertianyue
基于Flutter的超完整仿腾讯动漫,小说阅读,抖音视频项目,功能丰富,适合学习和日常使用,拥有较好的项目结构&比较规范的代码!Flutter入门,看这个就够了~Flutter project which provide richer functionality, if you want to learn flutter, this project is a good choice
Stars: ✭ 871 (+2388.57%)
Mutual labels:  video-player
Rx Player
DASH/Smooth HTML5 Video Player
Stars: ✭ 600 (+1614.29%)
Mutual labels:  video-player
Pbjvideoplayer
▶️ video player, simple way to play and stream media on iOS/tvOS
Stars: ✭ 620 (+1671.43%)
Mutual labels:  video-player
Drm wv fp player
Few of the resources from flutter plugin video_player
Stars: ✭ 19 (-45.71%)
Mutual labels:  video-player
Server
CasparCG Server is a Windows and Linux software used to play out professional graphics, audio and video to multiple outputs. It has been in 24/7 broadcast production since 2006. Ready-to-use downloads are available under the Releases tab https://casparcg.com.
Stars: ✭ 572 (+1534.29%)
Mutual labels:  video-player
Fijkplayer
ijkplayer for flutter. ijkplayer 的 flutter 封装。 Flutter video/audio player. Flutter media player plugin for android/iOS based on ijkplayer. fijkplayer 是基于 ijkplayer 封装的 flutter 媒体播放器,开箱即用,无需编译 ijkplayer
Stars: ✭ 943 (+2594.29%)
Mutual labels:  video-player
Shaka Player
JavaScript player library / DASH & HLS client / MSE-EME player
Stars: ✭ 5,386 (+15288.57%)
Mutual labels:  video-player
H5player
网页播放器增强脚本,支持:播放进度记录、播放倍率记录、快进快退、倍速播放、画面缩放等
Stars: ✭ 736 (+2002.86%)
Mutual labels:  video-player
Videojscustomization
HTML5 视频播放器 自定制: React + video.js 详细讲解
Stars: ✭ 32 (-8.57%)
Mutual labels:  video-player
Dailymotion Swift Player Sdk Ios
Dailymotion Player SDK for iOS in Swift
Stars: ✭ 29 (-17.14%)
Mutual labels:  video-player
Abplayerhtml5
Video Player for danmaku comments. ABPlayer in HTML5. ABPlayer核心构件以动态HTML编写的版本。向HTML5进发!HTML5弹幕播放器
Stars: ✭ 858 (+2351.43%)
Mutual labels:  video-player

rn-floating-video-widget

PRs Welcome rn-floating-video-widget rn-floating-video-widget

React Native Module for Floating/Popup video player on Android. From android 8.0 Oreo onwards we have PictureInPicture mode built into android which is great but even today there are many devices below android 8.0 and hence there is a need for some alternative. This library helps you with that issue if you are making a video application with floating video support starting from android 4.4.2 kitkat.

Run the Example

To run the example app clone the project

git clone https://github.com/ammarahm-ed/rn-floating-video-widget.git

then run yarn or npm install in the example folder and finally to run the example app:

react-native run-android

Installation

npm install rn-floating-video-widget --save

or if you use yarn:

yarn add rn-floating-video-widget

If you are using react-native <= 0.59.0 you also need to run:

react-native link rn-floating-video-widget

Add permission SYSTEM_ALERT_WINDOW to AndroidManifest.xml:

<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>

Add the following service in AndroidManifest.xml inside <application> tag:

<application>
    ...
    <service android:name="com.rnfloatingvideowidget.FloatingVideoWidgetShowService"  
    android:enabled="true"></service>
    ...
</application>

Usage

For complete usage, see the example project.

import React from "react";
import {
  StyleSheet,
  View,
  TouchableOpacity,
  ToastAndroid,
  Text
} from "react-native";
import FloatingVideo from "rn-floating-video-widget";

export default class App extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      floating: false,
      granted: false
    };
    // The Data Object
    this.data = {
      video: {
        url:
          "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4"
      },
      videos: [
        {
          url:
            "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4"
        },
        {
          url:
            "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ElephantsDream.mp4"
        },
        {
          url:
            "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ForBiggerBlazes.mp4"
        }
      ],
      seek: 10,
      index: 0
    };
  }

  componentDidMount() {
    // Add event listeners

    FloatingVideo.onClose(data => console.log(data));
    FloatingVideo.onOpen(data => console.log(data));
    FloatingVideo.onPlay(data => console.log(data));
    FloatingVideo.onPause(data => console.log(data));
    FloatingVideo.onNext(data => console.log(data));
    FloatingVideo.onPrev(data => console.log(data));
    FloatingVideo.onError(data => console.log(data));
  }

  enterPipMode() {
    FloatingVideo.requestOverlayPermission()
      .then(() => {
        this.setState({
          floating: true,
          granted: true
        });
        FloatingVideo.open(this.data);
      })
      .catch(e => {
        ToastAndroid.show(
          "Please grant draw over other apps permission" + JSON.stringify(e),
          800
        );
      });
  }

  componentWillUnmount() {
    FloatingVideo.removeAllListeners();
  }

  render() {
    const floating = this.state.floating;

    return (
      <View style={styles.container}>
        <TouchableOpacity
          style={styles.start}
          onPress={() => {
            this.enterPipMode();
          }}
        >
          <Text
            style={{
              color: "white",
              fontSize: 20
            }}
          >
            START
          </Text>
        </TouchableOpacity>
      </View>
    );
  }
}

const styles = StyleSheet.create({
  container: {
    flex: 1,

    alignItems: "center",
    paddingTop: 20,
    backgroundColor: "#F5FCFF"
  },
  welcome: {
    fontSize: 20,
    textAlign: "center",
    margin: 10
  },
  start: {
    width: "90%",
    alignSelf: "center",
    padding: 15,
    backgroundColor: "red",
    justifyContent: "center",
    alignItems: "center",
    elevation: 5,
    borderRadius: 5
  },
  button: {
    alignSelf: "center",
    padding: 5,
    borderWidth: 1,
    borderColor: "red",
    backgroundColor: "white",
    justifyContent: "center",
    alignItems: "center",
    elevation: 5,
    borderRadius: 5
  }
});

FloatingVideo API

FloatingVideo API has been kept very simple and practical in use.

Methods

Name Arguments Description
open Data object (see below) Initialise the player and play video
play Play/Resume the video
pause Pause the video
next Play the next video in playlist
prev Play the previous video in playlist
close Close the Foating Video Player
requestOverlayPermission Ask for draw over other apps permission

Data Object

The video data object is a single object that can have the following properties

Name Type Required Description
video Object yes A video object should have a url property.
videos Array no Array of the above video objects
seek number(ms) no seek video on load to this value
index number no index of video object in videos array.

Event Listeners

All event listeners should have a callback function as an argument to handle the event.

Name Description Data recieved from event
onOpen Floating video is open and video is playing {type:"open",seek,index,url}
onPlay Video started playing {type:"play",seek,index,url}
onPause Video was paused {type:"pause",seek,index,url}
onNext Next video started playing {type:"next",seek,index,url}
onPrev Previous video started playing {type:"prev",seek,index,url}
onClose Floating Video Player was closed {type:"close",seek,index,url}
onError An error occurred {type:"error",seek,index,url}

Don't forget to call FloatingVideo.removeAllListeners() when component unmount.

Todo List

  • [ ] Improve native code quality
  • [ ] Complete error handling
  • [ ] Use ExoPlayer w/o ExoMedia Library

Thanks to developers of following libraries

Dependencies

MIT Licensed

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].