5

So I am using react-native-video and react-native-track-player parallelly, Normally both are working fine, but to use some extra functionalities of video player like buffering I have to use Exo player , but using exo player manually is making react-native-track player crash well i was trying to get an answer and find that it was happening due to conflict in exo player versions used by both libs. can anyone help

Thanks

Manglesh
  • 51
  • 3

2 Answers2

4

Problem background

Both react-native-track-player and react-native-video are built on top of the Exoplayer (the application level media player for android).

In the current versions of react-native-track-player and the react-native-video the following exoplayer versions are used:

  • react-native-track-player (2.1.3): node_modules\react-native-track-player\android\build.gradle

     dependencies {
         ...   
         def exoPlayerVersion = safeExtGet("exoPlayerVersion", '2.11.4')
         ...
     }
    
  • react-native-video (5.2.0): node_modules\react-native-video\android-exoplayer\build.gradle

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

As you can see both require different versions of the exoplayer which causes the problem (application crash).

Solution

The available solution is to make sure both packages use the same version of exoplayer. We can achieve this by downgrading one of the packages until it matches the exoplayer version of the other. Since current version react-native-track-player uses the older version of exoplayer (2.11.4) we have no option but to downgrade react-native-video down to the version which use exoplayer 2.11.4 which is the version 5.1.1.

Therefore the problem will be solved if you downgrade the react-native-video down to 5.1.1.

npm i react-native-video@5.1.1

Note: This may cause some minor issues in react-native-video. (ex: textTracks property of Video class might not work)

Pawara Siriwardhane
  • 1,873
  • 10
  • 26
  • 38
1

I know the question is a long time ago, but it might help someone, I had the same problem, solved using the 'patch-package'

https://gist.github.com/Fairbrook/53127f8a05c020836a64f6c19b71f889#file-react-native-track-player-2-1-2-patch

to use is simple
1 - npm i patch-package
2 - Create folder in the project root with name 'patches'
3 - Create a file named 'react-native-track-player+2.1.2.patch'
4 - Copy the code from the link and paste it in the file
5 - npm install

This should solve it, solve it for me

  • I visited the link , it is working for others i don't know why this solution is not working for me, May be i am doing something wrong . I am using react-native-video@5.2.0 & react-native-track-player@2.1.3 , everything working fine till i decided to use exoplayer for react native video, I added this dependency in react-native.config.js " 'react-native-video': { platforms: { android: { sourceDir: '../node_modules/react-native-video/android-exoplayer', }, }, }, " after this app is crashing whem i am opening audio player. – Manglesh Jul 28 '22 at 13:50
  • could you help me i am new in development. – Manglesh Jul 28 '22 at 13:51