Coder Social home page Coder Social logo

react-native-torrent-streamer's Introduction

React-Native-Torrent-Streamer

Torrent Streamer for react-native

Only Android support now.

- 0.2.0 Release

  • Support react-native 0.60.x
  • TorrentStream-Android updated to

Integrate

Android
  • Install via npm yarn add react-native-torrent-streamer

  • Add android/build.gradle

...
allprojects {
  ...
  dependencies {
      ...
+      maven {
+        url("https://jitpack.io")
+      }
  }
}

Usage

import React, { Component } from 'react';
import { AppRegistry, StyleSheet, View, Text, TouchableHighlight } from 'react-native'

import TorrentStreamer from 'react-native-torrent-streamer'

export default class App extends Component<{}> {
  state = {
    progress: 0,
    buffer: 0,
    downloadSpeed: 0,
    seeds: 0
  }

  componentDidMount() {
    TorrentStreamer.addEventListener('error', this.onError)
    TorrentStreamer.addEventListener('status', this.onStatus.bind(this))
    TorrentStreamer.addEventListener('ready', this.onReady.bind(this))
    TorrentStreamer.addEventListener('stop', this.onStop.bind(this))
  }

  onError(e) {
    console.log(e)
  }

  onStatus({progress, buffer, downloadSpeed, seeds}) {
    this.setState({
      progress,
      buffer,
      downloadSpeed,
      seeds
    })
  }

  onReady(data) {
    TorrentStreamer.open(data.url, 'video/mp4')
  }

  onStop(data) {
    console.log('stop')
  }

  render() {
    const { progress, buffer, downloadSpeed, seeds } = this.state

    return (
      <View style={styles.container}>
        <TouchableHighlight
          style={styles.button}
          onPress={this._handleStart.bind(this)}>
            <Text >Start Torrent!</Text>
        </TouchableHighlight>

        <TouchableHighlight
          style={styles.button}
          onPress={this._handleStop.bind(this)}>
            <Text >Stop Torrent!</Text>
        </TouchableHighlight>

        {buffer ? <Text>Buffer: {buffer}</Text> : null}
        {downloadSpeed ? <Text>Download Speed: {(downloadSpeed / 1024).toFixed(2)} Kbs/seg</Text> : null}
        {progress ? <Text>Progress: {parseFloat(progress).toFixed(2)}</Text> : null}
        {seeds ? <Text>Seeds: {seeds}</Text> : null}
      </View>
    )
  }

  _handleStart() {
    TorrentStreamer.start('magnet:?xt=urn:btih:88594aaacbde40ef3e2510c47374ec0aa396c08e&dn=bbb%5Fsunflower%5F1080p%5F30fps%5Fnormal.mp4&tr=udp%3A%2F%2Ftracker.openbittorrent.com%3A80%2Fannounce&tr=udp%3A%2F%2Ftracker.publicbt.com%3A80%2Fannounce&ws=http%3A%2F%2Fdistribution.bbb3d.renderfarming.net%2Fvideo%2Fmp4%2Fbbb%5Fsunflower%5F1080p%5F30fps%5Fnormal.mp4')
  }

  _handleStop() {
    this.setState({
      progress: 0,
      buffer: 0,
      downloadSpeed: 0,
      seeds: 0
    }, () => {
      TorrentStreamer.stop()
    })
  }
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
    backgroundColor: '#F5FCFF',
  }
})

LICENSE

MIT

react-native-torrent-streamer's People

Contributors

ghondar 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

react-native-torrent-streamer's Issues

Event Listener not working

No Event Listener returns to React.

react 16.2.0
react-native 0.53.0
react-native-torrent-streamer 0.1.1

Support Parallel Torrents

As you can see I started only the first one on the list, but the events are returning to everyone.

A gif is the continuation of the other
ezgif-1-3fdee1bef8
2ezgif-1-80eb9657c8

Follow the source code

import React, { Component } from 'react';
import { View } from 'react-native'
import TorrentStreamer from 'react-native-torrent-streamer'
import Item from './Item';

