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

bump exoplayer to version 2.13.2 #3116

Merged
merged 1 commit into from
Mar 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion owncloudApp/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ dependencies {
implementation "androidx.annotation:annotation:1.1.0"
implementation 'com.google.android.material:material:1.3.0'
implementation 'com.jakewharton:disklrucache:2.0.2'
implementation 'com.google.android.exoplayer:exoplayer:r2.2.0'
implementation 'com.google.android.exoplayer:exoplayer:2.13.2'
implementation 'com.andrognito.patternlockview:patternlockview:1.0.0'
implementation "androidx.appcompat:appcompat:$appCompat"
implementation 'com.getbase:floatingactionbutton:1.10.1'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
* ownCloud Android client application
*
* @author David González Verdugo
* Copyright (C) 2017 ownCloud GmbH.
* @author Christian Schabesberger
* Copyright (C) 2021 ownCloud GmbH.
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2,
Expand All @@ -21,6 +22,7 @@

import com.google.android.exoplayer2.upstream.DataSource;
import com.google.android.exoplayer2.upstream.DefaultHttpDataSource;
import com.google.android.exoplayer2.upstream.HttpDataSource;
import com.google.android.exoplayer2.upstream.HttpDataSource.BaseFactory;
import com.google.android.exoplayer2.upstream.HttpDataSource.Factory;
import com.google.android.exoplayer2.upstream.TransferListener;
Expand All @@ -33,7 +35,7 @@
public final class CustomHttpDataSourceFactory extends BaseFactory {

private final String userAgent;
private final TransferListener<? super DataSource> listener;
private final TransferListener listener;
private final int connectTimeoutMillis;
private final int readTimeoutMillis;
private final boolean allowCrossProtocolRedirects;
Expand All @@ -52,7 +54,7 @@ public final class CustomHttpDataSourceFactory extends BaseFactory {
* Map<String, String>)
*/
public CustomHttpDataSourceFactory(
String userAgent, TransferListener<? super DataSource> listener, Map<String,
String userAgent, TransferListener listener, Map<String,
String> params) {
this(userAgent, listener, DefaultHttpDataSource.DEFAULT_CONNECT_TIMEOUT_MILLIS,
DefaultHttpDataSource.DEFAULT_READ_TIMEOUT_MILLIS, false, params);
Expand All @@ -70,7 +72,7 @@ public CustomHttpDataSourceFactory(
* to HTTPS and vice versa) are enabled.
*/
public CustomHttpDataSourceFactory(String userAgent,
TransferListener<? super DataSource> listener,
TransferListener listener,
int connectTimeoutMillis, int readTimeoutMillis,
boolean allowCrossProtocolRedirects,
Map<String, String> params) {
Expand All @@ -83,10 +85,14 @@ public CustomHttpDataSourceFactory(String userAgent,
}

@Override
protected DefaultHttpDataSource createDataSourceInternal() {
DefaultHttpDataSource defaultHttpDataSource = new DefaultHttpDataSource(userAgent, null,
listener, connectTimeoutMillis,
readTimeoutMillis, allowCrossProtocolRedirects);
protected HttpDataSource createDataSourceInternal(HttpDataSource.RequestProperties defaultRequestProperties) {
DefaultHttpDataSource defaultHttpDataSource = new DefaultHttpDataSource.Factory()
.setUserAgent(userAgent)
.setTransferListener(listener)
.setConnectTimeoutMs(connectTimeoutMillis)
.setReadTimeoutMs(readTimeoutMillis)
.setAllowCrossProtocolRedirects(allowCrossProtocolRedirects)
.createDataSource();

// Set headers in http data source
for (Map.Entry<String, String> entry : headers.entrySet()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* @author David A. Velasco
* @author David González Verdugo
* @author Christian Schabesberger
* Copyright (C) 2020 ownCloud GmbH.
* Copyright (C) 2021 ownCloud GmbH.
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2,
Expand Down Expand Up @@ -35,15 +35,12 @@
import com.google.android.exoplayer2.ExoPlayer;
import com.google.android.exoplayer2.ExoPlayerFactory;
import com.google.android.exoplayer2.SimpleExoPlayer;
import com.google.android.exoplayer2.Timeline;
import com.google.android.exoplayer2.source.MediaSource;
import com.google.android.exoplayer2.source.TrackGroupArray;
import com.google.android.exoplayer2.trackselection.AdaptiveVideoTrackSelection;
import com.google.android.exoplayer2.trackselection.AdaptiveTrackSelection;
import com.google.android.exoplayer2.trackselection.DefaultTrackSelector;
import com.google.android.exoplayer2.trackselection.TrackSelection;
import com.google.android.exoplayer2.trackselection.TrackSelectionArray;
import com.google.android.exoplayer2.ui.SimpleExoPlayerView;
import com.google.android.exoplayer2.upstream.DefaultBandwidthMeter;
import com.google.android.exoplayer2.ui.PlayerView;
import com.owncloud.android.R;
import com.owncloud.android.ui.activity.FileActivity;
import timber.log.Timber;
Expand All @@ -60,11 +57,10 @@ public class PreviewVideoActivity extends FileActivity implements ExoPlayer.Even
/** Key to receive the position of the playback where the video should be put at start */
public static final String EXTRA_START_POSITION = "START_POSITION";

private final DefaultBandwidthMeter BANDWIDTH_METER = new DefaultBandwidthMeter();

private Handler mainHandler;
private SimpleExoPlayerView simpleExoPlayerView;
private PlayerView exoPlayerView;

private boolean mExoPlayerBooted = false;
private SimpleExoPlayer player;
private DefaultTrackSelector trackSelector;

Expand All @@ -84,7 +80,7 @@ public void onCreate(Bundle savedInstanceState) {

setContentView(R.layout.video_preview);

simpleExoPlayerView = findViewById(R.id.video_player);
exoPlayerView = findViewById(R.id.video_player);

// Hide sync bar
ProgressBar syncProgressBar = findViewById(R.id.syncProgressBar);
Expand Down Expand Up @@ -154,15 +150,12 @@ private void preparePlayer() {

// Create a default TrackSelector
mainHandler = new Handler();
TrackSelection.Factory videoTrackSelectionFactory =
new AdaptiveVideoTrackSelection.Factory(BANDWIDTH_METER);
AdaptiveTrackSelection.Factory videoTrackSelectionFactory =
new AdaptiveTrackSelection.Factory();
trackSelector = new DefaultTrackSelector(videoTrackSelectionFactory);
player = ExoPlayerFactory.newSimpleInstance(this, trackSelector, new DefaultLoadControl());
player.addListener(this);
simpleExoPlayerView.setPlayer(player);
player.seekTo(mPlaybackPosition);
player.setPlayWhenReady(mAutoplay);

exoPlayerView.setPlayer(player);
// Prepare video player asynchronously
new PrepareVideoPlayerAsyncTask(getApplicationContext(), this, getFile(), getAccount(),
mainHandler).execute();
Expand Down Expand Up @@ -229,17 +222,13 @@ public void onLoadingChanged(boolean isLoading) {

@Override
public void onPlayerStateChanged(boolean playWhenReady, int playbackState) {
// Do nothing.
}

@Override
public void onPositionDiscontinuity() {
// Do nothing
}

@Override
public void onTimelineChanged(Timeline timeline, Object manifest) {
// Do nothing
if (playbackState == ExoPlayer.STATE_READY) {
if (player != null && !mExoPlayerBooted) {
mExoPlayerBooted = true;
player.seekTo(mPlaybackPosition);
player.setPlayWhenReady(mAutoplay);
}
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* @author David González Verdugo
* @author Christian Schabesberger
* @author Shashvat Kedia
* Copyright (C) 2020 ownCloud GmbH.
* Copyright (C) 2021 ownCloud GmbH.
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2,
Expand Down Expand Up @@ -42,14 +42,12 @@
import com.google.android.exoplayer2.ExoPlayer;
import com.google.android.exoplayer2.ExoPlayerFactory;
import com.google.android.exoplayer2.SimpleExoPlayer;
import com.google.android.exoplayer2.Timeline;
import com.google.android.exoplayer2.source.MediaSource;
import com.google.android.exoplayer2.source.TrackGroupArray;
import com.google.android.exoplayer2.trackselection.AdaptiveVideoTrackSelection;
import com.google.android.exoplayer2.trackselection.AdaptiveTrackSelection;
import com.google.android.exoplayer2.trackselection.DefaultTrackSelector;
import com.google.android.exoplayer2.trackselection.TrackSelection;
import com.google.android.exoplayer2.trackselection.TrackSelectionArray;
import com.google.android.exoplayer2.ui.SimpleExoPlayerView;
import com.google.android.exoplayer2.ui.PlayerView;
import com.google.android.exoplayer2.upstream.DefaultBandwidthMeter;
import com.owncloud.android.R;
import com.owncloud.android.datamodel.FileDataStorageManager;
Expand Down Expand Up @@ -91,13 +89,14 @@ public class PreviewVideoFragment extends FileFragment implements View.OnClickLi
private TransferProgressController mProgressController;

private Handler mainHandler;
private SimpleExoPlayerView simpleExoPlayerView;
private PlayerView exoPlayerView;

private SimpleExoPlayer player;
private DefaultTrackSelector trackSelector;

private ImageButton fullScreenButton;

private boolean mExoPlayerBooted = false;
private boolean mAutoplay;
private long mPlaybackPosition;

Expand Down Expand Up @@ -169,7 +168,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,
mProgressBar = view.findViewById(R.id.syncProgressBar);
mProgressBar.setVisibility(View.GONE);

simpleExoPlayerView = view.findViewById(R.id.video_player);
exoPlayerView = view.findViewById(R.id.video_player);

fullScreenButton = view.findViewById(R.id.fullscreen_button);

Expand Down Expand Up @@ -235,11 +234,6 @@ public void onResume() {
Timber.v("onResume");

preparePlayer();

if (player != null) {
player.seekTo(mPlaybackPosition);
player.setPlayWhenReady(mAutoplay);
}
}

@Override
Expand Down Expand Up @@ -280,6 +274,7 @@ public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (resultCode == Activity.RESULT_OK) {
mAutoplay = data.getExtras().getBoolean(PreviewVideoActivity.EXTRA_AUTOPLAY);
mPlaybackPosition = data.getExtras().getLong(PreviewVideoActivity.EXTRA_START_POSITION);
mExoPlayerBooted = false;
}
}

Expand Down Expand Up @@ -372,7 +367,7 @@ public boolean onOptionsItemSelected(MenuItem item) {
}
case R.id.action_remove_file: {
RemoveFilesDialogFragment dialog = RemoveFilesDialogFragment.newInstance(getFile());
dialog.show(getFragmentManager(), ConfirmationDialogFragment.FTAG_CONFIRMATION);
dialog.show(getParentFragmentManager(), ConfirmationDialogFragment.FTAG_CONFIRMATION);
return true;
}
case R.id.action_see_details: {
Expand Down Expand Up @@ -417,8 +412,8 @@ private void preparePlayer() {

// Create a default TrackSelector
mainHandler = new Handler();
TrackSelection.Factory videoTrackSelectionFactory =
new AdaptiveVideoTrackSelection.Factory(BANDWIDTH_METER);
AdaptiveTrackSelection.Factory videoTrackSelectionFactory =
new AdaptiveTrackSelection.Factory();
trackSelector = new DefaultTrackSelector(videoTrackSelectionFactory);

// Video streaming is only supported at Jelly Bean or higher Android versions (>= API 16)
Expand All @@ -430,7 +425,7 @@ private void preparePlayer() {
player.addListener(this);

// Bind the player to the view.
simpleExoPlayerView.setPlayer(player);
exoPlayerView.setPlayer(player);

// Prepare video player asynchronously
new PrepareVideoPlayerAsyncTask(getActivity(), this,
Expand Down Expand Up @@ -517,21 +512,17 @@ public void onPlayerStateChanged(boolean playWhenReady, int playbackState) {
// If player is already, show full screen button
if (playbackState == ExoPlayer.STATE_READY) {
fullScreenButton.setVisibility(View.VISIBLE);
if (player != null && !mExoPlayerBooted) {
mExoPlayerBooted = true;
player.seekTo(mPlaybackPosition);
player.setPlayWhenReady(mAutoplay);
}

} else if (playbackState == ExoPlayer.STATE_ENDED) {
fullScreenButton.setVisibility(View.GONE);
}
}

@Override
public void onPositionDiscontinuity() {
// Do nothing
}

@Override
public void onTimelineChanged(Timeline timeline, Object manifest) {
// Do nothing
}

// File extra methods
@Override
public void onFileMetadataChanged(OCFile updatedFile) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
android:includeFontPadding="false"
android:textColor="#FFBEBEBE" />

<SeekBar
<com.google.android.exoplayer2.ui.DefaultTimeBar
android:id="@id/exo_progress"
android:layout_width="0dp"
android:layout_weight="1"
Expand Down
2 changes: 1 addition & 1 deletion owncloudApp/src/main/res/layout/video_preview.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
android:keepScreenOn="true"
android:background="@color/black">

<com.google.android.exoplayer2.ui.SimpleExoPlayerView
<com.google.android.exoplayer2.ui.PlayerView
android:id="@+id/video_player"
android:layout_width="match_parent"
android:layout_height="match_parent"
Expand Down