Skip to content

Commit

Permalink
Merge pull request #7 from hariharsubramanyam/master
Browse files Browse the repository at this point in the history
Fixed bug where video does not resume after putting app into background ...
  • Loading branch information
hariharsubramanyam committed Jul 28, 2014
2 parents 46fe7e6 + 33f7f6d commit dc376b3
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ public void onManifest(String contentId, MediaPresentationDescription manifest)

// Build the video data source.
DataSource videoDataSource = new HttpDataSource(userAgent,
HttpDataSource.REJECT_PAYWALL_TYPES,
null,
bandwidthMeter);
ChunkSource videoChunkSource;
String mimeType = videoRepresentations[0].format.mimeType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,15 @@ public interface TextListener {
*/
public static final int TYPE_DEBUG = 3;

/**
* These variables must be ints (instead of enums) because their values have significance in the
* ExoPlayer libary.
*/
private static final int RENDERER_BUILDING_STATE_IDLE = 1;
private static final int RENDERER_BUILDING_STATE_BUILDING = 2;
private static final int RENDERER_BUILDING_STATE_BUILT = 3;
public static final int DISABLED_TRACK = -1;
public static final int PRIMARY_TRACK = 0;

private final RendererBuilder rendererBuilder;
private final ExoPlayer player;
Expand Down Expand Up @@ -239,7 +245,7 @@ public interface TextListener {
/**
* The state of a track at a given index (one of the TYPE_* constants).
*/
private TrackState[] trackStateForType;
private int[] trackStateForType;

/**
* Respond to text (i.e. subtitle or closed captioning) events.
Expand All @@ -257,9 +263,9 @@ public ExoplayerWrapper(RendererBuilder rendererBuilder) {
playbackListeners = new CopyOnWriteArrayList<PlaybackListener>();
lastReportedPlaybackState = ExoPlayer.STATE_IDLE;
rendererBuildingState = RENDERER_BUILDING_STATE_IDLE;
trackStateForType = new TrackState[RENDERER_COUNT];
trackStateForType = new int[RENDERER_COUNT];
// Disable text initially.
trackStateForType[TYPE_TEXT] = TrackState.DISABLED;
trackStateForType[TYPE_TEXT] = DISABLED_TRACK;
}

public ObservablePlayerControl getPlayerControl() {
Expand Down Expand Up @@ -326,11 +332,11 @@ public String[] getTracks(int type) {
return trackNames == null ? null : trackNames[type];
}

public TrackState getStateForTrackType(int type) {
public int getStateForTrackType(int type) {
return trackStateForType[type];
}

public void selectTrack(int type, TrackState state) {
public void selectTrack(int type, int state) {
if (trackStateForType[type] == state) {
return;
}
Expand Down Expand Up @@ -644,8 +650,8 @@ private void pushTrackSelection(int type, boolean allowRendererEnable) {
return;
}

TrackState trackState = trackStateForType[type];
if (trackState == TrackState.DISABLED) {
int trackState = trackStateForType[type];
if (trackState == DISABLED_TRACK) {
player.setRendererEnabled(type, false);
} else if (multiTrackSources[type] == null) {
player.setRendererEnabled(type, allowRendererEnable);
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@

import com.google.android.libraries.mediaframework.R;
import com.google.android.libraries.mediaframework.exoplayerextensions.ExoplayerWrapper;
import com.google.android.libraries.mediaframework.exoplayerextensions.TrackState;

/**
* Creates a view which can render video.
Expand Down Expand Up @@ -67,7 +66,7 @@ public void surfaceCreated(SurfaceHolder surfaceHolder) {
wrapper.setSurface(surfaceHolder.getSurface());
if (wrapper.getSurface().isValid() ||
wrapper.getStateForTrackType(ExoplayerWrapper.TYPE_VIDEO)
== TrackState.DISABLED) {
== ExoplayerWrapper.DISABLED_TRACK) {
wrapper.setPlayWhenReady(autoplay);
}
}
Expand Down

0 comments on commit dc376b3

Please sign in to comment.