export default class App extends Component {
  render() {
    return (
      <View>
        <Item magnet="magnet:?xt=urn:btih:401b95a6de2ee3c99a166f77344e20eede090d78&dn=The.Big.Bang.Theory.S11E15.The.Novelization.Correlation.720p.AMZN.WEBRip.DDP5.1.x264-NTb%5Brartv%5D&tr=http%3A%2F%2Ftracker.trackerfix.com%3A80%2Fannounce&tr=udp%3A%2F%2F9.rarbg.me%3A2710&tr=udp%3A%2F%2F9.rarbg.to%3A2710" />
        <Item magnet="magnet:?xt=urn:btih:6b82b6e3a2549de82f76071a0b59e370d4070338&dn=The.Big.Bang.Theory.S11E14.The.Separation.Triangulation.720p.AMZN.WEBRip.DDP5.1.x264-NTb%5Brartv%5D&tr=http%3A%2F%2Ftracker.trackerfix.com%3A80%2Fannounce&tr=udp%3A%2F%2F9.rarbg.me%3A2710&tr=udp%3A%2F%2F9.rarbg.to%3A2710" />
        <Item magnet="magnet:?xt=urn:btih:773f1f4c2e6d354dab798e4a7d4d8179746bcecd&dn=The.Big.Bang.Theory.S11E13.WEB-DL.x264-ION10&tr=http%3A%2F%2Ftracker.trackerfix.com%3A80%2Fannounce&tr=udp%3A%2F%2F9.rarbg.me%3A2710&tr=udp%3A%2F%2F9.rarbg.to%3A2710" />
        <Item magnet="magnet:?xt=urn:btih:772837cd094496818b21116332aed7385d609f75&dn=The.Big.Bang.Theory.S11E12.WEB-DL.x264-RARBG&tr=http%3A%2F%2Ftracker.trackerfix.com%3A80%2Fannounce&tr=udp%3A%2F%2F9.rarbg.me%3A2710&tr=udp%3A%2F%2F9.rarbg.to%3A2710" />
      </View>
    )
  }
}
import React, { Component } from 'react';
import { View, Text, TouchableHighlight } from 'react-native'
import TorrentStreamer from 'react-native-torrent-streamer'

export default class Item extends Component {
  constructor(props) {
    super(props);
  
    this.state = {
      progress: 0,
      buffer: 0,
      downloadSpeed: 0,
      seeds: 0,
    };


    this.onError = this.onError.bind(this);
    this.onStatus = this.onStatus.bind(this);
    this.onReady = this.onReady.bind(this);
    this.onStop = this.onStop.bind(this);
    this._handleStart = this._handleStart.bind(this);
    this._handleStop = this._handleStop.bind(this);
  }

  componentWillMount() {
    TorrentStreamer.addEventListener('error', this.onError)
    TorrentStreamer.addEventListener('status', this.onStatus)
    TorrentStreamer.addEventListener('ready', this.onReady)
    TorrentStreamer.addEventListener('stop', this.onStop)
  }

  onError(e) {
    console.log(e)
  }

  onStatus({ progress, buffer, downloadSpeed, seeds }) {
    this.setState({
      progress,
      buffer,
      downloadSpeed,
      seeds
    })
  }

  onReady(data) {
    console.log('ready', data);
  }

  onStop(data) {
    console.log('stop', data)
  }

  render() {
    const { progress, buffer, downloadSpeed, seeds } = this.state

    return (
      <View style={{margin: 20}}>
        <TouchableHighlight
          onPress={this._handleStart.bind(this)}
          >
            <Text >Start Torrent!</Text>
        </TouchableHighlight>

        <TouchableHighlight
          onPress={this._handleStop.bind(this)}
          >
            <Text >Stop Torrent!</Text>
        </TouchableHighlight>

        {buffer ? <Text>Buffer: {buffer}</Text> : null}
        {downloadSpeed ? <Text>Download Speed: {(downloadSpeed / 1024).toFixed(2)} Kbs/seg</Text> : null}
        {progress ? <Text>Progress: {parseFloat(progress).toFixed(2)}</Text> : null}
        {seeds ? <Text>Seeds: {seeds}</Text> : null}
      </View>
    );
  }

  private
  _handleStart() {
    TorrentStreamer.start(this.props.magnet);
  }

