Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ExoPlayer #426

Merged
merged 2 commits into from
Jan 11, 2017
Merged

ExoPlayer #426

merged 2 commits into from
Jan 11, 2017

Conversation

AndrewJack
Copy link
Contributor

@AndrewJack AndrewJack commented Dec 23, 2016

Implementation of react-native-video using Google's ExoPlayer library

View the ExoPlayer README to see the new props and the props that still need to be implemented.

This also adds a buffering callback to iOS and ExoPlayer Android.

Long term I am hoping we can move to ExoPlayer as the default, if not sooner.

p.s. if you need any help maintaining this project I'd be happy to help out on the Android side.

@AndrewJack
Copy link
Contributor Author

cc @mattapperson

@corbt - The ExoPlayer PR you were asking for

compile "com.android.support:appcompat-v7:23.0.1"
compile "com.facebook.react:react-native:+" // From node_modules
compile project(':react-native-video')
// compile project(':react-native-video-exoplayer') // uncomment to use exoplayer
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment out react-native-video and uncomment react-native-video-exoplayer to test

/* For ExoPlayer */
/* source={require('./broadchurch.mp4')} */
/* source={{ uri: 'http://www.youtube.com/api/manifest/dash/id/bf5bb2419360daf1/source/youtube?as=fmp4_audio_clear,fmp4_sd_hd_clear&sparams=ip,ipbits,expire,source,id,as&ip=0.0.0.0&ipbits=0&expire=19000000000&signature=51AF5F39AB0CEC3E5497CD9C900EBFEAECCCB5C7.8506521BFC350652163895D4C26DEE124209AA9E&key=ik0', type: 'mpd' }} */
source={{ uri: 'broadchurch', type: 'mp4' }}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change video sources to test dash

@mattapperson mattapperson merged commit 9a936c9 into TheWidlarzGroup:master Jan 11, 2017
@mattapperson
Copy link
Contributor

@AndrewJack THANK YOU FOR THIS

@corbt
Copy link
Contributor

corbt commented Jan 11, 2017 via email

@jaggerwang
Copy link

@AndrewJack Does it the default player on Android, or need to specify explicitly?

@AndrewJack
Copy link
Contributor Author

@jaggerwang

You'll need to compile the react-native-video-exoplayer project instead of the react-native-video then it should work.

Change in app/build.gradle:

- compile project(':react-native-video')
+ compile project(':react-native-video-exoplayer')

Change in settings.gradle:

+ include ':app',
-        ':react-native-video',
+        ':react-native-video-exoplayer'

- project(':react-native-video').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-video/android')
+ project(':react-native-video-exoplayer').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-video/android-exoplayer')

@jaggerwang
Copy link

jaggerwang commented Jan 16, 2017

@AndrewJack Thanks! It's much better performance than the old one. But when playing, change the video source url(different rate) has no effect. Does the api compatible with the old?

@AndrewJack
Copy link
Contributor Author

@jaggerwang
Copy link

@AndrewJack , I'm not mean to let the player to switch video stream rate automatically. For every video in my app, there are low, middle and high quality urls. When user select a different quality, app will pass the new url to player, but player is still playing the old one. Does it need to recreate the player?

@AndrewJack
Copy link
Contributor Author

Oh ok, I'll test switching sources, that should work.

I'm guessing you aren't using an adaptive stream (SS, HLS, or DASH)? which would switch bitrate automatically.

@jaggerwang
Copy link

Yes, not adaptive.

@jaggerwang
Copy link

jaggerwang commented Jan 17, 2017

@AndrewJack , sometimes the video did not auto play when first open player, already set paused to false. But when change paused to true and change it back again, the video will play.

It seems like it's related to the loading time of the online video. If the loading time is very short, about less than 1s, the video will auto play.

@note89
Copy link

note89 commented Feb 6, 2017

Works much better except it seems muted={true} does not seem to work.
it works if you flip it
muted={this.state.muted}
true -> false -> true
but not when the video starts.

on Android
A working hack is

        InteractionManager.runAfterInteractions(() => {
            _.delay(() => {
                this.setState({muted: this.props.muted});
            }, 1);
        });

@note89
Copy link

note89 commented Feb 6, 2017

Another issue seems to be if i run the player in a modal video gets very dark for some reason.

@AndrewJack AndrewJack deleted the exoplayer branch February 21, 2017 16:51
@davidstefando
Copy link

@AndrewJack I try to change video source state, but the player doesn't keep playing the old source unless I force to re render it. Am I miss something?

<Video
       style={styles.video}
       source={{"uri" : this.state.videoSource}}
       paused={false}
       muted={false}
               />

After trying to change videoSource state, video won't change. I Use HLS .m3u8 as video source.

I run react-native-video 1.0.0 & react-native v0.42

@AndrewJack
Copy link
Contributor Author

@davidpratama that's fixed in this PR #502

@dgurns
Copy link

dgurns commented Apr 2, 2017

Thanks AndrewJack, the exoplayer variant is working well for me with live HLS streams on Android.

@manjeets12
Copy link

will I be able to play RTSP videos on android using this solution?

@AndrewJack
Copy link
Contributor Author

@manjeets12 looks like exoplayer doesn't support it google/ExoPlayer#55

@manuTro
Copy link

manuTro commented Jul 7, 2017

compiling the react-native-video-exoplayer project instead of the react-native-video now I have authentication problems with .ts files and in my log
com.google.android.exoplayer2.upstream.HttpDataSource$InvalidResponseCodeException: Response code: 401. and I cannot see the cookies. Without exoplayer I was able to stream the video. Is there a way to fix it? Is it a problem of .ts files?

@johndanek
Copy link

When I try converting react-native-video to react-native-video-exoplayer as detailed above (#426 (comment)) I now receive the following error when I try to run react-native run-android

:app:transformClassesWithDexForDebug FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:transformClassesWithDexForDebug'.
> com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.dex.DexException: Multiple dex files define Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat$AccessibilityServiceInfoVersionImpl;

Any idea how to prevent this error?

@manuTro
Copy link

manuTro commented Jul 11, 2017

@johndanek Did you put the strings into settings.grandle in the same order as described above?

@johndanek
Copy link

@manuTro I'm not sure of the order you're referring to. My settings.gradle looks like:

rootProject.name = 'Foo'

include ':app'

include ':react-native-video-exoplayer'
project(':react-native-video-exoplayer').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-video/android-exoplayer')
include ':react-native-vector-icons'
project(':react-native-vector-icons').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-vector-icons/android')
include ':react-native-orientation'
project(':react-native-orientation').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-orientation/android')

@johndanek
Copy link

@manuTro If you create a new blank react-native project and attempt to integrate the exoplayer, can you get it to work? I cannot.

@manuTro
Copy link

manuTro commented Jul 12, 2017

@johndanek are you sure you linked it properly? is it working without exoplayer?

@johndanek
Copy link

@manuTro Yep, it works (though it's a bit slow) when using it without exoplayer.

@iamronsuez
Copy link

Hi there i'm having this issue #697 when I try to integrate exoplayer, i modified the conf as you guys told but it seems that i'm missing something yet.

@seppemarotta
Copy link

I've made the integration so far, however callbacks are not triggering. The only callback that it's triggering its the onProgress , onLoadStart / onError are not working. When there are connection issues in streamer's or user's end , onError callback it's not working .

@viperfx
Copy link

viperfx commented Sep 13, 2017

I get a similar error to @johndanek after following @AndrewJack instructions

here is the stack trace

:app:compileDebugJavaWithJavac
:app:compileDebugJavaWithJavac - is not incremental (e.g. outputs have changed, no previous execution, etc.).
:app:compileDebugNdk UP-TO-DATE
:app:compileDebugSources
:app:transformClassesWithDexForDebug
Running dex in-process requires build tools 23.0.2.
For faster builds update this project to use the latest build tools.
Dex: Error converting bytecode to dex:
Cause: com.android.dex.DexException: Multiple dex files define Landroid/support/v4/app/NavUtilsJB;
    UNEXPECTED TOP-LEVEL EXCEPTION:
    com.android.dex.DexException: Multiple dex files define Landroid/support/v4/app/NavUtilsJB;
        at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:596)
        at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:554)
        at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:535)
        at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:171)
        at com.android.dx.merge.DexMerger.merge(DexMerger.java:189)
        at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:502)
        at com.android.dx.command.dexer.Main.runMonoDex(Main.java:334)
        at com.android.dx.command.dexer.Main.run(Main.java:277)
        at com.android.dx.command.dexer.Main.main(Main.java:245)
        at com.android.dx.command.Main.main(Main.java:106)

:app:transformClassesWithDexForDebug FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:transformClassesWithDexForDebug'.
> com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: java.lang.UnsupportedOperationException

@AndrewJack
Copy link
Contributor Author

AndrewJack commented Sep 13, 2017

@viperfx see iamronsuez/rn-video#1

Update your compileSdk, buildTools and support library to the same version that exoplayer uses.

@viperfx
Copy link

viperfx commented Sep 14, 2017

Thanks. Its working now.

@coniel
Copy link

coniel commented Sep 18, 2017

@johndanek did you find a solution? I'm having the same issue.

@johndanek
Copy link

@coniel I ended up giving up because of other problems down the line, but I think specifying compile 'com.android.support:appcompat-v7:25.3.1' in build.gradle and making sure all of my projects and libraries were on compileSdkVersion 25. I believe this got me past that error.

@Komeyl94
Copy link

@johndanek I had the same problem that I fixed by adding the following line:

org.gradle.jvmargs=-Xmx1536M

to the gradle.properties file

@Yessengerey
Copy link

Yessengerey commented Mar 2, 2018

I am very new to React Native, and especially new to Android development.

I had the same problem as @johndanek after following @AndrewJack instructions. I believe I also updated my compileSDK and buildtools to the appropriate versions. I've also changed the targetSdkVersion to 23.

The build succeeds, however, the second I open the component that has react-native-video inside it, the application crashes, closes and gives out a warning message saying that unfortunately, my app has stopped working.

And this is what I get in the log:

03-02 04:44:59.566 5809-5837/com.holanews I/ReactNativeJS: {}, 'DATA STARTED TO LOAD!!!'
03-02 04:44:59.700 5809-5857/com.holanews W/VideoCapabilities: Unrecognized profile/level 0/0 for video/mpeg2
03-02 04:44:59.700 5809-5857/com.holanews W/VideoCapabilities: Unrecognized profile/level 0/2 for video/mpeg2
03-02 04:44:59.700 5809-5857/com.holanews W/VideoCapabilities: Unrecognized profile/level 0/3 for video/mpeg2
03-02 04:44:59.706 5809-5857/com.holanews I/VideoCapabilities: Unsupported profile 4 for video/mp4v-es
03-02 04:44:59.716 5809-5862/com.holanews I/OMXClient: Using client-side OMX mux.
03-02 04:44:59.729 5809-5862/com.holanews D/SoftAVCDec: Number of CPU cores: 2
03-02 04:44:59.733 5809-5861/com.holanews I/MediaCodec: [OMX.google.h264.decoder] setting surface generation to 5948417
03-02 04:44:59.734 5809-5833/com.holanews D/EGL_emulation: eglMakeCurrent: 0xeb6f1820: ver 3 0 (tinfo 0xf0bcdbb0)
03-02 04:44:59.738 5809-5862/com.holanews W/OMXNodeInstance: [1:google.h264.decoder] component does not support metadata mode; using fallback
03-02 04:44:59.738 5809-5862/com.holanews E/ACodec: [OMX.google.h264.decoder] storeMetaDataInBuffers failed w/ err -1010
03-02 04:44:59.740 5809-5862/com.holanews D/SoftAVCDec: Number of CPU cores: 2
03-02 04:44:59.755 5809-5863/com.holanews D/SoftAVCDec: Number of CPU cores: 2
03-02 04:44:59.791 5809-5866/com.holanews I/OMXClient: Using client-side OMX mux.
03-02 04:44:59.834 5809-5868/com.holanews I/SoftAAC2: limiting to stereo output
03-02 04:44:59.835 5809-5868/com.holanews I/SoftAAC2: Reconfiguring decoder: 0->48000 Hz, 0->2 channels
03-02 04:45:00.120 5809-5861/com.holanews A/libc: Fatal signal 11 (SIGSEGV), code 2, fault addr 0xd369b000 in tid 5861 (MediaCodec_loop)

This is what I have in my build.gradle:

compileSdkVersion 25
    buildToolsVersion "25.0.3"

    defaultConfig {
        applicationId "com.holanews"
        minSdkVersion 16
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
        ndk {
            abiFilters "armeabi-v7a", "x86"
        }
    }
*
*
// some other stuff
*
*
dependencies {
    compile project(':react-native-video-exoplayer')
    compile project(':react-native-vector-icons')
    compile fileTree(dir: "libs", include: ["*.jar"])
    compile "com.facebook.react:react-native:+"  // From node_modules
    compile "com.android.support:appcompat-v7:25.3.1"
}

And this is what I have in my settings.gradle:

rootProject.name = 'HolaNews'
include ':react-native-video-exoplayer'
project(':react-native-video-exoplayer').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-video/android-exoplayer')
include ':react-native-vector-icons'
project(':react-native-vector-icons').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-vector-icons/android')

include ':app'

I have also tried @Komeyl94 suggestion, but it did not solve anything.
Please point me to what am I doing wrong?

@pawelbrzezinski
Copy link

same as above

@acollazomayer
Copy link

@AndrewJack hi andrew, i follow all your steps. However i dont know if the exoplayer is working or not. I have a dash stream and the application is still throwing the onError event.

@ramu534
Copy link

ramu534 commented Jan 7, 2019

Hi,
I am trying to build cross-platform app that should work IOS, Android and Web too. Is react-native-video work on web platform? Any alias configuration for react-native-web ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.