Skip to content

Commit

Permalink
Updated ExoPlayer version
Browse files Browse the repository at this point in the history
  • Loading branch information
jhomlala committed Jul 9, 2021
1 parent e895a3c commit 178474e
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 54 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## 0.0.72
* Updated ExoPlayer version

## 0.0.71
* Fixed play after seeking issue on iOS.
* Fixed audio track selection issue on iOS/Android.
Expand Down
12 changes: 6 additions & 6 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ android {
}

dependencies {
implementation 'com.google.android.exoplayer:exoplayer-core:2.13.3'
implementation 'com.google.android.exoplayer:exoplayer-hls:2.13.3'
implementation 'com.google.android.exoplayer:exoplayer-dash:2.13.3'
implementation 'com.google.android.exoplayer:exoplayer-smoothstreaming:2.13.3'
implementation 'com.google.android.exoplayer:exoplayer-ui:2.13.3'
implementation 'com.google.android.exoplayer:extension-mediasession:2.13.3'
implementation 'com.google.android.exoplayer:exoplayer-core:2.14.1'
implementation 'com.google.android.exoplayer:exoplayer-hls:2.14.1'
implementation 'com.google.android.exoplayer:exoplayer-dash:2.14.1'
implementation 'com.google.android.exoplayer:exoplayer-smoothstreaming:2.14.1'
implementation 'com.google.android.exoplayer:exoplayer-ui:2.14.1'
implementation 'com.google.android.exoplayer:extension-mediasession:2.14.1'
implementation "android.arch.lifecycle:runtime:1.1.1"
implementation "android.arch.lifecycle:common:1.1.1"
implementation "android.arch.lifecycle:common-java8:1.1.1"
Expand Down
79 changes: 39 additions & 40 deletions android/src/main/java/com/jhomlala/better_player/BetterPlayer.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@
import com.google.android.exoplayer2.ControlDispatcher;
import com.google.android.exoplayer2.DefaultLoadControl;
import com.google.android.exoplayer2.ExoPlaybackException;
import com.google.android.exoplayer2.ExoPlayer;
import com.google.android.exoplayer2.Format;
import com.google.android.exoplayer2.LoadControl;
import com.google.android.exoplayer2.MediaItem;
import com.google.android.exoplayer2.PlaybackParameters;
import com.google.android.exoplayer2.Player;
import com.google.android.exoplayer2.Player.EventListener;
import com.google.android.exoplayer2.SimpleExoPlayer;
import com.google.android.exoplayer2.Timeline;
import com.google.android.exoplayer2.audio.AudioAttributes;
Expand Down Expand Up @@ -104,7 +104,7 @@ final class BetterPlayer {
private PlayerNotificationManager playerNotificationManager;
private Handler refreshHandler;
private Runnable refreshRunnable;
private EventListener exoPlayerEventListener;
private ExoPlayer.Listener exoPlayerEventListener;
private Bitmap bitmap;
private MediaSessionCompat mediaSession;
private DrmSessionManager drmSessionManager;
Expand Down Expand Up @@ -324,11 +324,10 @@ public Bitmap getCurrentLargeIcon(@NonNull Player player,
}
}


playerNotificationManager = new PlayerNotificationManager(context,
playerNotificationChannelName,
playerNotificationManager = new PlayerNotificationManager.Builder(context,
NOTIFICATION_ID,
mediaDescriptionAdapter);
playerNotificationChannelName,
mediaDescriptionAdapter).build();
playerNotificationManager.setPlayer(exoPlayer);
playerNotificationManager.setUseNextAction(false);
playerNotificationManager.setUsePreviousAction(false);
Expand Down Expand Up @@ -362,7 +361,7 @@ public Bitmap getCurrentLargeIcon(@NonNull Player player,
refreshHandler.postDelayed(refreshRunnable, 0);
}

exoPlayerEventListener = new EventListener() {
exoPlayerEventListener = new Player.Listener() {
@Override
public void onPlaybackStateChanged(int playbackState) {
mediaSession.setMetadata(new MediaMetadataCompat.Builder()
Expand Down Expand Up @@ -455,7 +454,9 @@ public boolean isFastForwardEnabled() {


public void disposeRemoteNotifications() {
exoPlayer.removeListener(exoPlayerEventListener);
if (exoPlayerEventListener != null) {
exoPlayer.removeListener(exoPlayerEventListener);
}
if (refreshHandler != null) {
refreshHandler.removeCallbacksAndMessages(null);
refreshHandler = null;
Expand Down Expand Up @@ -552,39 +553,37 @@ public void onCancel(Object o) {
exoPlayer.setVideoSurface(surface);
setAudioAttributes(exoPlayer, true);

exoPlayer.addListener(
new EventListener() {

@Override
public void onPlaybackStateChanged(int playbackState) {
if (playbackState == Player.STATE_BUFFERING) {
sendBufferingUpdate();
Map<String, Object> event = new HashMap<>();
event.put("event", "bufferingStart");
eventSink.success(event);
} else if (playbackState == Player.STATE_READY) {
if (!isInitialized) {
isInitialized = true;
sendInitialized();
}
exoPlayer.addListener(new Player.Listener() {
@Override
public void onPlaybackStateChanged(int playbackState) {
if (playbackState == Player.STATE_BUFFERING) {
sendBufferingUpdate();
Map<String, Object> event = new HashMap<>();
event.put("event", "bufferingStart");
eventSink.success(event);
} else if (playbackState == Player.STATE_READY) {
if (!isInitialized) {
isInitialized = true;
sendInitialized();
}

Map<String, Object> event = new HashMap<>();
event.put("event", "bufferingEnd");
eventSink.success(event);
Map<String, Object> event = new HashMap<>();
event.put("event", "bufferingEnd");
eventSink.success(event);

} else if (playbackState == Player.STATE_ENDED) {
Map<String, Object> event = new HashMap<>();
event.put("event", "completed");
event.put("key", key);
eventSink.success(event);
}
}
} else if (playbackState == Player.STATE_ENDED) {
Map<String, Object> event = new HashMap<>();
event.put("event", "completed");
event.put("key", key);
eventSink.success(event);
}
}

@Override
public void onPlayerError(final ExoPlaybackException error) {
eventSink.error("VideoError", "Video player had error " + error, null);
}
});
@Override
public void onPlayerError(final ExoPlaybackException error) {
eventSink.error("VideoError", "Video player had error " + error, null);
}
});

Map<String, Object> reply = new HashMap<>();
reply.put("textureId", textureEntry.id());
Expand All @@ -601,7 +600,7 @@ void sendBufferingUpdate() {
}

private void setAudioAttributes(SimpleExoPlayer exoPlayer, Boolean mixWithOthers) {
Player.AudioComponent audioComponent = exoPlayer.getAudioComponent();
ExoPlayer.AudioComponent audioComponent = exoPlayer.getAudioComponent();
if (audioComponent == null) {
return;
}
Expand Down Expand Up @@ -782,7 +781,7 @@ void setAudioTrack(String name, Integer index) {
hasElementWithoutLabel = true;
}

if (format.id.equals("1/15")) {
if (format.id != null && format.id.equals("1/15")) {
hasStrangeAudioTrack = true;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,15 @@ public Result doWork() {
mCacheWriter = new CacheWriter(
cacheDataSourceFactory.createDataSource(),
dataSpec,
true,
null,
(long requestLength, long bytesCached, long newBytesCached) -> {
double completedData = ((bytesCached * 100f) / preCacheSize);
if (completedData >= mLastCacheReportIndex * 10) {
mLastCacheReportIndex += 1;
Log.d(TAG, "Completed pre cache of " + url + ": " + (int) completedData + "%");
double completedData = ((bytesCached * 100f) / preCacheSize);
if (completedData >= mLastCacheReportIndex * 10) {
mLastCacheReportIndex += 1;
Log.d(TAG, "Completed pre cache of " + url + ": " + (int) completedData + "%");
}
}
});
);

mCacheWriter.cache();
} else {
Expand Down
2 changes: 1 addition & 1 deletion docs/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

```yaml
dependencies:
better_player: ^0.0.71
better_player: ^0.0.72
```
2. Install it
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: better_player
description: Advanced video player based on video_player and Chewie. It's solves many typical use cases and it's easy to run.
version: 0.0.71
version: 0.0.72
authors:
- Jakub Homlala <jhomlala@gmail.com>
homepage: https://github.com/jhomlala/betterplayer
Expand Down

0 comments on commit 178474e

Please sign in to comment.