  _handleStop() {
    this.setState({
      progress: 0,
      buffer: 0,
      downloadSpeed: 0,
      seeds: 0
    }, () => {
      TorrentStreamer.stop()
    });
  }
}

send file during stream

Would it be possible to implement the sending of the file during transmission? for other users who are watching the same time

0.63 not working

Hi, I have created new project using react native 0.63.3 and also it's functional component, i tried to integrate it but nothing works, please add support for 0.63.*

import React, {useEffect} from 'react';
import {Button, SafeAreaView, StatusBar, Text} from 'react-native';
import TorrentStreamer from 'react-native-torrent-streamer';

const magnet =
  'magnet:?xt=urn:btih:942c4e341488b632b49b0628b5a37716818d5269&dn=Artemis.Fowl.2020.REPACK.720p.DSNP.WEBRip.800MB.x264-GalaxyRG%5BTGx%5D&xl=835868069&tr=udp%3A%2F%2Ftracker.coppersurfer.tk:6969/announce&tr=udp%3A%2F%2Ftracker.leechers-paradise.org:6969/announce&tr=udp%3A%2F%2Ftracker.cyberia.is:6969/announce&tr=udp%3A%2F%2Ftracker.iamhansen.xyz:2000/announce&tr=udp%3A%2F%2Fp4p.arenabg.com:1337/announce&tr=udp%3A%2F%2Fexplodie.org:6969/announce&tr=udp%3A%2F%2Ftracker.opentrackr.org:1337/announce&tr=udp%3A%2F%2Ftracker.tiny-vps.com:6969/announce&tr=udp%3A%2F%2Fexodus.desync.com:6969/announce&tr=udp%3A%2F%2Ftracker.torrent.eu.org:451/announce&tr=udp%3A%2F%2Ftracker.moeking.me:6969/announce&tr=udp%3A%2F%2Fipv4.tracker.harry.lu:80/announce&tr=udp%3A%2F%2Fopen.stealth.si:80/announce&tr=udp%3A%2F%2F9.rarbg.to:2710/announce&tr=udp%3A%2F%2Fopentor.org:2710/announce';

const App = () => {
  useEffect(() => {
    TorrentStreamer.addEventListener('ready', (data: any) => {
      console.log(data, 'data');
    });
  }, []);

  useEffect(() => {
    TorrentStreamer.addEventListener('status', (data: any) => {
      console.log(data, 'data');
    });
  }, []);

  useEffect(() => {
    TorrentStreamer.addEventListener('error', (data: any) => {
      console.log(data, 'data');
    });
  }, []);

  useEffect(() => {
    TorrentStreamer.addEventListener('stop', (data: any) => {
      console.log(data, 'data');
    });
  }, []);

  const startTorrent = () => {
    try {
      console.log('starting');

      TorrentStreamer.start(magnet);
    } catch (error) {
      console.log('error', error);
    }
  };

  return (
    <>
      <StatusBar barStyle="dark-content" />
      <SafeAreaView>
        <Button title="hello" onPress={startTorrent} />
      </SafeAreaView>
    </>
  );
};

export default App;

FAILURE: Build failed with an exception.

React Native Version 0.39
compileSdkVersion 23
buildToolsVersion 23.0.1

That's what I get when I execute: react-native run-android

* What went wrong:
Execution failed for task :app:prepareMoviesAppReactNativeTorrentStreamerUnspecifiedLibrary.
Could not expand ZIP D:\React Native\MyApp\node_modules\react-native-torrent-streamer\android\torrent\b
uild\outputs\aar\react-native-torrent-streamer-release.aar.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.


BUILD FAILED

Total time: 30.202 secs
Could not install the app on the device, read the error above for details.
Make sure you have an Android emulator running or a device connected and have
set up your Android development environment:
https://facebook.github.io/react-native/docs/android-setup.html

(node:8628) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 2): TypeError: Cannot
 read property 'message' of undefined

DLNA Support

I don't know if its possible but it could be great to have it.

Cant get it to run

/Users/home/code/bingewatch/node_modules/react-native-torrent-streamer/android/torrent/src/main/java/com/ghondar/torrentstreamer/TorrentStreamerPackage.java:22: error: method does not override or implement a method from a supertype
@OverRide
^
1 error
:react-native-torrent-streamer:compileReleaseJavaWithJavac FAILED

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':react-native-torrent-streamer:compileReleaseJavaWithJavac'.

