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

[Android] Change selected text or audio track not working properly #2973

Closed
facugu1998 opened this issue Dec 27, 2022 · 4 comments
Closed

[Android] Change selected text or audio track not working properly #2973

facugu1998 opened this issue Dec 27, 2022 · 4 comments

Comments

@facugu1998
Copy link
Contributor

Bug

Platform

Which player are you experiencing the problem on:

  • Android

Environment info

React native info output:

System:
    OS: Linux 5.15 Ubuntu 20.04.4 LTS (Focal Fossa)
    CPU: (8) x64 Intel(R) Core(TM) i7-6700HQ CPU @ 2.60GHz
    Memory: 2.96 GB / 15.50 GB
    Shell: 5.8 - /usr/bin/zsh
  Binaries:
    Node: 18.12.1 - /usr/local/bin/node
    Yarn: Not Found
    npm: 8.19.2 - /usr/local/bin/npm
    Watchman: Not Found
  SDKs:
    Android SDK: Not Found
  IDEs:
    Android Studio: Not Found
  Languages:
    Java: Not Found
  npmPackages:
    @react-native-community/cli: Not Found
    react: ^18.1.0 => 18.1.0 
    react-native: ^0.70.5 => 0.70.5 
  npmGlobalPackages:
    *react-native*: Not Found

Library version: 6.0.0-alpha.4

Steps To Reproduce

  1. Store in state audioTracks and textTracks on load. Audio languages are: en, es, pt.
  2. Select on “onLoad” a different audioTrack, for example, pt.
  3. The audio is playing on “pt”.
  4. Change audio to "es".
  5. The audio is playing on "es".
  6. Change back to "pt".
  7. The audio keeps playing on "es".

Expected behaviour

  1. The audio should be "pt".

Possible solution

Modifying function setSelectedTrack on file /android/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java.

Original code block:

DefaultTrackSelector.Parameters selectionParameters = trackSelector.getParameters()
            .buildUpon()
            .setRendererDisabled(rendererIndex, false)\
            .addOverride(selectionOverride)
            .build();

Solution:

DefaultTrackSelector.Parameters selectionParameters = trackSelector.getParameters()
            .buildUpon()
            .setRendererDisabled(rendererIndex, false)
            .clearOverridesOfType(selectionOverride.getType())
            .addOverride(selectionOverride)
            .build();
@rohitninawe
Copy link

rohitninawe commented Dec 28, 2022

+1 same problem.

The above Solution works for me.


DefaultTrackSelector.Parameters selectionParameters = trackSelector.getParameters()
            .buildUpon()
            .setRendererDisabled(rendererIndex, false)
            .clearOverridesOfType(selectionOverride.getType())
            .addOverride(selectionOverride)
            .build();
            

Thank you. @facugu1998

@freeboub
Copy link
Collaborator

freeboub commented Jan 2, 2023

Thank you for the patch, I open the corresponding PR Here: #2979
Can you please validate it ?

@facugu1998
Copy link
Contributor Author

@freeboub It looks ok. Thanks!

@freeboub
Copy link
Collaborator

freeboub commented Jan 2, 2023

will be available in alpha.5

@freeboub freeboub closed this as completed Jan 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants