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

In android ExoPlayer Audio only play crashes #1460

Closed
sridhard opened this issue Jan 30, 2019 · 9 comments
Closed

In android ExoPlayer Audio only play crashes #1460

sridhard opened this issue Jan 30, 2019 · 9 comments

Comments

@sridhard
Copy link
Contributor

Current behavior

When playing audio only file, exoplayer is crashing with the below stack:
01-30 20:03:49.283 10563 11830 E ExoPlayerImplInternal: Internal runtime error.
01-30 20:03:49.283 10563 11830 E ExoPlayerImplInternal: java.lang.ArrayIndexOutOfBoundsException: length=0; index=-1
01-30 20:03:49.283 10563 11830 E ExoPlayerImplInternal: at com.google.android.exoplayer2.source.TrackGroupArray.get(TrackGroupArray.java:65)
01-30 20:03:49.283 10563 11830 E ExoPlayerImplInternal: at com.google.android.exoplayer2.trackselection.DefaultTrackSelector.selectTracks(DefaultTrackSelector.java:1264)
01-30 20:03:49.283 10563 11830 E ExoPlayerImplInternal: at com.google.android.exoplayer2.trackselection.MappingTrackSelector.selectTracks(MappingTrackSelector.java:394)
01-30 20:03:49.283 10563 11830 E ExoPlayerImplInternal: at com.google.android.exoplayer2.MediaPeriodHolder.selectTracks(MediaPeriodHolder.java:160)
01-30 20:03:49.283 10563 11830 E ExoPlayerImplInternal: at com.google.android.exoplayer2.ExoPlayerImplInternal.reselectTracksInternal(ExoPlayerImplInternal.java:1001)
01-30 20:03:49.283 10563 11830 E ExoPlayerImplInternal: at com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:327)
01-30 20:03:49.283 10563 11830 E ExoPlayerImplInternal: at android.os.Handler.dispatchMessage(Handler.java:98)
01-30 20:03:49.283 10563 11830 E ExoPlayerImplInternal: at android.os.Looper.loop(Looper.java:163)
01-30 20:03:49.283 10563 11830 E ExoPlayerImplInternal: at android.os.HandlerThread.run(HandlerThread.java:61)
01-30 20:03:49.284 10563 10563 D ReactExoplayerView: onStateChanged: playWhenReady=true, playbackState=ready

Reproduction steps

Play any audio file

Expected behavior

play should be success

Platform

Which player are you experiencing the problem on:

  • Android ExoPlayer
@sridhard
Copy link
Contributor Author

@cobarx I have fixed this issue in PR #1448. Please check and merge

sridhard added a commit to sridhard/react-native-video that referenced this issue Jan 30, 2019
@onitzschke
Copy link

For me with this fix it is working again. Looks #1442 is the same issue.

@wojo1206
Copy link

wojo1206 commented Feb 7, 2019

@sridhard Thanks for the PR. Fixes the problem in my case. I applied the changes and my audio plays normally.

@cobarx cobarx closed this as completed in 938cfd6 Feb 11, 2019
@Chalchi52
Copy link

this problem exist in react-native-video 4.4.0 version, when this fix would be released?

@cobarx
Copy link
Contributor

cobarx commented Feb 20, 2019

@Chalchi52 It sounds like there are multiple issues and while the PR fixed some of them, doesn't address the problem you are having. Can you share the props & source you are having problems with.

@Chalchi52
Copy link

Chalchi52 commented Feb 20, 2019

Hi @cobarx I share the following information that I get when updating the version

Versions in package.json:
"react": "16.6.3",
"react-native": "0.58.5",
"react-native-video": "4.4.0",

I need update my project to gradle 3 version, but change to react-native-video of 3.2.1 to 4.4.0 not works in android devices for API 23 or upper

into build.gradle test with:

 implementation('com.google.android.exoplayer:exoplayer:2.9.3') {
        exclude group: 'com.android.support'
    }

and

 implementation('com.google.android.exoplayer:exoplayer:2.9.5') {
        exclude group: 'com.android.support'
    }

