Created
December 10, 2021 19:22
-
-
Save kanzitelli/53aca11f6a5d701acf49d0de7c482253 to your computer and use it in GitHub Desktop.
Patch file for react-native-track-player to work with exoplayer 2.13.2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/node_modules/react-native-track-player/android/build.gradle b/node_modules/react-native-track-player/android/build.gradle | |
index a241d94..48138f9 100644 | |
--- a/node_modules/react-native-track-player/android/build.gradle | |
+++ b/node_modules/react-native-track-player/android/build.gradle | |
@@ -60,7 +60,7 @@ dependencies { | |
//noinspection GradleDynamicVersion | |
implementation 'com.facebook.react:react-native:+' | |
- def exoPlayerVersion = safeExtGet("exoPlayerVersion", '2.11.4') | |
+ def exoPlayerVersion = safeExtGet("exoPlayerVersion", '2.13.2') | |
// ExoPlayer Core | |
implementation "com.google.android.exoplayer:exoplayer-core:${exoPlayerVersion}" | |
diff --git a/node_modules/react-native-track-player/android/src/main/java/com/guichaguri/trackplayer/service/MusicManager.java b/node_modules/react-native-track-player/android/src/main/java/com/guichaguri/trackplayer/service/MusicManager.java | |
index 61d17bf..c9969b5 100644 | |
--- a/node_modules/react-native-track-player/android/src/main/java/com/guichaguri/trackplayer/service/MusicManager.java | |
+++ b/node_modules/react-native-track-player/android/src/main/java/com/guichaguri/trackplayer/service/MusicManager.java | |
@@ -132,8 +132,8 @@ public class MusicManager implements OnAudioFocusChangeListener { | |
.setLoadControl(control) | |
.build(); | |
- player.setAudioAttributes(new com.google.android.exoplayer2.audio.AudioAttributes.Builder() | |
- .setContentType(C.CONTENT_TYPE_MUSIC).setUsage(C.USAGE_MEDIA).build()); | |
+ player.getAudioComponent().setAudioAttributes(new com.google.android.exoplayer2.audio.AudioAttributes.Builder() | |
+ .setContentType(C.CONTENT_TYPE_MUSIC).setUsage((C.USAGE_MEDIA)).build(), false); | |
return new LocalPlayback(service, this, player, cacheMaxSize, autoUpdateMetadata); | |
} | |
diff --git a/node_modules/react-native-track-player/android/src/main/java/com/guichaguri/trackplayer/service/player/ExoPlayback.java b/node_modules/react-native-track-player/android/src/main/java/com/guichaguri/trackplayer/service/player/ExoPlayback.java | |
index 37a6fbf..8e2d866 100644 | |
--- a/node_modules/react-native-track-player/android/src/main/java/com/guichaguri/trackplayer/service/player/ExoPlayback.java | |
+++ b/node_modules/react-native-track-player/android/src/main/java/com/guichaguri/trackplayer/service/player/ExoPlayback.java | |
@@ -8,7 +8,7 @@ import com.facebook.react.bridge.Promise; | |
import com.google.android.exoplayer2.*; | |
import com.google.android.exoplayer2.Player.EventListener; | |
import com.google.android.exoplayer2.Timeline.Window; | |
-import com.google.android.exoplayer2.extractor.mp4.MdtaMetadataEntry; | |
+import com.google.android.exoplayer2.metadata.mp4.MdtaMetadataEntry; | |
import com.google.android.exoplayer2.metadata.Metadata; | |
import com.google.android.exoplayer2.metadata.MetadataOutput; | |
import com.google.android.exoplayer2.metadata.flac.VorbisComment; | |
@@ -247,7 +247,7 @@ public abstract class ExoPlayback<T extends Player> implements EventListener, Me | |
public void onTimelineChanged(@NonNull Timeline timeline, int reason) { | |
Log.d(Utils.LOG, "onTimelineChanged: " + reason); | |
- if((reason == Player.TIMELINE_CHANGE_REASON_PREPARED || reason == Player.TIMELINE_CHANGE_REASON_DYNAMIC) && !timeline.isEmpty()) { | |
+ if((reason == Player.TIMELINE_CHANGE_REASON_PLAYLIST_CHANGED || reason == Player.TIMELINE_CHANGE_REASON_SOURCE_UPDATE) && !timeline.isEmpty()) { | |
onPositionDiscontinuity(Player.DISCONTINUITY_REASON_INTERNAL); | |
} | |
} | |
diff --git a/node_modules/react-native-track-player/android/src/main/java/com/guichaguri/trackplayer/service/player/SourceMetadata.java b/node_modules/react-native-track-player/android/src/main/java/com/guichaguri/trackplayer/service/player/SourceMetadata.java | |
index 069cbbd..725feb9 100644 | |
--- a/node_modules/react-native-track-player/android/src/main/java/com/guichaguri/trackplayer/service/player/SourceMetadata.java | |
+++ b/node_modules/react-native-track-player/android/src/main/java/com/guichaguri/trackplayer/service/player/SourceMetadata.java | |
@@ -1,6 +1,6 @@ | |
package com.guichaguri.trackplayer.service.player; | |
-import com.google.android.exoplayer2.extractor.mp4.MdtaMetadataEntry; | |
+import com.google.android.exoplayer2.metadata.mp4.MdtaMetadataEntry; | |
import com.google.android.exoplayer2.metadata.Metadata; | |
import com.google.android.exoplayer2.metadata.flac.VorbisComment; | |
import com.google.android.exoplayer2.metadata.icy.IcyHeaders; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment