1088 lines
39 KiB
Java
1088 lines
39 KiB
Java
package com.ubt.jimu.widgets.player.widget;
|
|
|
|
import android.R;
|
|
import android.annotation.TargetApi;
|
|
import android.content.Context;
|
|
import android.graphics.Bitmap;
|
|
import android.media.AudioManager;
|
|
import android.net.Uri;
|
|
import android.os.Build;
|
|
import android.os.Bundle;
|
|
import android.os.Handler;
|
|
import android.os.Looper;
|
|
import android.os.Message;
|
|
import android.text.TextUtils;
|
|
import android.util.Log;
|
|
import android.view.View;
|
|
import android.widget.FrameLayout;
|
|
import android.widget.MediaController;
|
|
import android.widget.ProgressBar;
|
|
import android.widget.RelativeLayout;
|
|
import android.widget.TextView;
|
|
import android.widget.Toast;
|
|
import com.baidu.cloud.media.player.BDCloudMediaPlayer;
|
|
import com.baidu.cloud.media.player.BDTimedText;
|
|
import com.baidu.cloud.media.player.IMediaPlayer;
|
|
import com.baidu.cloud.videocache.CacheListener;
|
|
import com.baidu.cloud.videocache.ProxyCacheManager;
|
|
import com.ubt.jimu.widgets.player.widget.IRenderView;
|
|
import com.ubt.jimu.widgets.player.widget.datasource.ExtDataSourceProvider;
|
|
import java.io.File;
|
|
import java.io.IOException;
|
|
import java.util.Map;
|
|
|
|
/* loaded from: classes2.dex */
|
|
public class BDCloudVideoView extends FrameLayout implements MediaController.MediaPlayerControl {
|
|
private static boolean t0 = false;
|
|
private IMediaPlayer.OnSeekCompleteListener A;
|
|
private boolean B;
|
|
private boolean C;
|
|
private boolean D;
|
|
private String E;
|
|
private int F;
|
|
private Context G;
|
|
private IRenderView H;
|
|
private int I;
|
|
private int J;
|
|
private int K;
|
|
private boolean L;
|
|
private int M;
|
|
private boolean N;
|
|
private long O;
|
|
private int P;
|
|
private float Q;
|
|
private float R;
|
|
private int S;
|
|
private int T;
|
|
private int U;
|
|
private int V;
|
|
private boolean W;
|
|
private boolean a;
|
|
private int a0;
|
|
private Uri b;
|
|
private int b0;
|
|
private Map<String, String> c;
|
|
private float c0;
|
|
private ProxyCacheManager d;
|
|
private RelativeLayout d0;
|
|
private int e;
|
|
private ProgressBar e0;
|
|
private int f;
|
|
private TextView f0;
|
|
private String[] g;
|
|
private FrameLayout g0;
|
|
private String[] h;
|
|
private Handler h0;
|
|
private boolean i;
|
|
private TextView i0;
|
|
private PlayerState j;
|
|
IMediaPlayer.OnVideoSizeChangedListener j0;
|
|
private boolean k;
|
|
IMediaPlayer.OnPreparedListener k0;
|
|
private IRenderView.ISurfaceHolder l;
|
|
private IMediaPlayer.OnCompletionListener l0;
|
|
private BDCloudMediaPlayer m;
|
|
private IMediaPlayer.OnInfoListener m0;
|
|
private int n;
|
|
private IMediaPlayer.OnErrorListener n0;
|
|
private int o;
|
|
private IMediaPlayer.OnBufferingUpdateListener o0;
|
|
private int p;
|
|
private IMediaPlayer.OnSeekCompleteListener p0;
|
|
private int q;
|
|
private IMediaPlayer.OnTimedTextListener q0;
|
|
private int r;
|
|
private IMediaPlayer.OnMetadataListener r0;
|
|
private IMediaPlayer.OnCompletionListener s;
|
|
IRenderView.IRenderCallback s0;
|
|
private IMediaPlayer.OnPreparedListener t;
|
|
private int u;
|
|
private IMediaPlayer.OnErrorListener v;
|
|
private IMediaPlayer.OnInfoListener x;
|
|
private OnPlayerStateListener y;
|
|
private IMediaPlayer.OnBufferingUpdateListener z;
|
|
|
|
public interface OnPlayerStateListener {
|
|
void a(PlayerState playerState);
|
|
}
|
|
|
|
public enum PlayerState {
|
|
STATE_ERROR(-1),
|
|
STATE_IDLE(0),
|
|
STATE_PREPARING(1),
|
|
STATE_PREPARED(2),
|
|
STATE_PLAYING(3),
|
|
STATE_PAUSED(4),
|
|
STATE_PLAYBACK_COMPLETED(5),
|
|
STATE_VIDEOSIZE_CHANGED(6);
|
|
|
|
private int code;
|
|
|
|
PlayerState(int i) {
|
|
this.code = i;
|
|
}
|
|
}
|
|
|
|
public BDCloudVideoView(Context context) {
|
|
super(context);
|
|
this.a = true;
|
|
this.e = 0;
|
|
this.f = 0;
|
|
this.i = true;
|
|
this.j = PlayerState.STATE_IDLE;
|
|
this.k = false;
|
|
this.l = null;
|
|
this.m = null;
|
|
this.B = true;
|
|
this.C = true;
|
|
this.D = true;
|
|
this.E = null;
|
|
this.F = 0;
|
|
this.K = 0;
|
|
this.L = true;
|
|
this.M = 0;
|
|
this.N = false;
|
|
this.O = 0L;
|
|
this.P = 0;
|
|
this.Q = -1.0f;
|
|
this.R = -1.0f;
|
|
this.S = -1;
|
|
this.T = 0;
|
|
this.U = 0;
|
|
this.V = -1;
|
|
this.W = false;
|
|
this.a0 = 0;
|
|
this.b0 = -1;
|
|
this.c0 = 1.0f;
|
|
this.d0 = null;
|
|
this.e0 = null;
|
|
this.f0 = null;
|
|
this.g0 = null;
|
|
this.h0 = new Handler(Looper.getMainLooper()) { // from class: com.ubt.jimu.widgets.player.widget.BDCloudVideoView.1
|
|
@Override // android.os.Handler
|
|
public void handleMessage(Message message) {
|
|
int i = message.what;
|
|
if (i == 1) {
|
|
BDCloudVideoView.this.setCachingHintViewVisibility(message.arg1 == 1);
|
|
return;
|
|
}
|
|
if (i == 10005) {
|
|
Toast.makeText(BDCloudVideoView.this.G, "清晰度切换中...", 0).show();
|
|
} else if (i == 10006) {
|
|
if (message.arg2 < 0) {
|
|
Toast.makeText(BDCloudVideoView.this.G, "清晰度切换失败!", 0).show();
|
|
} else {
|
|
Toast.makeText(BDCloudVideoView.this.G, "清晰度切换成功!", 0).show();
|
|
}
|
|
}
|
|
}
|
|
};
|
|
this.j0 = new IMediaPlayer.OnVideoSizeChangedListener() { // from class: com.ubt.jimu.widgets.player.widget.BDCloudVideoView.3
|
|
@Override // com.baidu.cloud.media.player.IMediaPlayer.OnVideoSizeChangedListener
|
|
public void onVideoSizeChanged(IMediaPlayer iMediaPlayer, int i, int i2, int i3, int i4) {
|
|
Log.d("BDCloudVideoView", "onVideoSizeChanged width=" + i + ";height=" + i2 + ";sarNum=" + i3 + ";sarDen=" + i4);
|
|
BDCloudVideoView.this.n = iMediaPlayer.getVideoWidth();
|
|
BDCloudVideoView.this.o = iMediaPlayer.getVideoHeight();
|
|
BDCloudVideoView.this.I = iMediaPlayer.getVideoSarNum();
|
|
BDCloudVideoView.this.J = iMediaPlayer.getVideoSarDen();
|
|
if (BDCloudVideoView.this.n != 0 && BDCloudVideoView.this.o != 0) {
|
|
if (BDCloudVideoView.this.H != null) {
|
|
BDCloudVideoView.this.H.a(BDCloudVideoView.this.n, BDCloudVideoView.this.o);
|
|
BDCloudVideoView.this.H.b(BDCloudVideoView.this.I, BDCloudVideoView.this.J);
|
|
}
|
|
BDCloudVideoView.this.requestLayout();
|
|
}
|
|
BDCloudVideoView.this.a(PlayerState.STATE_VIDEOSIZE_CHANGED, true);
|
|
}
|
|
};
|
|
this.k0 = new IMediaPlayer.OnPreparedListener() { // from class: com.ubt.jimu.widgets.player.widget.BDCloudVideoView.4
|
|
@Override // com.baidu.cloud.media.player.IMediaPlayer.OnPreparedListener
|
|
public void onPrepared(IMediaPlayer iMediaPlayer) {
|
|
Log.d("BDCloudVideoView", "onPrepared");
|
|
BDCloudVideoView.this.setCurrentState(PlayerState.STATE_PREPARED);
|
|
BDCloudVideoView.this.b(false);
|
|
BDCloudVideoView.this.n = iMediaPlayer.getVideoWidth();
|
|
BDCloudVideoView.this.o = iMediaPlayer.getVideoHeight();
|
|
if (BDCloudVideoView.this.t != null) {
|
|
BDCloudVideoView.this.t.onPrepared(BDCloudVideoView.this.m);
|
|
}
|
|
Log.d("BDCloudVideoView", "onPrepared: mVideoWidth=" + BDCloudVideoView.this.n + ";mVideoHeight=" + BDCloudVideoView.this.o + ";mSurfaceWidth=" + BDCloudVideoView.this.p + ";mSurfaceHeight=" + BDCloudVideoView.this.q);
|
|
if (BDCloudVideoView.this.n == 0 || BDCloudVideoView.this.o == 0) {
|
|
if (BDCloudVideoView.this.k) {
|
|
BDCloudVideoView.this.start();
|
|
}
|
|
} else if (BDCloudVideoView.this.H != null) {
|
|
BDCloudVideoView.this.H.a(BDCloudVideoView.this.n, BDCloudVideoView.this.o);
|
|
BDCloudVideoView.this.H.b(BDCloudVideoView.this.I, BDCloudVideoView.this.J);
|
|
if ((!BDCloudVideoView.this.H.a() || (BDCloudVideoView.this.p == BDCloudVideoView.this.n && BDCloudVideoView.this.q == BDCloudVideoView.this.o)) && BDCloudVideoView.this.k) {
|
|
BDCloudVideoView.this.start();
|
|
}
|
|
}
|
|
}
|
|
};
|
|
this.l0 = new IMediaPlayer.OnCompletionListener() { // from class: com.ubt.jimu.widgets.player.widget.BDCloudVideoView.5
|
|
@Override // com.baidu.cloud.media.player.IMediaPlayer.OnCompletionListener
|
|
public void onCompletion(IMediaPlayer iMediaPlayer) {
|
|
Log.d("BDCloudVideoView", "onCompletion");
|
|
BDCloudVideoView.this.b(false);
|
|
BDCloudVideoView.this.setCurrentState(PlayerState.STATE_PLAYBACK_COMPLETED);
|
|
BDCloudVideoView.this.k = false;
|
|
if (BDCloudVideoView.this.s != null) {
|
|
BDCloudVideoView.this.s.onCompletion(BDCloudVideoView.this.m);
|
|
}
|
|
}
|
|
};
|
|
this.m0 = new IMediaPlayer.OnInfoListener() { // from class: com.ubt.jimu.widgets.player.widget.BDCloudVideoView.6
|
|
/* JADX WARN: Can't fix incorrect switch cases order, some code will duplicate */
|
|
@Override // com.baidu.cloud.media.player.IMediaPlayer.OnInfoListener
|
|
public boolean onInfo(IMediaPlayer iMediaPlayer, int i, int i2) {
|
|
Log.d("BDCloudVideoView", "onInfo: arg1=" + i + "; arg2=" + i2);
|
|
if (BDCloudVideoView.this.x != null) {
|
|
BDCloudVideoView.this.x.onInfo(iMediaPlayer, i, i2);
|
|
}
|
|
if (i == 3) {
|
|
Log.d("BDCloudVideoView", "MEDIA_INFO_VIDEO_RENDERING_START:");
|
|
} else if (i == 901) {
|
|
Log.d("BDCloudVideoView", "MEDIA_INFO_UNSUPPORTED_SUBTITLE:");
|
|
} else if (i == 902) {
|
|
Log.d("BDCloudVideoView", "MEDIA_INFO_SUBTITLE_TIMED_OUT:");
|
|
} else if (i == 10001) {
|
|
BDCloudVideoView.this.r = i2;
|
|
Log.d("BDCloudVideoView", "MEDIA_INFO_VIDEO_ROTATION_CHANGED: " + i2);
|
|
if (BDCloudVideoView.this.H != null) {
|
|
BDCloudVideoView.this.H.setVideoRotation(i2);
|
|
}
|
|
} else if (i == 10002) {
|
|
Log.d("BDCloudVideoView", "MEDIA_INFO_AUDIO_RENDERING_START:");
|
|
} else if (i == 10005) {
|
|
Log.i("BDCloudVideoView", " MEDIA_INFO_MEDIA_CHANGE_START:");
|
|
BDCloudVideoView.this.a(i, 0);
|
|
} else if (i != 10006) {
|
|
switch (i) {
|
|
case IMediaPlayer.MEDIA_INFO_VIDEO_TRACK_LAGGING /* 700 */:
|
|
Log.d("BDCloudVideoView", "MEDIA_INFO_VIDEO_TRACK_LAGGING:");
|
|
break;
|
|
case IMediaPlayer.MEDIA_INFO_BUFFERING_START /* 701 */:
|
|
Log.d("BDCloudVideoView", "MEDIA_INFO_BUFFERING_START:");
|
|
BDCloudVideoView.this.b(true);
|
|
break;
|
|
case IMediaPlayer.MEDIA_INFO_BUFFERING_END /* 702 */:
|
|
Log.d("BDCloudVideoView", "MEDIA_INFO_BUFFERING_END:");
|
|
BDCloudVideoView.this.b(false);
|
|
break;
|
|
case IMediaPlayer.MEDIA_INFO_NETWORK_BANDWIDTH /* 703 */:
|
|
Log.d("BDCloudVideoView", "MEDIA_INFO_NETWORK_BANDWIDTH: " + i2);
|
|
break;
|
|
default:
|
|
switch (i) {
|
|
case 800:
|
|
Log.d("BDCloudVideoView", "MEDIA_INFO_BAD_INTERLEAVING:");
|
|
break;
|
|
case IMediaPlayer.MEDIA_INFO_NOT_SEEKABLE /* 801 */:
|
|
Log.d("BDCloudVideoView", "MEDIA_INFO_NOT_SEEKABLE:");
|
|
break;
|
|
case IMediaPlayer.MEDIA_INFO_METADATA_UPDATE /* 802 */:
|
|
Log.d("BDCloudVideoView", "MEDIA_INFO_METADATA_UPDATE:");
|
|
break;
|
|
}
|
|
}
|
|
} else {
|
|
BDCloudVideoView.this.a(i, i2);
|
|
Log.d("BDCloudVideoView", " MEDIA_INFO_MEDIA_CHANGE_END:");
|
|
}
|
|
return true;
|
|
}
|
|
};
|
|
this.n0 = new IMediaPlayer.OnErrorListener() { // from class: com.ubt.jimu.widgets.player.widget.BDCloudVideoView.7
|
|
@Override // com.baidu.cloud.media.player.IMediaPlayer.OnErrorListener
|
|
public boolean onError(IMediaPlayer iMediaPlayer, int i, int i2) {
|
|
Log.d("BDCloudVideoView", "onError: " + i + "," + i2);
|
|
if (i == -1000) {
|
|
Toast.makeText(BDCloudVideoView.this.G, "鉴权失败, 请申请播放权限!", 1).show();
|
|
} else {
|
|
Toast.makeText(BDCloudVideoView.this.G, "onError: " + i + " / " + i2, 1).show();
|
|
}
|
|
BDCloudVideoView.this.setCurrentState(PlayerState.STATE_ERROR);
|
|
BDCloudVideoView.this.k = false;
|
|
BDCloudVideoView.this.b(false);
|
|
if (BDCloudVideoView.this.v == null || BDCloudVideoView.this.v.onError(BDCloudVideoView.this.m, i, i2)) {
|
|
}
|
|
return true;
|
|
}
|
|
};
|
|
this.o0 = new IMediaPlayer.OnBufferingUpdateListener() { // from class: com.ubt.jimu.widgets.player.widget.BDCloudVideoView.8
|
|
@Override // com.baidu.cloud.media.player.IMediaPlayer.OnBufferingUpdateListener
|
|
public void onBufferingUpdate(IMediaPlayer iMediaPlayer, int i) {
|
|
BDCloudVideoView.this.u = i;
|
|
if (BDCloudVideoView.this.z != null) {
|
|
BDCloudVideoView.this.z.onBufferingUpdate(iMediaPlayer, i);
|
|
}
|
|
}
|
|
};
|
|
this.p0 = new IMediaPlayer.OnSeekCompleteListener() { // from class: com.ubt.jimu.widgets.player.widget.BDCloudVideoView.9
|
|
@Override // com.baidu.cloud.media.player.IMediaPlayer.OnSeekCompleteListener
|
|
public void onSeekComplete(IMediaPlayer iMediaPlayer) {
|
|
Log.d("BDCloudVideoView", "onSeekComplete");
|
|
BDCloudVideoView.this.b(false);
|
|
if (BDCloudVideoView.this.A != null) {
|
|
BDCloudVideoView.this.A.onSeekComplete(iMediaPlayer);
|
|
}
|
|
}
|
|
};
|
|
this.q0 = new IMediaPlayer.OnTimedTextListener() { // from class: com.ubt.jimu.widgets.player.widget.BDCloudVideoView.10
|
|
@Override // com.baidu.cloud.media.player.IMediaPlayer.OnTimedTextListener
|
|
public void onTimedText(IMediaPlayer iMediaPlayer, BDTimedText bDTimedText) {
|
|
Log.d("BDCloudVideoView", "onTimedText text=" + bDTimedText.getText());
|
|
if (bDTimedText != null) {
|
|
BDCloudVideoView.this.i0.setText(bDTimedText.getText());
|
|
}
|
|
}
|
|
};
|
|
this.r0 = new IMediaPlayer.OnMetadataListener(this) { // from class: com.ubt.jimu.widgets.player.widget.BDCloudVideoView.11
|
|
@Override // com.baidu.cloud.media.player.IMediaPlayer.OnMetadataListener
|
|
public void onMetadata(IMediaPlayer iMediaPlayer, Bundle bundle) {
|
|
for (String str : bundle.keySet()) {
|
|
Log.d("BDCloudVideoView", "onMetadata: key = " + str + ", value = " + bundle.getString(str));
|
|
}
|
|
}
|
|
};
|
|
this.s0 = new IRenderView.IRenderCallback() { // from class: com.ubt.jimu.widgets.player.widget.BDCloudVideoView.12
|
|
@Override // com.ubt.jimu.widgets.player.widget.IRenderView.IRenderCallback
|
|
public void a(IRenderView.ISurfaceHolder iSurfaceHolder, int i, int i2, int i3) {
|
|
Log.d("BDCloudVideoView", "mSHCallback onSurfaceChanged");
|
|
if (iSurfaceHolder.a() != BDCloudVideoView.this.H) {
|
|
Log.e("BDCloudVideoView", "onSurfaceChanged: unmatched render callback\n");
|
|
return;
|
|
}
|
|
BDCloudVideoView.this.p = i2;
|
|
BDCloudVideoView.this.q = i3;
|
|
boolean z = BDCloudVideoView.this.k;
|
|
boolean z2 = !BDCloudVideoView.this.H.a() || (BDCloudVideoView.this.n == i2 && BDCloudVideoView.this.o == i3);
|
|
if (BDCloudVideoView.this.m != null && z && z2) {
|
|
BDCloudVideoView.this.start();
|
|
}
|
|
}
|
|
|
|
@Override // com.ubt.jimu.widgets.player.widget.IRenderView.IRenderCallback
|
|
public void a(IRenderView.ISurfaceHolder iSurfaceHolder, int i, int i2) {
|
|
if (iSurfaceHolder.a() == BDCloudVideoView.this.H) {
|
|
BDCloudVideoView.this.l = iSurfaceHolder;
|
|
if (BDCloudVideoView.this.m == null) {
|
|
BDCloudVideoView.this.i();
|
|
return;
|
|
} else {
|
|
BDCloudVideoView bDCloudVideoView = BDCloudVideoView.this;
|
|
bDCloudVideoView.a(bDCloudVideoView.m, iSurfaceHolder);
|
|
return;
|
|
}
|
|
}
|
|
Log.e("BDCloudVideoView", "onSurfaceCreated: unmatched render callback\n");
|
|
}
|
|
|
|
@Override // com.ubt.jimu.widgets.player.widget.IRenderView.IRenderCallback
|
|
public void a(IRenderView.ISurfaceHolder iSurfaceHolder) {
|
|
if (iSurfaceHolder.a() == BDCloudVideoView.this.H) {
|
|
BDCloudVideoView.this.l = null;
|
|
BDCloudVideoView.this.j();
|
|
} else {
|
|
Log.e("BDCloudVideoView", "onSurfaceDestroyed: unmatched render callback\n");
|
|
}
|
|
}
|
|
};
|
|
a(context);
|
|
}
|
|
|
|
public static void setAK(String str) {
|
|
BDCloudMediaPlayer.setAK(str);
|
|
}
|
|
|
|
public static void setAppId(String str) {
|
|
BDCloudMediaPlayer.setAppId(str);
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
public void setCachingHintViewVisibility(boolean z) {
|
|
if (z) {
|
|
this.d0.setVisibility(0);
|
|
} else {
|
|
this.d0.setVisibility(8);
|
|
}
|
|
}
|
|
|
|
public static void setCuid(String str) {
|
|
BDCloudMediaPlayer.setCuid(str);
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
public void setCurrentState(PlayerState playerState) {
|
|
if (this.j != playerState) {
|
|
this.j = playerState;
|
|
OnPlayerStateListener onPlayerStateListener = this.y;
|
|
if (onPlayerStateListener != null) {
|
|
onPlayerStateListener.a(this.j);
|
|
}
|
|
}
|
|
}
|
|
|
|
private void setVideoURI(Uri uri) {
|
|
this.b = uri;
|
|
i();
|
|
requestLayout();
|
|
invalidate();
|
|
}
|
|
|
|
@Override // android.widget.MediaController.MediaPlayerControl
|
|
public boolean canPause() {
|
|
return this.B;
|
|
}
|
|
|
|
@Override // android.widget.MediaController.MediaPlayerControl
|
|
public boolean canSeekBackward() {
|
|
return this.C;
|
|
}
|
|
|
|
@Override // android.widget.MediaController.MediaPlayerControl
|
|
public boolean canSeekForward() {
|
|
return this.D;
|
|
}
|
|
|
|
@Override // android.widget.MediaController.MediaPlayerControl
|
|
public int getAudioSessionId() {
|
|
return 0;
|
|
}
|
|
|
|
public Bitmap getBitmap() {
|
|
IRenderView iRenderView = this.H;
|
|
if (iRenderView != null) {
|
|
return iRenderView.getBitmap();
|
|
}
|
|
return null;
|
|
}
|
|
|
|
@Override // android.widget.MediaController.MediaPlayerControl
|
|
public int getBufferPercentage() {
|
|
if (this.m != null) {
|
|
return this.u;
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
public IMediaPlayer getCurrentMediaPlayer() {
|
|
return this.m;
|
|
}
|
|
|
|
public PlayerState getCurrentPlayerState() {
|
|
return this.j;
|
|
}
|
|
|
|
public String getCurrentPlayingUrl() {
|
|
Uri uri = this.b;
|
|
if (uri != null) {
|
|
return uri.toString();
|
|
}
|
|
return null;
|
|
}
|
|
|
|
@Override // android.widget.MediaController.MediaPlayerControl
|
|
public int getCurrentPosition() {
|
|
if (h()) {
|
|
return (int) this.m.getCurrentPosition();
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
public long getDownloadSpeed() {
|
|
BDCloudMediaPlayer bDCloudMediaPlayer = this.m;
|
|
if (bDCloudMediaPlayer != null) {
|
|
return bDCloudMediaPlayer.getDownloadSpeed();
|
|
}
|
|
return 0L;
|
|
}
|
|
|
|
@Override // android.widget.MediaController.MediaPlayerControl
|
|
public int getDuration() {
|
|
if (h()) {
|
|
return (int) this.m.getDuration();
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
public int getMediaInputType() {
|
|
return this.e;
|
|
}
|
|
|
|
public String[] getMutilMediasDsc() {
|
|
return this.h;
|
|
}
|
|
|
|
public int getPlayType() {
|
|
return this.f;
|
|
}
|
|
|
|
public String[] getVariantInfo() {
|
|
BDCloudMediaPlayer bDCloudMediaPlayer = this.m;
|
|
if (bDCloudMediaPlayer == null) {
|
|
return null;
|
|
}
|
|
int i = this.e;
|
|
return (i == 1 || i == 2) ? this.m.getMediaItems() : bDCloudMediaPlayer.getVariantInfo();
|
|
}
|
|
|
|
public int getVideoHeight() {
|
|
return this.o;
|
|
}
|
|
|
|
public int getVideoWidth() {
|
|
return this.n;
|
|
}
|
|
|
|
@Override // android.widget.MediaController.MediaPlayerControl
|
|
public boolean isPlaying() {
|
|
return h() && this.m.isPlaying();
|
|
}
|
|
|
|
@Override // android.widget.MediaController.MediaPlayerControl
|
|
public void pause() {
|
|
if (h() && this.m.isPlaying()) {
|
|
this.m.pause();
|
|
setCurrentState(PlayerState.STATE_PAUSED);
|
|
}
|
|
this.k = false;
|
|
}
|
|
|
|
@Override // android.widget.MediaController.MediaPlayerControl
|
|
public void seekTo(int i) {
|
|
if (h()) {
|
|
this.m.seekTo(i);
|
|
b(true);
|
|
}
|
|
}
|
|
|
|
public void setBufferSizeInBytes(int i) {
|
|
this.a0 = i;
|
|
BDCloudMediaPlayer bDCloudMediaPlayer = this.m;
|
|
if (bDCloudMediaPlayer != null) {
|
|
bDCloudMediaPlayer.setBufferSizeInBytes(this.a0);
|
|
}
|
|
}
|
|
|
|
public void setBufferTimeInMs(int i) {
|
|
this.K = i;
|
|
BDCloudMediaPlayer bDCloudMediaPlayer = this.m;
|
|
if (bDCloudMediaPlayer != null) {
|
|
bDCloudMediaPlayer.setBufferTimeInMs(this.K);
|
|
}
|
|
}
|
|
|
|
public void setDecodeMode(int i) {
|
|
this.M = i;
|
|
BDCloudMediaPlayer bDCloudMediaPlayer = this.m;
|
|
if (bDCloudMediaPlayer != null) {
|
|
bDCloudMediaPlayer.setDecodeMode(this.M);
|
|
}
|
|
}
|
|
|
|
public void setHeaders(Map<String, String> map) {
|
|
this.c = map;
|
|
}
|
|
|
|
public void setInitPlayPosition(long j) {
|
|
this.O = j;
|
|
BDCloudMediaPlayer bDCloudMediaPlayer = this.m;
|
|
if (bDCloudMediaPlayer != null) {
|
|
bDCloudMediaPlayer.setInitPlayPosition(this.O);
|
|
this.O = -1L;
|
|
}
|
|
}
|
|
|
|
public void setLogEnabled(boolean z) {
|
|
this.N = z;
|
|
BDCloudMediaPlayer bDCloudMediaPlayer = this.m;
|
|
if (bDCloudMediaPlayer != null) {
|
|
bDCloudMediaPlayer.setLogEnabled(this.N);
|
|
}
|
|
}
|
|
|
|
public void setLooping(boolean z) {
|
|
this.W = z;
|
|
BDCloudMediaPlayer bDCloudMediaPlayer = this.m;
|
|
if (bDCloudMediaPlayer != null) {
|
|
bDCloudMediaPlayer.setLooping(this.W);
|
|
}
|
|
}
|
|
|
|
public void setMaxCacheSizeInBytes(int i) {
|
|
this.U = i;
|
|
BDCloudMediaPlayer bDCloudMediaPlayer = this.m;
|
|
if (bDCloudMediaPlayer != null) {
|
|
bDCloudMediaPlayer.setMaxCacheSizeInBytes(this.U);
|
|
}
|
|
}
|
|
|
|
public void setMaxProbeSize(int i) {
|
|
this.T = i;
|
|
BDCloudMediaPlayer bDCloudMediaPlayer = this.m;
|
|
if (bDCloudMediaPlayer != null) {
|
|
bDCloudMediaPlayer.setMaxProbeSize(this.T);
|
|
}
|
|
}
|
|
|
|
public void setMaxProbeTime(int i) {
|
|
this.S = i;
|
|
BDCloudMediaPlayer bDCloudMediaPlayer = this.m;
|
|
if (bDCloudMediaPlayer != null) {
|
|
bDCloudMediaPlayer.setMaxProbeTime(this.S);
|
|
}
|
|
}
|
|
|
|
public void setMediaInputType(int i) {
|
|
this.e = i;
|
|
if (i != 0) {
|
|
this.V = 5000;
|
|
}
|
|
BDCloudMediaPlayer bDCloudMediaPlayer = this.m;
|
|
if (bDCloudMediaPlayer != null) {
|
|
bDCloudMediaPlayer.setMediaInputType(i);
|
|
if (i != 0) {
|
|
this.m.setMaxCacheDuration(this.V);
|
|
}
|
|
}
|
|
}
|
|
|
|
public void setMediaItems(String[] strArr) {
|
|
this.g = strArr;
|
|
BDCloudMediaPlayer bDCloudMediaPlayer = this.m;
|
|
if (bDCloudMediaPlayer != null) {
|
|
bDCloudMediaPlayer.setMediaItems(strArr);
|
|
}
|
|
}
|
|
|
|
public void setOnBufferingUpdateListener(IMediaPlayer.OnBufferingUpdateListener onBufferingUpdateListener) {
|
|
this.z = onBufferingUpdateListener;
|
|
}
|
|
|
|
public void setOnCompletionListener(IMediaPlayer.OnCompletionListener onCompletionListener) {
|
|
this.s = onCompletionListener;
|
|
}
|
|
|
|
public void setOnErrorListener(IMediaPlayer.OnErrorListener onErrorListener) {
|
|
this.v = onErrorListener;
|
|
}
|
|
|
|
public void setOnInfoListener(IMediaPlayer.OnInfoListener onInfoListener) {
|
|
this.x = onInfoListener;
|
|
}
|
|
|
|
public void setOnPlayerStateListener(OnPlayerStateListener onPlayerStateListener) {
|
|
this.y = onPlayerStateListener;
|
|
}
|
|
|
|
public void setOnPreparedListener(IMediaPlayer.OnPreparedListener onPreparedListener) {
|
|
this.t = onPreparedListener;
|
|
}
|
|
|
|
public void setOnSeekCompleteListener(IMediaPlayer.OnSeekCompleteListener onSeekCompleteListener) {
|
|
this.A = onSeekCompleteListener;
|
|
}
|
|
|
|
public void setPlayType(int i) {
|
|
this.f = i;
|
|
BDCloudMediaPlayer bDCloudMediaPlayer = this.m;
|
|
if (bDCloudMediaPlayer != null) {
|
|
bDCloudMediaPlayer.setPlayType(i);
|
|
}
|
|
}
|
|
|
|
protected void setRenderView(IRenderView iRenderView) {
|
|
int i;
|
|
int i2;
|
|
if (this.H != null) {
|
|
BDCloudMediaPlayer bDCloudMediaPlayer = this.m;
|
|
if (bDCloudMediaPlayer != null) {
|
|
bDCloudMediaPlayer.setDisplay(null);
|
|
}
|
|
View view = this.H.getView();
|
|
this.H.a(this.s0);
|
|
this.H.release();
|
|
this.H = null;
|
|
this.l = null;
|
|
this.g0.removeView(view);
|
|
}
|
|
if (iRenderView == null) {
|
|
return;
|
|
}
|
|
this.H = iRenderView;
|
|
iRenderView.setAspectRatio(this.F);
|
|
int i3 = this.n;
|
|
if (i3 > 0 && (i2 = this.o) > 0) {
|
|
iRenderView.a(i3, i2);
|
|
}
|
|
int i4 = this.I;
|
|
if (i4 > 0 && (i = this.J) > 0) {
|
|
iRenderView.b(i4, i);
|
|
}
|
|
View view2 = this.H.getView();
|
|
view2.setLayoutParams(new FrameLayout.LayoutParams(-2, -2, 17));
|
|
this.g0.addView(view2);
|
|
this.H.b(this.s0);
|
|
this.H.setVideoRotation(this.r);
|
|
}
|
|
|
|
public void setSpeed(float f) {
|
|
this.c0 = f;
|
|
BDCloudMediaPlayer bDCloudMediaPlayer = this.m;
|
|
if (bDCloudMediaPlayer != null) {
|
|
bDCloudMediaPlayer.setSpeed(this.c0);
|
|
}
|
|
}
|
|
|
|
public void setTimeoutInUs(int i) {
|
|
BDCloudMediaPlayer bDCloudMediaPlayer = this.m;
|
|
if (bDCloudMediaPlayer != null) {
|
|
bDCloudMediaPlayer.setTimeoutInUs(i);
|
|
}
|
|
}
|
|
|
|
public void setVideoPath(String str) {
|
|
a(str, (String) null);
|
|
}
|
|
|
|
public void setVideoScalingMode(int i) {
|
|
if (i != 1 && i != 2 && i != 3) {
|
|
Log.e("BDCloudVideoView", "setVideoScalingMode: param should be VID");
|
|
return;
|
|
}
|
|
if (i == 1) {
|
|
this.F = 0;
|
|
} else if (i == 2) {
|
|
this.F = 1;
|
|
} else {
|
|
this.F = 3;
|
|
}
|
|
IRenderView iRenderView = this.H;
|
|
if (iRenderView != null) {
|
|
iRenderView.setAspectRatio(this.F);
|
|
}
|
|
}
|
|
|
|
@Override // android.widget.MediaController.MediaPlayerControl
|
|
public void start() {
|
|
if (this.m != null) {
|
|
PlayerState playerState = this.j;
|
|
if (playerState == PlayerState.STATE_ERROR || playerState == PlayerState.STATE_PLAYBACK_COMPLETED) {
|
|
if (this.j == PlayerState.STATE_PLAYBACK_COMPLETED) {
|
|
this.m.stop();
|
|
}
|
|
try {
|
|
this.m.prepareAsync();
|
|
b(true);
|
|
setCurrentState(PlayerState.STATE_PREPARING);
|
|
} catch (IllegalStateException unused) {
|
|
setCurrentState(PlayerState.STATE_ERROR);
|
|
this.k = false;
|
|
return;
|
|
}
|
|
} else if (h()) {
|
|
this.m.start();
|
|
setCurrentState(PlayerState.STATE_PLAYING);
|
|
}
|
|
}
|
|
this.k = true;
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
@TargetApi(14)
|
|
public void i() {
|
|
if (this.b == null || this.l == null) {
|
|
return;
|
|
}
|
|
a(false);
|
|
((AudioManager) this.G.getSystemService("audio")).requestAudioFocus(null, 3, 1);
|
|
try {
|
|
this.m = a();
|
|
if (!TextUtils.isEmpty(this.E)) {
|
|
this.m.setDecryptTokenForHLS(this.E);
|
|
}
|
|
this.m.setOnPreparedListener(this.k0);
|
|
this.m.setOnVideoSizeChangedListener(this.j0);
|
|
this.m.setOnCompletionListener(this.l0);
|
|
this.m.setOnErrorListener(this.n0);
|
|
this.m.setOnInfoListener(this.m0);
|
|
this.m.setOnBufferingUpdateListener(this.o0);
|
|
this.m.setOnSeekCompleteListener(this.p0);
|
|
this.m.setOnTimedTextListener(this.q0);
|
|
this.m.setOnMetadataListener(this.r0);
|
|
this.u = 0;
|
|
if ("asset".equals(this.b.getScheme())) {
|
|
String authority = this.b.getAuthority();
|
|
Log.w("BDCloudVideoView", "asset media name: " + authority);
|
|
this.m.setDataSource(new ExtDataSourceProvider(this.G.getResources().getAssets().open(authority, 1)));
|
|
} else {
|
|
this.m.setDataSource(this.G, this.b, this.c);
|
|
}
|
|
a(this.m, this.l);
|
|
this.m.setAudioStreamType(3);
|
|
this.m.setScreenOnWhilePlaying(true);
|
|
this.m.setTimeoutInUs(15000000);
|
|
try {
|
|
this.m.prepareAsync();
|
|
b(true);
|
|
setCurrentState(PlayerState.STATE_PREPARING);
|
|
} catch (IllegalStateException unused) {
|
|
setCurrentState(PlayerState.STATE_ERROR);
|
|
this.k = false;
|
|
}
|
|
} catch (IOException e) {
|
|
Log.w("BDCloudVideoView", "Unable to open content: " + this.b, e);
|
|
setCurrentState(PlayerState.STATE_ERROR);
|
|
this.k = false;
|
|
this.n0.onError(this.m, 1, 0);
|
|
} catch (IllegalArgumentException e2) {
|
|
Log.w("BDCloudVideoView", "Unable to open content: " + this.b, e2);
|
|
setCurrentState(PlayerState.STATE_ERROR);
|
|
this.k = false;
|
|
this.n0.onError(this.m, 1, 0);
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
public void j() {
|
|
BDCloudMediaPlayer bDCloudMediaPlayer = this.m;
|
|
if (bDCloudMediaPlayer == null || !(this.H instanceof SurfaceRenderView)) {
|
|
return;
|
|
}
|
|
bDCloudMediaPlayer.setDisplay(null);
|
|
}
|
|
|
|
private void f() {
|
|
this.d0 = new RelativeLayout(getContext());
|
|
FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(-1, -1);
|
|
this.d0.setVisibility(8);
|
|
addView(this.d0, layoutParams);
|
|
RelativeLayout.LayoutParams layoutParams2 = new RelativeLayout.LayoutParams(-2, -2);
|
|
layoutParams2.addRule(13);
|
|
this.e0 = new ProgressBar(getContext());
|
|
this.e0.setId(R.id.text1);
|
|
this.e0.setMax(100);
|
|
this.e0.setProgress(10);
|
|
this.e0.setSecondaryProgress(100);
|
|
this.d0.addView(this.e0, layoutParams2);
|
|
RelativeLayout.LayoutParams layoutParams3 = new RelativeLayout.LayoutParams(-1, -2);
|
|
layoutParams3.addRule(9);
|
|
layoutParams3.addRule(3, R.id.text1);
|
|
this.f0 = new TextView(getContext());
|
|
this.f0.setTextColor(-1);
|
|
this.f0.setText("正在缓冲...");
|
|
this.f0.setGravity(1);
|
|
this.d0.addView(this.f0, layoutParams3);
|
|
}
|
|
|
|
private void g() {
|
|
this.i0 = new TextView(getContext());
|
|
this.i0.setTextSize(24.0f);
|
|
this.i0.setGravity(17);
|
|
addView(this.i0, new FrameLayout.LayoutParams(-1, -2, 80));
|
|
}
|
|
|
|
private boolean h() {
|
|
PlayerState playerState;
|
|
return (this.m == null || (playerState = this.j) == PlayerState.STATE_ERROR || playerState == PlayerState.STATE_IDLE || playerState == PlayerState.STATE_PREPARING) ? false : true;
|
|
}
|
|
|
|
public void d() {
|
|
ProxyCacheManager proxyCacheManager;
|
|
a(true);
|
|
IRenderView iRenderView = this.H;
|
|
if (iRenderView != null) {
|
|
iRenderView.release();
|
|
}
|
|
if (!t0 || (proxyCacheManager = this.d) == null) {
|
|
return;
|
|
}
|
|
proxyCacheManager.a();
|
|
}
|
|
|
|
public void e() {
|
|
BDCloudMediaPlayer bDCloudMediaPlayer = this.m;
|
|
if (bDCloudMediaPlayer != null) {
|
|
bDCloudMediaPlayer.stop();
|
|
a(true);
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
public void b(boolean z) {
|
|
if (this.L) {
|
|
Message obtainMessage = this.h0.obtainMessage();
|
|
obtainMessage.what = 1;
|
|
obtainMessage.arg1 = z ? 1 : 0;
|
|
this.h0.sendMessage(obtainMessage);
|
|
}
|
|
}
|
|
|
|
public void c() {
|
|
if (this.a && Build.VERSION.SDK_INT >= 16) {
|
|
TextureRenderView textureRenderView = new TextureRenderView(getContext());
|
|
if (this.m != null) {
|
|
textureRenderView.getSurfaceHolder().a(this.m);
|
|
textureRenderView.a(this.m.getVideoWidth(), this.m.getVideoHeight());
|
|
textureRenderView.b(this.m.getVideoSarNum(), this.m.getVideoSarDen());
|
|
textureRenderView.setAspectRatio(this.F);
|
|
}
|
|
setRenderView(textureRenderView);
|
|
return;
|
|
}
|
|
setRenderView(new SurfaceRenderView(getContext()));
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
public void a(PlayerState playerState, boolean z) {
|
|
if (z || this.j != playerState) {
|
|
this.j = playerState;
|
|
OnPlayerStateListener onPlayerStateListener = this.y;
|
|
if (onPlayerStateListener != null) {
|
|
onPlayerStateListener.a(this.j);
|
|
}
|
|
}
|
|
}
|
|
|
|
public void b() {
|
|
IRenderView iRenderView = this.H;
|
|
if (iRenderView == null || (iRenderView instanceof SurfaceRenderView)) {
|
|
return;
|
|
}
|
|
this.g0.removeView(iRenderView.getView());
|
|
}
|
|
|
|
private void a(Context context) {
|
|
this.G = context.getApplicationContext();
|
|
this.g0 = new FrameLayout(context);
|
|
addView(this.g0, new FrameLayout.LayoutParams(-1, -1));
|
|
c();
|
|
g();
|
|
f();
|
|
this.n = 0;
|
|
this.o = 0;
|
|
setFocusable(true);
|
|
setFocusableInTouchMode(true);
|
|
requestFocus();
|
|
setCurrentState(PlayerState.STATE_IDLE);
|
|
this.d = ProxyCacheManager.b();
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
public void a(int i, int i2) {
|
|
if (this.i) {
|
|
Message obtainMessage = this.h0.obtainMessage();
|
|
obtainMessage.what = i;
|
|
obtainMessage.arg1 = i2;
|
|
this.h0.sendMessage(obtainMessage);
|
|
}
|
|
}
|
|
|
|
public void a(String str, String str2) {
|
|
this.E = str2;
|
|
if (t0 && this.e == 0) {
|
|
str = this.d.a(this.G, str);
|
|
this.d.a(new CacheListener(this) { // from class: com.ubt.jimu.widgets.player.widget.BDCloudVideoView.2
|
|
@Override // com.baidu.cloud.videocache.CacheListener
|
|
public void a(File file, String str3, int i) {
|
|
Log.d("BDCloudVideoView", "percents:" + i + " file" + file + " url:" + str3);
|
|
}
|
|
});
|
|
}
|
|
Log.w("BDCloudVideoView", "Video Uri: " + str);
|
|
setVideoURI(Uri.parse(str));
|
|
}
|
|
|
|
public BDCloudMediaPlayer a() {
|
|
BDCloudMediaPlayer bDCloudMediaPlayer = new BDCloudMediaPlayer(getContext());
|
|
bDCloudMediaPlayer.setLogEnabled(this.N);
|
|
bDCloudMediaPlayer.setDecodeMode(this.M);
|
|
long j = this.O;
|
|
if (j > -1) {
|
|
bDCloudMediaPlayer.setInitPlayPosition(j);
|
|
this.O = -1L;
|
|
}
|
|
if (this.P > 0) {
|
|
bDCloudMediaPlayer.setWakeMode(getContext(), this.P);
|
|
}
|
|
float f = this.Q;
|
|
if (f > -1.0f) {
|
|
float f2 = this.R;
|
|
if (f2 > -1.0f) {
|
|
bDCloudMediaPlayer.setVolume(f, f2);
|
|
}
|
|
}
|
|
int i = this.K;
|
|
if (i > 0) {
|
|
bDCloudMediaPlayer.setBufferTimeInMs(i);
|
|
}
|
|
int i2 = this.S;
|
|
if (i2 >= 0) {
|
|
bDCloudMediaPlayer.setMaxProbeTime(i2);
|
|
}
|
|
int i3 = this.T;
|
|
if (i3 > 0) {
|
|
bDCloudMediaPlayer.setMaxProbeSize(i3);
|
|
}
|
|
int i4 = this.U;
|
|
if (i4 > 0) {
|
|
bDCloudMediaPlayer.setMaxCacheSizeInBytes(i4);
|
|
}
|
|
boolean z = this.W;
|
|
if (z) {
|
|
bDCloudMediaPlayer.setLooping(z);
|
|
}
|
|
int i5 = this.a0;
|
|
if (i5 > 0) {
|
|
bDCloudMediaPlayer.setBufferSizeInBytes(i5);
|
|
}
|
|
int i6 = this.b0;
|
|
if (i6 >= 0) {
|
|
bDCloudMediaPlayer.toggleFrameChasing(i6 == 1);
|
|
}
|
|
String[] strArr = this.g;
|
|
if (strArr != null) {
|
|
bDCloudMediaPlayer.setMediaItems(strArr);
|
|
}
|
|
int i7 = this.V;
|
|
if (i7 >= 0) {
|
|
bDCloudMediaPlayer.setMaxCacheDuration(i7);
|
|
}
|
|
bDCloudMediaPlayer.setMediaInputType(this.e);
|
|
bDCloudMediaPlayer.setPlayType(this.f);
|
|
bDCloudMediaPlayer.setSpeed(this.c0);
|
|
return bDCloudMediaPlayer;
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
public void a(IMediaPlayer iMediaPlayer, IRenderView.ISurfaceHolder iSurfaceHolder) {
|
|
if (iMediaPlayer == null) {
|
|
return;
|
|
}
|
|
if (iSurfaceHolder == null) {
|
|
iMediaPlayer.setDisplay(null);
|
|
} else {
|
|
iSurfaceHolder.a(iMediaPlayer);
|
|
}
|
|
}
|
|
|
|
private void a(boolean z) {
|
|
BDCloudMediaPlayer bDCloudMediaPlayer = this.m;
|
|
if (bDCloudMediaPlayer != null) {
|
|
bDCloudMediaPlayer.reset();
|
|
this.m.setDisplay(null);
|
|
synchronized (this.m) {
|
|
this.m.release();
|
|
this.m = null;
|
|
}
|
|
setCurrentState(PlayerState.STATE_IDLE);
|
|
if (z) {
|
|
this.k = false;
|
|
}
|
|
((AudioManager) this.G.getSystemService("audio")).abandonAudioFocus(null);
|
|
}
|
|
}
|
|
}
|