Skip to content

Commit

Permalink
bump exoplayer to version 2.13.2
Browse files Browse the repository at this point in the history
  • Loading branch information
theScrabi committed Feb 26, 2021
1 parent f2f5961 commit 4cfb68a
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 55 deletions.
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,10 +57,8 @@ 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 SimpleExoPlayer player;
private DefaultTrackSelector trackSelector;
Expand All @@ -84,7 +79,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,12 +149,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);
exoPlayerView.setPlayer(player);
player.seekTo(mPlaybackPosition);
player.setPlayWhenReady(mAutoplay);

Expand Down Expand Up @@ -232,16 +227,6 @@ 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
}

@Override
public void onTracksChanged(TrackGroupArray trackGroups, TrackSelectionArray trackSelections) {
// Do nothing
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,7 +89,7 @@ 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;
Expand Down Expand Up @@ -169,7 +167,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 @@ -378,7 +376,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 @@ -423,8 +421,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 @@ -436,7 +434,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 @@ -528,16 +526,6 @@ public void onPlayerStateChanged(boolean playWhenReady, int playbackState) {
}
}

@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

0 comments on commit 4cfb68a

Please sign in to comment.