Skip to content

Commit

Permalink
Merge pull request #88 from learning-layers/bump-exoplayer-versio
Browse files Browse the repository at this point in the history
Bump exoplayer version to 1.3.3
  • Loading branch information
melonmanchan committed Apr 25, 2016
2 parents 44cf127 + 6969f71 commit 0db6bb0
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 14 deletions.
1 change: 1 addition & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ dependencies {
compile 'com.android.support:support-v4:23.2.1'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:recyclerview-v7:23.0.1'
compile 'com.google.android.exoplayer:exoplayer:r1.3.3'

// Material design dialogs
compile('com.github.afollestad.material-dialogs:commons:0.8.5.4@aar') {
Expand Down
Binary file removed app/libs/exoplayer-r1.0.13.jar
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,24 @@
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewParent;
import android.webkit.URLUtil;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import android.widget.ProgressBar;

import com.google.android.exoplayer.ExoPlaybackException;
import com.google.android.exoplayer.ExoPlayer;
import com.google.android.exoplayer.FrameworkSampleSource;
import com.google.android.exoplayer.extractor.Extractor;
import com.google.android.exoplayer.extractor.mp4.Mp4Extractor;
import com.google.android.exoplayer.upstream.DataSource;
import com.google.android.exoplayer.extractor.ExtractorSampleSource;
import com.google.android.exoplayer.MediaCodecAudioTrackRenderer;
import com.google.android.exoplayer.MediaCodecTrackRenderer;
import com.google.android.exoplayer.MediaCodecVideoTrackRenderer;
import com.google.android.exoplayer.SampleSource;
import com.google.android.exoplayer.TrackRenderer;
import com.google.android.exoplayer.upstream.DefaultUriDataSource;
import com.google.android.exoplayer.upstream.FileDataSource;
import com.google.android.exoplayer.util.Util;
import com.nispok.snackbar.Snackbar;
import com.nispok.snackbar.SnackbarManager;
import com.rollbar.android.Rollbar;
Expand Down Expand Up @@ -74,6 +80,9 @@ public final class PlayerFragment extends Fragment implements ExoPlayer.Listener

private LinearLayout subtitleContainer;

private DataSource dataSource;
private Extractor extractor;

private ExoPlayer exoPlayer;
private TrackRenderer videoRenderer;
private AnnotationRenderer annotationRenderer;
Expand Down Expand Up @@ -164,12 +173,19 @@ public void prepare(Video video, AnnotationEditor annotationEditor) {
orientationPatcher.updateOrientation(video);
orientationPatcher.setView(videoSurface);

SampleSource source = new FrameworkSampleSource(
getActivity(),
videoUri,
null,
DOWNSTREAM_RENDERER_COUNT
);
System.out.println(URLUtil.isFileUrl(videoUri.toString()));

// Seems as if the DefaultUriDataSource cannot correctly guess a local file URI, so just do it manually
if (URLUtil.isFileUrl(videoUri.toString()) == true) {
dataSource = new FileDataSource();
} else {
String userAgent = Util.getUserAgent(getActivity(), "ACHSO");
dataSource = new DefaultUriDataSource(getActivity(), userAgent);
}

extractor = new Mp4Extractor();

ExtractorSampleSource source = new ExtractorSampleSource(videoUri, dataSource, extractor, DOWNSTREAM_RENDERER_COUNT, 5 * 1024 * 1024);

// The video renderer runs on another thread: we need to supply a handler on the main
// thread in order to receive events.
Expand Down Expand Up @@ -395,6 +411,11 @@ public void onCryptoError(MediaCodec.CryptoException error) {
Rollbar.reportException(error);
}

@Override
public void onDecoderInitialized(String decoderName, long elapsedRealtimeMs, long initializationDurationMs) {

}

/**
* Invoked when a frame is rendered to a surface for the first time following that surface
* having been set as the target for the renderer.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ public void run() {
* Invoked to make progress when the renderer is in the STATE_UNPREPARED state.
*/
@Override
protected int doPrepare() {
protected int doPrepare(long positionUs) {
// Prepared instantly
return STATE_PREPARED;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,11 @@ public void onCryptoError(CryptoException exception) {
delegate.onCryptoError(exception);
}

@Override
public void onDecoderInitialized(String decoderName, long elapsedRealtimeMs, long initializationDurationMs) {

}

/**
* Rotates the video when the TextureView's layout bounds change.
* Video dimensions are preserved.
Expand All @@ -135,11 +140,6 @@ public void onCryptoError(CryptoException exception) {
public void onLayoutChange(View changedView, int left, int top, int right, int bottom,
int oldLeft, int oldTop, int oldRight, int oldBottom) {

// Not needed on API 21 and up
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.KITKAT_WATCH) {
return;
}

if (rotationDegrees == -1 || view == null || changedView != view) {
return;
}
Expand Down

0 comments on commit 0db6bb0

Please sign in to comment.