Compilation failed; see the compiler error output for details.

TypeError: null is not an object (evaluating 'torrentstreamer.start') TypeError: Cannot read property 'start' of undefined

Description
example not working

Observed Behavior
TypeError: null is not an object (evaluating 'torrentstreamer.start')
Uncaught TypeError: Cannot read property 'start' of undefined at Object.start (index.js:37) at App._handleStart (App.js:8) at Object.touchableHandlePress (index.js:166) at Object._performSideEffectsForTransition (index.js:730) at Object._receiveSignal (index.js:642) at Object.touchableHandleResponderRelease (index.js:428) at domProps.<computed> (index.js:65) at HTMLUnknownElement.callCallback (react-dom.development.js:347) at Object.invokeGuardedCallbackDev (react-dom.development.js:397) at invokeGuardedCallback (react-dom.development.js:454) at invokeGuardedCallbackAndCatchFirstError (react-dom.development.js:468) at executeDispatch (react-dom.development.js:600) at executeDispatchesInOrder (react-dom.development.js:622) at executeDispatchesAndRelease (react-dom.development.js:725) at executeDispatchesAndReleaseTopLevel (react-dom.development.js:733) at Array.forEach (<anonymous>) at forEachAccumulated (react-dom.development.js:705) at runEventsInBatch (react-dom.development.js:750) at runExtractedPluginEventsInBatch (react-dom.development.js:881) at handleTopLevel (react-dom.development.js:5901) at batchedEventUpdates (react-dom.development.js:2344) at dispatchEventForPluginEventSystem (react-dom.development.js:5996) at dispatchEvent (react-dom.development.js:6025) at unstable_runWithPriority (scheduler.development.js:643) at runWithPriority$2 (react-dom.development.js:11305) at discreteUpdates$1 (react-dom.development.js:21672) at discreteUpdates (react-dom.development.js:2359) at dispatchDiscreteEvent (react-dom.development.js:5979) react-dom.development.js:487 Uncaught TypeError: Cannot read property 'start' of undefined at Object.start (index.js:37) at App._handleStart (App.js:8) at Object.touchableHandlePress (index.js:166) at Object._performSideEffectsForTransition (index.js:730) at Object._receiveSignal (index.js:642) at Object.touchableHandleResponderRelease (index.js:428) at domProps.<computed> (index.js:65) at HTMLUnknownElement.callCallback (react-dom.development.js:347) at Object.invokeGuardedCallbackDev (react-dom.development.js:397) at invokeGuardedCallback (react-dom.development.js:454) at invokeGuardedCallbackAndCatchFirstError (react-dom.development.js:468) at executeDispatch (react-dom.development.js:600) at executeDispatchesInOrder (react-dom.development.js:622) at executeDispatchesAndRelease (react-dom.development.js:725) at executeDispatchesAndReleaseTopLevel (react-dom.development.js:733) at Array.forEach (<anonymous>) at forEachAccumulated (react-dom.development.js:705) at runEventsInBatch (react-dom.development.js:750) at runExtractedPluginEventsInBatch (react-dom.development.js:881) at handleTopLevel (react-dom.development.js:5901) at batchedEventUpdates (react-dom.development.js:2344) at dispatchEventForPluginEventSystem (react-dom.development.js:5996) at dispatchEvent (react-dom.development.js:6025) at unstable_runWithPriority (scheduler.development.js:643) at runWithPriority$2 (react-dom.development.js:11305) at discreteUpdates$1 (react-dom.development.js:21672) at discreteUpdates (react-dom.development.js:2359) at dispatchDiscreteEvent (react-dom.development.js:5979)

Environment
Expo CLI 3.17.15 environment info: System: OS: Windows 10 10.0.18362 Binaries: Node: 12.16.1 - C:\Program Files\nodejs\node.EXE Yarn: 1.22.4 - C:\Users*****\AppData\Roaming\npm\yarn.CMD npm: 6.13.4 - C:\Program Files\nodejs\npm.CMD npmPackages: expo: ~37.0.3 => 37.0.7 react: ~16.9.0 => 16.9.0 react-native: https://github.com/expo/react-native/archive/sdk-37.0.1.tar.gz => 0.61.4