My definition of component is:

            <Video
                  ref={(ref) => {
                       this.player = ref;
                   }}
                   source={{ uri: 'https://ccrma.stanford.edu/~jos/mp3/bachfugue.mp3' }}
                   onEnd={this.handleEndOfThePlay}
                   onError={this.handleVideoError}
                   onProgress={this.handleProgress}
                   audioOnly
                   paused={this.state.paused}
                   repeat={this.state.repeat}
               />

Put an static url but no works. I also put this property useTextureView={false} to the component but it did not work either
The audio file is aac format,

into logcat say the following:

E/ExoPlayerImplInternal: Internal runtime error.
java.lang.ArrayIndexOutOfBoundsException: length=0; index=-1
at com.google.android.exoplayer2.source.TrackGroupArray.get(TrackGroupArray.java:65)
at com.google.android.exoplayer2.trackselection.DefaultTrackSelector.selectTracks(DefaultTrackSelector.java:1264)
at com.google.android.exoplayer2.trackselection.MappingTrackSelector.selectTracks(MappingTrackSelector.java:394)
at com.google.android.exoplayer2.MediaPeriodHolder.selectTracks(MediaPeriodHolder.java:160)
at com.google.android.exoplayer2.ExoPlayerImplInternal.reselectTracksInternal(ExoPlayerImplInternal.java:1001)
at com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:327)
at android.os.Handler.dispatchMessage(Handler.java:98)
at android.os.Looper.loop(Looper.java:148)
at android.os.HandlerThread.run(HandlerThread.java:61)

@Chalchi52
Copy link

Chalchi52 commented Feb 21, 2019

Hi @cobarx Force the version 3.2.1 to work with 3 gradle version with the following build.gradle:

apply plugin: 'com.android.library'

def safeExtGet(prop, fallback) {
    rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
}

android {
    compileSdkVersion safeExtGet('compileSdkVersion', 27)
    buildToolsVersion safeExtGet('buildToolsVersion', '27.0.3')

    defaultConfig {
        minSdkVersion safeExtGet('minSdkVersion', 16)
        targetSdkVersion safeExtGet('targetSdkVersion', 27)
        versionCode 1
        versionName "1.0"
    }
}

dependencies {
    //noinspection GradleDynamicVersion
    compileOnly "com.facebook.react:react-native:${safeExtGet('reactNativeVersion', '+')}"
    implementation('com.google.android.exoplayer:exoplayer:2.7.3') {
        exclude group: 'com.android.support'
    }
    // All support libs must use the same version
    implementation "com.android.support:support-annotations:${safeExtGet('supportLibVersion', '+')}"
    implementation "com.android.support:support-compat:${safeExtGet('supportLibVersion', '+')}"
    implementation "com.android.support:support-media-compat:${safeExtGet('supportLibVersion', '+')}"

    implementation('com.google.android.exoplayer:extension-okhttp:2.7.3') {
        exclude group: 'com.squareup.okhttp3', module: 'okhttp'
    }
    implementation 'com.squareup.okhttp3:okhttp:3.12.1'
}

Because the last version 4.4.0 no works for me with any exoplayer version for the bug that I mentioned earlier

AnteWall pushed a commit to sfstudios/react-native-video that referenced this issue Mar 1, 2019
@matamicen
Copy link

Hi @cobarx , We are having the same error as @Chalchi52 and we need to upgrade to gradle plugin 3.3.2 ... and it was working on react-native-video 3.2.1 with gradle plugin 3.1.4 and gradle-4.4

not working project:
"react": "16.6.0-alpha.8af6728",
"react-native": "0.57.4",
"react-native-video": "^4.4.0"
Gradle plugin: build:gradle:3.3.2
Gradle Version: gradle-4.10.2

Thanks for your support! :)

@matamicen
Copy link

@cobarx, to be more specific, only appear that crash when play the audio.
@Chalchi52

thanks again :)

djay05554 added a commit to djay05554/react-native-video that referenced this issue Dec 23, 2019
jake4376 added a commit to jake4376/react-native-video that referenced this issue Jan 18, 2020
rosslavni pushed a commit to rosslavni/react-native-video that referenced this issue Aug 11, 2022
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

No branches or pull requests

6 participants