Skip to content

Commit

Permalink
Merge branch '9_0_X' into TIMOB-26678_90X
Browse files Browse the repository at this point in the history
  • Loading branch information
ssjsamir committed Mar 25, 2020
2 parents 1f8fcdb + 5a5c0f5 commit c3ad085
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
16 changes: 12 additions & 4 deletions android/modules/media/src/java/android/widget/TiVideoView8.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
package android.widget;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

import org.appcelerator.kroll.common.Log;
Expand Down Expand Up @@ -368,13 +369,14 @@ public void stopPlayback()
}
}

// TITANIUM Added to detect HTTP redirects before we hand off to MediaPlayer
// See: http://code.google.com/p/android/issues/detail?id=10810
private void setDataSource()
{
try {
mUri = TiUIHelper.getRedirectUri(mUri);
mMediaPlayer.setDataSource(TiApplication.getAppRootOrCurrentActivity(), mUri);
// TIMOB-27493: disable caching, which would otherwise introduce a delay.
Map<String, String> headers = new HashMap<>();
headers.put("Cache-Control", "no-cache");

mMediaPlayer.setDataSource(TiApplication.getAppRootOrCurrentActivity(), mUri, headers);
} catch (Exception e) {
Log.e(TAG, "Error setting video data source: " + e.getMessage(), e);
}
Expand Down Expand Up @@ -568,6 +570,9 @@ public void onCompletion(MediaPlayer mp)
if (mOnCompletionListener != null) {
mOnCompletionListener.onCompletion(mMediaPlayer);
}
if (mp != null) {
mp.release();
}
}
};

Expand All @@ -580,6 +585,9 @@ public boolean onError(MediaPlayer mp, int framework_err, int impl_err)
if (mMediaController != null) {
mMediaController.hide();
}
if (mp != null) {
mp.release();
}

/* If an error handler has been supplied, use it and finish. */
if (mOnErrorListener != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -343,12 +343,14 @@ public void onPrepared(MediaPlayer mp)
@Override
public void onCompletion(MediaPlayer mp)
{
mp.release();
getPlayerProxy().onPlaybackComplete();
}

@Override
public boolean onError(MediaPlayer mp, int what, int extra)
{
mp.release();
getPlayerProxy().onPlaybackError(what);
return false; // Let completion listener run.
}
Expand Down

0 comments on commit c3ad085

Please sign in to comment.