Could not get unknown property 'getJavaCompileProvider'

Installed using yarn exactly as the instructions say to do so, using a compatible version of react native but get this error everytime:

Could not get unknown property 'getJavaCompileProvider' for object of type com.android.build.gradle.internal.api.LibraryVariantImpl.

package com.github.se_bastiaan.torrentstream does not exist

Please find the complete error log


/Users/ani/Desktop/TorPido/node_modules/react-native-torrent-streamer/android/torrent/src/main/java/com/ghondar/torrentstreamer/TorrentStreamer.java:16: error: package com.github.se_bastiaan.torrentstream does not exist
import com.github.se_bastiaan.torrentstream.StreamStatus;
                                           ^
/Users/ani/Desktop/TorPido/node_modules/react-native-torrent-streamer/android/torrent/src/main/java/com/ghondar/torrentstreamer/TorrentStreamer.java:17: error: package com.github.se_bastiaan.torrentstream does not exist
import com.github.se_bastiaan.torrentstream.Torrent;
                                           ^
/Users/ani/Desktop/TorPido/node_modules/react-native-torrent-streamer/android/torrent/src/main/java/com/ghondar/torrentstreamer/TorrentStreamer.java:18: error: package com.github.se_bastiaan.torrentstream does not exist
import com.github.se_bastiaan.torrentstream.TorrentOptions;
                                           ^
/Users/ani/Desktop/TorPido/node_modules/react-native-torrent-streamer/android/torrent/src/main/java/com/ghondar/torrentstreamer/TorrentStreamer.java:19: error: package com.github.se_bastiaan.torrentstream does not exist
import com.github.se_bastiaan.torrentstream.TorrentStream;
                                           ^
/Users/ani/Desktop/TorPido/node_modules/react-native-torrent-streamer/android/torrent/src/main/java/com/ghondar/torrentstreamer/TorrentStreamer.java:20: error: package com.github.se_bastiaan.torrentstream.listeners does not exist
import com.github.se_bastiaan.torrentstream.listeners.TorrentListener;
                                                     ^
/Users/ani/Desktop/TorPido/node_modules/react-native-torrent-streamer/android/torrent/src/main/java/com/ghondar/torrentstreamer/TorrentStreamer.java:29: error: cannot find symbol
public class TorrentStreamer extends ReactContextBaseJavaModule implements TorrentListener {
                                                                           ^
  symbol: class TorrentListener
/Users/ani/Desktop/TorPido/node_modules/react-native-torrent-streamer/android/torrent/src/main/java/com/ghondar/torrentstreamer/TorrentStreamer.java:31: error: cannot find symbol
    private TorrentStream mTorrentStream;
            ^
  symbol:   class TorrentStream
  location: class TorrentStreamer
/Users/ani/Desktop/TorPido/node_modules/react-native-torrent-streamer/android/torrent/src/main/java/com/ghondar/torrentstreamer/TorrentStreamer.java:77: error: cannot find symbol
    public void onStreamPrepared(Torrent torrent) {
                                 ^
  symbol:   class Torrent
  location: class TorrentStreamer
/Users/ani/Desktop/TorPido/node_modules/react-native-torrent-streamer/android/torrent/src/main/java/com/ghondar/torrentstreamer/TorrentStreamer.java:89: error: cannot find symbol
    public void onStreamStarted(Torrent torrent) {
                                ^
  symbol:   class Torrent
  location: class TorrentStreamer
/Users/ani/Desktop/TorPido/node_modules/react-native-torrent-streamer/android/torrent/src/main/java/com/ghondar/torrentstreamer/TorrentStreamer.java:99: error: cannot find symbol
    public void onStreamError(Torrent torrent, Exception e) {
                              ^
  symbol:   class Torrent
  location: class TorrentStreamer
/Users/ani/Desktop/TorPido/node_modules/react-native-torrent-streamer/android/torrent/src/main/java/com/ghondar/torrentstreamer/TorrentStreamer.java:106: error: cannot find symbol
    public void onStreamReady(Torrent torrent) {
                              ^
  symbol:   class Torrent
  location: class TorrentStreamer
/Users/ani/Desktop/TorPido/node_modules/react-native-torrent-streamer/android/torrent/src/main/java/com/ghondar/torrentstreamer/TorrentStreamer.java:116: error: cannot find symbol
    public void onStreamProgress(Torrent torrent, StreamStatus status) {
                                 ^
  symbol:   class Torrent
  location: class TorrentStreamer
/Users/ani/Desktop/TorPido/node_modules/react-native-torrent-streamer/android/torrent/src/main/java/com/ghondar/torrentstreamer/TorrentStreamer.java:116: error: cannot find symbol
    public void onStreamProgress(Torrent torrent, StreamStatus status) {
                                                  ^
  symbol:   class StreamStatus
  location: class TorrentStreamer
/Users/ani/Desktop/TorPido/node_modules/react-native-torrent-streamer/android/torrent/src/main/java/com/ghondar/torrentstreamer/TorrentStreamer.java:38: error: cannot find symbol
        TorrentOptions torrentOptions = new TorrentOptions.Builder()
        ^
  symbol:   class TorrentOptions
  location: class TorrentStreamer
/Users/ani/Desktop/TorPido/node_modules/react-native-torrent-streamer/android/torrent/src/main/java/com/ghondar/torrentstreamer/TorrentStreamer.java:38: error: package TorrentOptions does not exist
        TorrentOptions torrentOptions = new TorrentOptions.Builder()
                                                          ^
/Users/ani/Desktop/TorPido/node_modules/react-native-torrent-streamer/android/torrent/src/main/java/com/ghondar/torrentstreamer/TorrentStreamer.java:45: error: cannot find symbol
        mTorrentStream = TorrentStream.init(torrentOptions);
                         ^
  symbol:   variable TorrentStream
  location: class TorrentStreamer
/Users/ani/Desktop/TorPido/node_modules/react-native-torrent-streamer/android/torrent/src/main/java/com/ghondar/torrentstreamer/TorrentStreamer.java:76: error: method does not override or implement a method from a supertype
    @Override
    ^
/Users/ani/Desktop/TorPido/node_modules/react-native-torrent-streamer/android/torrent/src/main/java/com/ghondar/torrentstreamer/TorrentStreamer.java:88: error: method does not override or implement a method from a supertype
    @Override
    ^
/Users/ani/Desktop/TorPido/node_modules/react-native-torrent-streamer/android/torrent/src/main/java/com/ghondar/torrentstreamer/TorrentStreamer.java:98: error: method does not override or implement a method from a supertype
    @Override
    ^
/Users/ani/Desktop/TorPido/node_modules/react-native-torrent-streamer/android/torrent/src/main/java/com/ghondar/torrentstreamer/TorrentStreamer.java:105: error: method does not override or implement a method from a supertype
    @Override
    ^
/Users/ani/Desktop/TorPido/node_modules/react-native-torrent-streamer/android/torrent/src/main/java/com/ghondar/torrentstreamer/TorrentStreamer.java:115: error: method does not override or implement a method from a supertype
    @Override
    ^
/Users/ani/Desktop/TorPido/node_modules/react-native-torrent-streamer/android/torrent/src/main/java/com/ghondar/torrentstreamer/TorrentStreamer.java:130: error: method does not override or implement a method from a supertype
    @Override
    ^
22 errors
:react-native-torrent-streamer:compileReleaseJavaWithJavac FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':react-native-torrent-streamer:compileReleaseJavaWithJavac'.
> Compilation failed; see the compiler error output for details.


Android 10 support

Hi,

I discovered that on Android 10, when clicking the start button nothing happens, but when changing the emulator to Android 9 all works fine.

Storage Permission has been granted on both emulators and no errors get logged when testing.

@ghondar Will it be possible to add Android 10+ support?

Can't run the example project.

Trying to run the project but i'm getting following error:

* What went wrong:
A problem occurred configuring project ':react-native-torrent-streamer'.
> Could not get unknown property 'getJavaCompileProvider' for object of type com.android.build.gradle.internal.api.LibraryVariantImpl.

Do you any idea what is the problem ?

improvement To implement

Hi, saw the component and I really liked it.

As if now it has many issue. So since I wanted to use it I hade to improve it a little.

Those are the improvement I did.
1- Support multi torrent download.
2- Support getting files information and more methods to use.
3- upgraded com.github.se_bastiaan.torrentstream to the latest

What more we need.

We need to be able to create a server/client socket to stream the video file instead of using com.github.se_bastiaan.torrentstream which dose clearly not work 100%

Those improment you could find in my fork(https://github.com/AlenToma/react-native-torrent-streamer)

I hope you can use it and implement it on this library.

Here is how you could use it as of now

import TorrentItem from 'react-native-torrent-streamer'
import useState from '@alentoma/usestate'
    const state = useState({
        progress: 0,
        buffer: 0,
        downloadSpeed: 0,
        seeds: 0,
        url: undefined, // "/storage/emulated/0/Download/Antlers (2021) [720p] [WEBRip] [YTS.MX]/Antlers.2021.720p.WEBRip.x264.AAC-[YTS.MX].mp4",
        loading: false,
        torrent: undefined,
        reload: false
    }, false)
  useEffect(() => {
        requestPermissions(); // permission to download folder, this has to be triggered
        var torrent = new TorrentItem("https://yts.mx/torrent/download/E68EE3FC711024F89D37F539A404F3211F326F97");
        state.torrent = torrent;
        torrent.addEventListener('error', (e) => {
            console.log(e)
        }).addEventListener('status', ({ progress, buffer, downloadSpeed, seeds, torrent }) => {
            var item = {
                progress,
                buffer,
                downloadSpeed,
                seeds,
                loading: false
            }
            state.setValue(item)
        }).addEventListener('ready', (data) => {
                // state.reload = true;
                state.url = data.url;
            }).addEventListener('stop', (d) => {
                console.log(d);
                state.loading = false;
            })

        return () => state.torrent?.clearEvents();
    }, [])


// and here is the Torrent class
import { DeviceEventEmitter, NativeModules } from 'react-native';

const { TorrentStreamer } = NativeModules;

const TORRENT_STREAMER_DOWNLOAD_EVENTS = {
  error: 'error',
  progress: 'progress',
  status: 'status',
  ready: 'ready',
  stop: 'stop'
};


export class Torrent {
  constructor(magnetUrl, saveLocation, removeAfterStop) {
    this.magnetUrl = magnetUrl;
    this.saveLocation = saveLocation;
    this.removeAfterStop = removeAfterStop;
    this.files = [];
    this._TorrentStreamerDownloadHandlers = {};
    if (!this.magnetUrl)
      throw "magnetUrl cant be empty";

    if (!this.saveLocation)
      this.saveLocation = null;

    if (!this.removeAfterStop)
      this.removeAfterStop = true;

    this.addEventListener("progress", (params) => {
      if (this.files.length <= 0)
        this.files = params.files;

      this.setSelectedFileIndex(-1);
    });
  }

  setSelectedFileIndex(selectedFileIndex) {
    TorrentStreamer.setSelectedFileIndex(this.magnetUrl, selectedFileIndex);
  }

  addEventListener(type, handler) {
    var ty = TORRENT_STREAMER_DOWNLOAD_EVENTS[type] + this.magnetUrl;
    this._TorrentStreamerDownloadHandlers[handler] = DeviceEventEmitter.addListener(ty, (torrentStreamerData) => {
      var tr = Object.assign({}, this);
      delete tr._TorrentStreamerDownloadHandlers;

      handler(Object.assign(torrentStreamerData, { torrent: tr }))
    });

    return this;
  }

  clearEvents() {
    Object.keys(this._TorrentStreamerDownloadHandlers).forEach(x => {
      var item = this._TorrentStreamerDownloadHandlers[x];
      if (item && item.remove) {
        item.remove();
        delete this._TorrentStreamerDownloadHandlers[x];
      }
    })
  }

  async start() {
    await TorrentStreamer.createTorrent(this.magnetUrl, this.saveLocation, this.removeAfterStop);
    TorrentStreamer.start(this.magnetUrl);
  }

  stop() {
    TorrentStreamer.stop(this.magnetUrl);
  }

  destroy() {
    TorrentStreamer.stop(this.magnetUrl);
  }
}

export default Torrent


You will also have too look at the java files.

Hop those changes may help you improve the library more

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.