Initial commit
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
package com.ubt.jimu.widgets.player;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public interface FullScreenSwitchoverListener {
|
||||
}
|
184
sources/com/ubt/jimu/widgets/player/UbtPlayer.java
Normal file
184
sources/com/ubt/jimu/widgets/player/UbtPlayer.java
Normal file
@@ -0,0 +1,184 @@
|
||||
package com.ubt.jimu.widgets.player;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.os.Bundle;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
import android.view.ViewStub;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import com.ubt.jimu.R;
|
||||
import com.ubt.jimu.ScreenRotationManageActivity;
|
||||
import com.ubt.jimu.base.entities.Constant;
|
||||
import com.ubt.jimu.utils.BitmapUtils;
|
||||
import com.ubt.jimu.utils.LogUtils;
|
||||
import com.ubt.jimu.widgets.player.UbtPlayerView;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class UbtPlayer extends ScreenRotationManageActivity implements UbtPlayerView.VideoErrorListener, View.OnClickListener {
|
||||
private UbtPlayerView a;
|
||||
private View b;
|
||||
private ViewStub c;
|
||||
private View d;
|
||||
private ImageView e;
|
||||
private ImageView f;
|
||||
private boolean g;
|
||||
private String h = "";
|
||||
|
||||
private void initData() {
|
||||
Intent intent = getIntent();
|
||||
this.h = intent.getStringExtra(Constant.Publish.VIDEO_PATH_KEY);
|
||||
String stringExtra = intent.getStringExtra(Constant.Publish.VIDEO_TITLE_KEY);
|
||||
this.g = intent.getBooleanExtra(Constant.Publish.IS_SHOW_CONFIRM_KEY, false);
|
||||
this.f.setVisibility(this.g ? 0 : 8);
|
||||
if (!TextUtils.isEmpty(stringExtra)) {
|
||||
this.a.setTitle(stringExtra);
|
||||
}
|
||||
LogUtils.c("视频播放路径:" + this.h);
|
||||
if (TextUtils.isEmpty(this.h)) {
|
||||
return;
|
||||
}
|
||||
this.a.setVideoPath(this.h);
|
||||
this.a.f();
|
||||
LogUtils.c("设置视频路径:" + this.h);
|
||||
}
|
||||
|
||||
private void initView() {
|
||||
this.a = (UbtPlayerView) findViewById(R.id.ubt_player);
|
||||
this.c = (ViewStub) findViewById(R.id.vs_load_failure);
|
||||
this.e = (ImageView) findViewById(R.id.im_back);
|
||||
this.f = (ImageView) findViewById(R.id.im_publish_confirm);
|
||||
this.a.setVideoErrorListener(this);
|
||||
this.e.setOnClickListener(this);
|
||||
this.f.setOnClickListener(this);
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.widgets.player.UbtPlayerView.VideoErrorListener
|
||||
public void j(final int i) {
|
||||
LogUtils.c("视频播放失败errorCode:" + i);
|
||||
this.a.post(new Runnable() { // from class: com.ubt.jimu.widgets.player.UbtPlayer.1
|
||||
@Override // java.lang.Runnable
|
||||
public void run() {
|
||||
UbtPlayer ubtPlayer = UbtPlayer.this;
|
||||
Bitmap a = BitmapUtils.a(ubtPlayer, ubtPlayer.b);
|
||||
if (UbtPlayer.this.d == null) {
|
||||
UbtPlayer ubtPlayer2 = UbtPlayer.this;
|
||||
ubtPlayer2.d = ubtPlayer2.c.inflate();
|
||||
UbtPlayer.this.d.setOnClickListener(UbtPlayer.this);
|
||||
} else {
|
||||
UbtPlayer.this.d.setVisibility(0);
|
||||
}
|
||||
ImageView imageView = (ImageView) UbtPlayer.this.d.findViewById(R.id.im_error_icon);
|
||||
TextView textView = (TextView) UbtPlayer.this.d.findViewById(R.id.tv_load_failed_hint);
|
||||
imageView.setOnClickListener(UbtPlayer.this);
|
||||
if (a != null) {
|
||||
new BitmapDrawable(a);
|
||||
UbtPlayer.this.d.setBackgroundColor(UbtPlayer.this.getResources().getColor(R.color.video_error_shade));
|
||||
}
|
||||
int i2 = i;
|
||||
if (i2 == -10000) {
|
||||
imageView.setBackgroundResource(R.drawable.ic_network_error);
|
||||
textView.setText(R.string.video_network_error);
|
||||
} else {
|
||||
if (i2 != 12345) {
|
||||
return;
|
||||
}
|
||||
imageView.setBackgroundResource(R.drawable.community_bg_content);
|
||||
textView.setText(R.string.video_failed);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override // android.view.View.OnClickListener
|
||||
public void onClick(View view) {
|
||||
int id = view.getId();
|
||||
if (id == R.id.im_back) {
|
||||
if (this.g) {
|
||||
c(0, this.h);
|
||||
return;
|
||||
} else {
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (id != R.id.im_error_icon) {
|
||||
if (id != R.id.im_publish_confirm) {
|
||||
return;
|
||||
}
|
||||
c(-1, this.h);
|
||||
return;
|
||||
}
|
||||
View view2 = this.d;
|
||||
if (view2 != null) {
|
||||
view2.setVisibility(8);
|
||||
}
|
||||
UbtPlayerView ubtPlayerView = this.a;
|
||||
if (ubtPlayerView != null) {
|
||||
ubtPlayerView.getCurrentPosition();
|
||||
this.a.e();
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.ScreenRotationManageActivity, androidx.appcompat.app.AppCompatActivity, androidx.fragment.app.FragmentActivity, androidx.core.app.ComponentActivity, android.app.Activity
|
||||
protected void onCreate(Bundle bundle) {
|
||||
super.onCreate(bundle);
|
||||
requestWindowFeature(1);
|
||||
getWindow().requestFeature(12);
|
||||
this.b = View.inflate(this, R.layout.activity_ubtplayer, null);
|
||||
setContentView(this.b);
|
||||
initView();
|
||||
initData();
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.ScreenRotationManageActivity, androidx.appcompat.app.AppCompatActivity, androidx.fragment.app.FragmentActivity, android.app.Activity
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
this.a.g();
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.ScreenRotationManageActivity, androidx.fragment.app.FragmentActivity, android.app.Activity
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
this.a.b();
|
||||
}
|
||||
|
||||
@Override // android.app.Activity
|
||||
protected void onRestart() {
|
||||
super.onRestart();
|
||||
this.a.c();
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.ScreenRotationManageActivity, androidx.fragment.app.FragmentActivity, android.app.Activity
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
this.a.d();
|
||||
}
|
||||
|
||||
private void c(int i, String str) {
|
||||
Intent intent = new Intent();
|
||||
intent.putExtra("url", str);
|
||||
setResult(i, intent);
|
||||
this.a.g();
|
||||
finish();
|
||||
}
|
||||
|
||||
public static void a(Context context, String str, String str2) {
|
||||
Intent intent = new Intent(context, (Class<?>) UbtPlayer.class);
|
||||
intent.putExtra(Constant.Publish.VIDEO_PATH_KEY, str2);
|
||||
intent.putExtra(Constant.Publish.VIDEO_TITLE_KEY, str);
|
||||
context.startActivity(intent);
|
||||
}
|
||||
|
||||
public static void a(Activity activity, int i, String str, String str2, boolean z) {
|
||||
Intent intent = new Intent(activity, (Class<?>) UbtPlayer.class);
|
||||
intent.putExtra(Constant.Publish.VIDEO_PATH_KEY, str2);
|
||||
intent.putExtra(Constant.Publish.VIDEO_TITLE_KEY, str);
|
||||
intent.putExtra(Constant.Publish.IS_SHOW_CONFIRM_KEY, z);
|
||||
activity.startActivityForResult(intent, i);
|
||||
}
|
||||
}
|
285
sources/com/ubt/jimu/widgets/player/UbtPlayerView.java
Normal file
285
sources/com/ubt/jimu/widgets/player/UbtPlayerView.java
Normal file
@@ -0,0 +1,285 @@
|
||||
package com.ubt.jimu.widgets.player;
|
||||
|
||||
import android.content.Context;
|
||||
import android.text.TextUtils;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.Toast;
|
||||
import com.baidu.cloud.media.player.IMediaPlayer;
|
||||
import com.ubt.jimu.R;
|
||||
import com.ubt.jimu.utils.LogUtils;
|
||||
import com.ubt.jimu.widgets.player.bar.SimpleMediaController;
|
||||
import com.ubt.jimu.widgets.player.widget.BDCloudVideoView;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class UbtPlayerView extends RelativeLayout implements IMediaPlayer.OnPreparedListener, IMediaPlayer.OnCompletionListener, IMediaPlayer.OnErrorListener, IMediaPlayer.OnInfoListener, IMediaPlayer.OnBufferingUpdateListener, BDCloudVideoView.OnPlayerStateListener, FullScreenSwitchoverListener, View.OnClickListener {
|
||||
private String a;
|
||||
private String b;
|
||||
private SimpleMediaController c;
|
||||
private RelativeLayout d;
|
||||
private Context e;
|
||||
private BDCloudVideoView f;
|
||||
private String g;
|
||||
private Toast h;
|
||||
private RelativeLayout i;
|
||||
private RelativeLayout j;
|
||||
private ImageView k;
|
||||
private ImageView l;
|
||||
private boolean m;
|
||||
private VideoErrorListener n;
|
||||
|
||||
public interface VideoErrorListener {
|
||||
void j(int i);
|
||||
}
|
||||
|
||||
public UbtPlayerView(Context context) {
|
||||
this(context, null);
|
||||
}
|
||||
|
||||
private void h() {
|
||||
this.k.setOnClickListener(this);
|
||||
}
|
||||
|
||||
private void i() {
|
||||
BDCloudVideoView.setAppId(this.b);
|
||||
BDCloudVideoView.setAK(this.a);
|
||||
this.f = new BDCloudVideoView(this.e);
|
||||
this.f.setOnPreparedListener(this);
|
||||
this.f.setOnCompletionListener(this);
|
||||
this.f.setOnErrorListener(this);
|
||||
this.f.setOnInfoListener(this);
|
||||
this.f.setOnBufferingUpdateListener(this);
|
||||
this.f.setOnPlayerStateListener(this);
|
||||
}
|
||||
|
||||
private void j() {
|
||||
this.i = (RelativeLayout) ((LayoutInflater) getContext().getSystemService("layout_inflater")).inflate(R.layout.layout_ubt_player, this);
|
||||
this.d = (RelativeLayout) this.i.findViewById(R.id.rl_player_container);
|
||||
this.j = (RelativeLayout) this.i.findViewById(R.id.rl_normalscreen_controller);
|
||||
this.c = (SimpleMediaController) findViewById(R.id.media_controller_bar);
|
||||
this.k = (ImageView) findViewById(R.id.playButton);
|
||||
this.l = (ImageView) findViewById(R.id.im_cover);
|
||||
this.c.setFullScreenSwitchoverListener(this);
|
||||
RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(-1, -1);
|
||||
layoutParams.addRule(13);
|
||||
this.d.addView(this.f, layoutParams);
|
||||
this.c.setMediaPlayerControl(this.f);
|
||||
this.f.setLogEnabled(true);
|
||||
this.f.setMaxProbeTime(2000);
|
||||
this.f.setTimeoutInUs(1000000);
|
||||
this.i.setEnabled(false);
|
||||
this.i.setOnClickListener(new View.OnClickListener() { // from class: com.ubt.jimu.widgets.player.UbtPlayerView.1
|
||||
@Override // android.view.View.OnClickListener
|
||||
public void onClick(View view) {
|
||||
UbtPlayerView.this.a();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.widgets.player.widget.BDCloudVideoView.OnPlayerStateListener
|
||||
public void a(BDCloudVideoView.PlayerState playerState) {
|
||||
SimpleMediaController simpleMediaController = this.c;
|
||||
if (simpleMediaController != null) {
|
||||
simpleMediaController.a();
|
||||
}
|
||||
BDCloudVideoView bDCloudVideoView = this.f;
|
||||
if (bDCloudVideoView == null) {
|
||||
return;
|
||||
}
|
||||
BDCloudVideoView.PlayerState currentPlayerState = bDCloudVideoView.getCurrentPlayerState();
|
||||
if (currentPlayerState == BDCloudVideoView.PlayerState.STATE_PLAYING) {
|
||||
this.i.setEnabled(true);
|
||||
this.k.setVisibility(8);
|
||||
}
|
||||
if (this.m && currentPlayerState == BDCloudVideoView.PlayerState.STATE_PLAYING) {
|
||||
this.m = false;
|
||||
this.f.pause();
|
||||
this.k.setVisibility(0);
|
||||
}
|
||||
}
|
||||
|
||||
public void b() {
|
||||
BDCloudVideoView bDCloudVideoView = this.f;
|
||||
if (bDCloudVideoView != null) {
|
||||
bDCloudVideoView.pause();
|
||||
}
|
||||
}
|
||||
|
||||
public void c() {
|
||||
BDCloudVideoView bDCloudVideoView;
|
||||
if (this.k.getVisibility() != 8 || (bDCloudVideoView = this.f) == null) {
|
||||
return;
|
||||
}
|
||||
bDCloudVideoView.start();
|
||||
}
|
||||
|
||||
public void d() {
|
||||
RelativeLayout relativeLayout = this.d;
|
||||
if (relativeLayout == null) {
|
||||
return;
|
||||
}
|
||||
relativeLayout.removeAllViews();
|
||||
this.j.removeAllViews();
|
||||
BDCloudVideoView bDCloudVideoView = this.f;
|
||||
if (bDCloudVideoView != null) {
|
||||
this.d.addView(bDCloudVideoView);
|
||||
}
|
||||
this.j.addView(this.c);
|
||||
}
|
||||
|
||||
public void e() {
|
||||
BDCloudVideoView bDCloudVideoView = this.f;
|
||||
if (bDCloudVideoView != null) {
|
||||
bDCloudVideoView.seekTo((int) this.c.getPreviousProgress());
|
||||
this.f.start();
|
||||
}
|
||||
}
|
||||
|
||||
public void f() {
|
||||
if (TextUtils.isEmpty(this.g)) {
|
||||
this.h = Toast.makeText(this.e, "播放错误:视频播发源出错(001)", 0);
|
||||
this.h.show();
|
||||
} else {
|
||||
this.m = false;
|
||||
this.f.setVideoPath(this.g);
|
||||
this.f.start();
|
||||
}
|
||||
}
|
||||
|
||||
public void g() {
|
||||
BDCloudVideoView bDCloudVideoView = this.f;
|
||||
if (bDCloudVideoView != null) {
|
||||
bDCloudVideoView.b();
|
||||
}
|
||||
BDCloudVideoView bDCloudVideoView2 = this.f;
|
||||
if (bDCloudVideoView2 != null) {
|
||||
bDCloudVideoView2.e();
|
||||
this.f.d();
|
||||
}
|
||||
this.f = null;
|
||||
Toast toast = this.h;
|
||||
if (toast != null) {
|
||||
toast.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
public long getCurrentPosition() {
|
||||
if (this.f != null) {
|
||||
return r0.getCurrentPosition();
|
||||
}
|
||||
return -1L;
|
||||
}
|
||||
|
||||
@Override // com.baidu.cloud.media.player.IMediaPlayer.OnBufferingUpdateListener
|
||||
public void onBufferingUpdate(IMediaPlayer iMediaPlayer, int i) {
|
||||
BDCloudVideoView bDCloudVideoView;
|
||||
SimpleMediaController simpleMediaController = this.c;
|
||||
if (simpleMediaController == null || (bDCloudVideoView = this.f) == null) {
|
||||
return;
|
||||
}
|
||||
simpleMediaController.a((i * bDCloudVideoView.getDuration()) / 100);
|
||||
}
|
||||
|
||||
@Override // android.view.View.OnClickListener
|
||||
public void onClick(View view) {
|
||||
LogUtils.c("开始播放");
|
||||
if (view.getId() != R.id.playButton) {
|
||||
return;
|
||||
}
|
||||
this.k.setVisibility(8);
|
||||
this.l.setVisibility(8);
|
||||
BDCloudVideoView bDCloudVideoView = this.f;
|
||||
if (bDCloudVideoView != null) {
|
||||
this.m = false;
|
||||
bDCloudVideoView.start();
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.baidu.cloud.media.player.IMediaPlayer.OnCompletionListener
|
||||
public void onCompletion(IMediaPlayer iMediaPlayer) {
|
||||
this.k.setVisibility(0);
|
||||
this.l.setVisibility(0);
|
||||
this.m = true;
|
||||
}
|
||||
|
||||
@Override // com.baidu.cloud.media.player.IMediaPlayer.OnErrorListener
|
||||
public boolean onError(IMediaPlayer iMediaPlayer, int i, int i2) {
|
||||
VideoErrorListener videoErrorListener = this.n;
|
||||
if (videoErrorListener == null) {
|
||||
return true;
|
||||
}
|
||||
videoErrorListener.j(i);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override // com.baidu.cloud.media.player.IMediaPlayer.OnInfoListener
|
||||
public boolean onInfo(IMediaPlayer iMediaPlayer, int i, int i2) {
|
||||
if (i == 701) {
|
||||
this.i.setEnabled(false);
|
||||
this.k.setVisibility(8);
|
||||
} else if (i == 702 && this.c != null) {
|
||||
this.i.setEnabled(true);
|
||||
this.k.setVisibility(8);
|
||||
BDCloudVideoView bDCloudVideoView = this.f;
|
||||
if (bDCloudVideoView != null) {
|
||||
bDCloudVideoView.start();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override // com.baidu.cloud.media.player.IMediaPlayer.OnPreparedListener
|
||||
public void onPrepared(IMediaPlayer iMediaPlayer) {
|
||||
if (this.f == null) {
|
||||
}
|
||||
}
|
||||
|
||||
public void setTitle(String str) {
|
||||
this.c.setTitle(str);
|
||||
}
|
||||
|
||||
public void setVideoErrorListener(VideoErrorListener videoErrorListener) {
|
||||
this.n = videoErrorListener;
|
||||
}
|
||||
|
||||
public void setVideoPath(String str) {
|
||||
this.g = str;
|
||||
}
|
||||
|
||||
public UbtPlayerView(Context context, AttributeSet attributeSet) {
|
||||
this(context, attributeSet, 0);
|
||||
}
|
||||
|
||||
public UbtPlayerView(Context context, AttributeSet attributeSet, int i) {
|
||||
this(context, attributeSet, i, 0);
|
||||
}
|
||||
|
||||
public UbtPlayerView(Context context, AttributeSet attributeSet, int i, int i2) {
|
||||
super(context, attributeSet, i, i2);
|
||||
this.a = "637ccdcd7133452fab2cd63c0ad326e7";
|
||||
this.b = "83120902010953728101p";
|
||||
this.f = null;
|
||||
this.e = context;
|
||||
i();
|
||||
j();
|
||||
h();
|
||||
}
|
||||
|
||||
public void a() {
|
||||
BDCloudVideoView bDCloudVideoView = this.f;
|
||||
if (bDCloudVideoView == null) {
|
||||
return;
|
||||
}
|
||||
if (bDCloudVideoView.isPlaying()) {
|
||||
this.k.setVisibility(0);
|
||||
this.f.pause();
|
||||
} else {
|
||||
this.k.setVisibility(8);
|
||||
this.l.setVisibility(8);
|
||||
this.f.start();
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,269 @@
|
||||
package com.ubt.jimu.widgets.player.bar;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.SeekBar;
|
||||
import android.widget.TextView;
|
||||
import com.ubt.jimu.R;
|
||||
import com.ubt.jimu.widgets.player.FullScreenSwitchoverListener;
|
||||
import com.ubt.jimu.widgets.player.widget.BDCloudVideoView;
|
||||
import com.ubtrobot.log.ALog;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class SimpleMediaController extends RelativeLayout {
|
||||
private TextView a;
|
||||
private SeekBar b;
|
||||
private TextView c;
|
||||
private Timer d;
|
||||
private Handler e;
|
||||
private long f;
|
||||
private BDCloudVideoView g;
|
||||
boolean h;
|
||||
private TextView i;
|
||||
private View j;
|
||||
private boolean k;
|
||||
private long l;
|
||||
|
||||
public SimpleMediaController(Context context, AttributeSet attributeSet) {
|
||||
super(context, attributeSet);
|
||||
this.e = new Handler(Looper.getMainLooper());
|
||||
this.g = null;
|
||||
this.h = false;
|
||||
this.k = false;
|
||||
this.l = 0L;
|
||||
c();
|
||||
}
|
||||
|
||||
public boolean getIsDragging() {
|
||||
return this.h;
|
||||
}
|
||||
|
||||
public Handler getMainThreadHandler() {
|
||||
return this.e;
|
||||
}
|
||||
|
||||
public long getPreviousProgress() {
|
||||
return this.f;
|
||||
}
|
||||
|
||||
public void setCache(int i) {
|
||||
SeekBar seekBar = this.b;
|
||||
if (seekBar == null || i == seekBar.getSecondaryProgress()) {
|
||||
return;
|
||||
}
|
||||
this.b.setSecondaryProgress(i);
|
||||
}
|
||||
|
||||
public void setFullScreenSwitchoverListener(FullScreenSwitchoverListener fullScreenSwitchoverListener) {
|
||||
}
|
||||
|
||||
public void setMax(int i) {
|
||||
if (this.k) {
|
||||
return;
|
||||
}
|
||||
SeekBar seekBar = this.b;
|
||||
if (seekBar != null) {
|
||||
seekBar.setMax(i);
|
||||
}
|
||||
b(i);
|
||||
if (i > 0) {
|
||||
this.k = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void setMediaPlayerControl(BDCloudVideoView bDCloudVideoView) {
|
||||
this.g = bDCloudVideoView;
|
||||
}
|
||||
|
||||
public void setProgress(int i) {
|
||||
if (this.b != null) {
|
||||
this.f = this.g.getCurrentPosition();
|
||||
this.b.setProgress(i);
|
||||
}
|
||||
}
|
||||
|
||||
public void setTitle(String str) {
|
||||
this.j.setVisibility(0);
|
||||
this.i.setVisibility(0);
|
||||
this.i.setText(str);
|
||||
}
|
||||
|
||||
private void c() {
|
||||
View inflate = ((LayoutInflater) getContext().getSystemService("layout_inflater")).inflate(R.layout.layout_simple_controller, this);
|
||||
this.i = (TextView) inflate.findViewById(R.id.tv_content);
|
||||
this.j = inflate.findViewById(R.id.view_background);
|
||||
this.a = (TextView) inflate.findViewById(R.id.tv_position);
|
||||
this.b = (SeekBar) inflate.findViewById(R.id.seekbar);
|
||||
this.b.setMax(0);
|
||||
this.c = (TextView) inflate.findViewById(R.id.tv_duration);
|
||||
this.b.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { // from class: com.ubt.jimu.widgets.player.bar.SimpleMediaController.1
|
||||
@Override // android.widget.SeekBar.OnSeekBarChangeListener
|
||||
public void onProgressChanged(SeekBar seekBar, int i, boolean z) {
|
||||
SimpleMediaController.this.c(i);
|
||||
}
|
||||
|
||||
@Override // android.widget.SeekBar.OnSeekBarChangeListener
|
||||
public void onStartTrackingTouch(SeekBar seekBar) {
|
||||
SimpleMediaController.this.h = true;
|
||||
}
|
||||
|
||||
@Override // android.widget.SeekBar.OnSeekBarChangeListener
|
||||
public void onStopTrackingTouch(SeekBar seekBar) {
|
||||
if (SimpleMediaController.this.g.getDuration() > 0) {
|
||||
SimpleMediaController.this.l = seekBar.getProgress();
|
||||
if (SimpleMediaController.this.g != null) {
|
||||
SimpleMediaController.this.g.seekTo(seekBar.getProgress());
|
||||
}
|
||||
}
|
||||
SimpleMediaController.this.h = false;
|
||||
}
|
||||
});
|
||||
a(false);
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public void d() {
|
||||
Timer timer = this.d;
|
||||
if (timer != null) {
|
||||
timer.cancel();
|
||||
this.d = null;
|
||||
}
|
||||
this.d = new Timer();
|
||||
this.d.schedule(new TimerTask() { // from class: com.ubt.jimu.widgets.player.bar.SimpleMediaController.3
|
||||
@Override // java.util.TimerTask, java.lang.Runnable
|
||||
public void run() {
|
||||
SimpleMediaController.this.e.post(new Runnable() { // from class: com.ubt.jimu.widgets.player.bar.SimpleMediaController.3.1
|
||||
@Override // java.lang.Runnable
|
||||
public void run() {
|
||||
SimpleMediaController.this.b();
|
||||
}
|
||||
});
|
||||
}
|
||||
}, 0L, 500L);
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public void e() {
|
||||
Timer timer = this.d;
|
||||
if (timer != null) {
|
||||
timer.cancel();
|
||||
this.d = null;
|
||||
}
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public void b(int i) {
|
||||
TextView textView = this.c;
|
||||
if (textView != null) {
|
||||
textView.setText(a(i));
|
||||
}
|
||||
}
|
||||
|
||||
public void a() {
|
||||
final BDCloudVideoView.PlayerState currentPlayerState = this.g.getCurrentPlayerState();
|
||||
ALog.a("SimpleMediaController").d("mediaController: changeStatus=" + currentPlayerState.name());
|
||||
this.k = false;
|
||||
this.e.post(new Runnable() { // from class: com.ubt.jimu.widgets.player.bar.SimpleMediaController.2
|
||||
@Override // java.lang.Runnable
|
||||
public void run() {
|
||||
BDCloudVideoView.PlayerState playerState = currentPlayerState;
|
||||
if (playerState == BDCloudVideoView.PlayerState.STATE_IDLE || playerState == BDCloudVideoView.PlayerState.STATE_ERROR) {
|
||||
SimpleMediaController.this.e();
|
||||
SimpleMediaController.this.b.setEnabled(false);
|
||||
SimpleMediaController simpleMediaController = SimpleMediaController.this;
|
||||
simpleMediaController.c(simpleMediaController.g == null ? 0 : SimpleMediaController.this.g.getCurrentPosition());
|
||||
SimpleMediaController simpleMediaController2 = SimpleMediaController.this;
|
||||
simpleMediaController2.b(simpleMediaController2.g != null ? SimpleMediaController.this.g.getDuration() : 0);
|
||||
return;
|
||||
}
|
||||
if (playerState == BDCloudVideoView.PlayerState.STATE_PREPARING) {
|
||||
SimpleMediaController.this.b.setEnabled(false);
|
||||
return;
|
||||
}
|
||||
if (playerState == BDCloudVideoView.PlayerState.STATE_PREPARED) {
|
||||
SimpleMediaController.this.b.setEnabled(true);
|
||||
SimpleMediaController simpleMediaController3 = SimpleMediaController.this;
|
||||
simpleMediaController3.b(simpleMediaController3.g != null ? SimpleMediaController.this.g.getDuration() : 0);
|
||||
SimpleMediaController.this.b.setMax(SimpleMediaController.this.g.getDuration());
|
||||
return;
|
||||
}
|
||||
if (playerState == BDCloudVideoView.PlayerState.STATE_PLAYBACK_COMPLETED) {
|
||||
SimpleMediaController.this.e();
|
||||
SimpleMediaController.this.b.setProgress(SimpleMediaController.this.b.getMax());
|
||||
SimpleMediaController.this.b.setEnabled(false);
|
||||
} else if (playerState != BDCloudVideoView.PlayerState.STATE_PLAYING) {
|
||||
BDCloudVideoView.PlayerState playerState2 = BDCloudVideoView.PlayerState.STATE_PAUSED;
|
||||
} else {
|
||||
SimpleMediaController.this.d();
|
||||
SimpleMediaController.this.b.setEnabled(true);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public boolean b() {
|
||||
int duration;
|
||||
BDCloudVideoView bDCloudVideoView = this.g;
|
||||
if (bDCloudVideoView == null) {
|
||||
return false;
|
||||
}
|
||||
long currentPosition = bDCloudVideoView.getCurrentPosition();
|
||||
long j = this.l;
|
||||
if (currentPosition > 0 && !getIsDragging()) {
|
||||
this.l = currentPosition;
|
||||
}
|
||||
if (getVisibility() == 0 && !getIsDragging() && (duration = this.g.getDuration()) > 0) {
|
||||
setMax(duration);
|
||||
if (j != currentPosition) {
|
||||
setProgress((int) currentPosition);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public SimpleMediaController(Context context) {
|
||||
super(context);
|
||||
this.e = new Handler(Looper.getMainLooper());
|
||||
this.g = null;
|
||||
this.h = false;
|
||||
this.k = false;
|
||||
this.l = 0L;
|
||||
c();
|
||||
}
|
||||
|
||||
private String a(int i) {
|
||||
int i2 = i / 1000;
|
||||
int i3 = i2 / 3600;
|
||||
int i4 = (i2 % 3600) / 60;
|
||||
int i5 = i2 % 60;
|
||||
return i3 != 0 ? String.format("%02d:%02d:%02d", Integer.valueOf(i3), Integer.valueOf(i4), Integer.valueOf(i5)) : String.format("%02d:%02d", Integer.valueOf(i4), Integer.valueOf(i5));
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public void c(int i) {
|
||||
TextView textView = this.a;
|
||||
if (textView != null) {
|
||||
textView.setText(a(i));
|
||||
}
|
||||
}
|
||||
|
||||
public void a(boolean z) {
|
||||
this.b.setEnabled(z);
|
||||
}
|
||||
|
||||
public void a(final long j) {
|
||||
this.e.post(new Runnable() { // from class: com.ubt.jimu.widgets.player.bar.SimpleMediaController.4
|
||||
@Override // java.lang.Runnable
|
||||
public void run() {
|
||||
SimpleMediaController.this.setCache((int) j);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
119
sources/com/ubt/jimu/widgets/player/info/VideoInfo.java
Normal file
119
sources/com/ubt/jimu/widgets/player/info/VideoInfo.java
Normal file
@@ -0,0 +1,119 @@
|
||||
package com.ubt.jimu.widgets.player.info;
|
||||
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
import com.tencent.open.SocialConstants;
|
||||
import org.json.JSONObject;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class VideoInfo implements Parcelable {
|
||||
public static final Parcelable.Creator<VideoInfo> CREATOR = new Parcelable.Creator<VideoInfo>() { // from class: com.ubt.jimu.widgets.player.info.VideoInfo.1
|
||||
/* JADX WARN: Can't rename method to resolve collision */
|
||||
@Override // android.os.Parcelable.Creator
|
||||
public VideoInfo createFromParcel(Parcel parcel) {
|
||||
String readString = parcel.readString();
|
||||
String readString2 = parcel.readString();
|
||||
String readString3 = parcel.readString();
|
||||
boolean[] zArr = new boolean[1];
|
||||
parcel.readBooleanArray(zArr);
|
||||
VideoInfo videoInfo = new VideoInfo(readString, readString2);
|
||||
videoInfo.setImageUrl(readString3);
|
||||
videoInfo.setCanDelete(zArr[0]);
|
||||
return videoInfo;
|
||||
}
|
||||
|
||||
/* JADX WARN: Can't rename method to resolve collision */
|
||||
@Override // android.os.Parcelable.Creator
|
||||
public VideoInfo[] newArray(int i) {
|
||||
return new VideoInfo[i];
|
||||
}
|
||||
};
|
||||
private String title;
|
||||
private String url;
|
||||
private String imageUrl = "";
|
||||
private boolean canDelete = true;
|
||||
|
||||
public VideoInfo(String str, String str2) {
|
||||
this.title = "";
|
||||
this.url = "";
|
||||
this.title = str;
|
||||
this.url = str2;
|
||||
}
|
||||
|
||||
public static VideoInfo fromJson(JSONObject jSONObject) {
|
||||
VideoInfo videoInfo;
|
||||
try {
|
||||
videoInfo = new VideoInfo(jSONObject.getString("title"), jSONObject.getString("url"));
|
||||
try {
|
||||
videoInfo.setImageUrl(jSONObject.optString(SocialConstants.PARAM_IMAGE_URL, ""));
|
||||
videoInfo.setCanDelete(jSONObject.optBoolean("canDelete", true));
|
||||
} catch (Exception e) {
|
||||
e = e;
|
||||
e.printStackTrace();
|
||||
return videoInfo;
|
||||
}
|
||||
} catch (Exception e2) {
|
||||
e = e2;
|
||||
videoInfo = null;
|
||||
}
|
||||
return videoInfo;
|
||||
}
|
||||
|
||||
@Override // android.os.Parcelable
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public String getImageUrl() {
|
||||
return this.imageUrl;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return this.title;
|
||||
}
|
||||
|
||||
public String getUrl() {
|
||||
return this.url;
|
||||
}
|
||||
|
||||
public boolean isCanDelete() {
|
||||
return this.canDelete;
|
||||
}
|
||||
|
||||
public void setCanDelete(boolean z) {
|
||||
this.canDelete = z;
|
||||
}
|
||||
|
||||
public void setImageUrl(String str) {
|
||||
this.imageUrl = str;
|
||||
}
|
||||
|
||||
public void setTitle(String str) {
|
||||
this.title = str;
|
||||
}
|
||||
|
||||
public void setUrl(String str) {
|
||||
this.url = str;
|
||||
}
|
||||
|
||||
public JSONObject toJson() {
|
||||
JSONObject jSONObject = new JSONObject();
|
||||
try {
|
||||
jSONObject.put("url", this.url);
|
||||
jSONObject.put("title", this.title);
|
||||
jSONObject.put(SocialConstants.PARAM_IMAGE_URL, this.imageUrl);
|
||||
jSONObject.put("canDelete", this.canDelete);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return jSONObject;
|
||||
}
|
||||
|
||||
@Override // android.os.Parcelable
|
||||
public void writeToParcel(Parcel parcel, int i) {
|
||||
parcel.writeString(this.title);
|
||||
parcel.writeString(this.url);
|
||||
parcel.writeString(this.imageUrl);
|
||||
parcel.writeBooleanArray(new boolean[]{this.canDelete});
|
||||
}
|
||||
}
|
1087
sources/com/ubt/jimu/widgets/player/widget/BDCloudVideoView.java
Normal file
1087
sources/com/ubt/jimu/widgets/player/widget/BDCloudVideoView.java
Normal file
File diff suppressed because it is too large
Load Diff
43
sources/com/ubt/jimu/widgets/player/widget/IRenderView.java
Normal file
43
sources/com/ubt/jimu/widgets/player/widget/IRenderView.java
Normal file
@@ -0,0 +1,43 @@
|
||||
package com.ubt.jimu.widgets.player.widget;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
import android.view.View;
|
||||
import com.baidu.cloud.media.player.IMediaPlayer;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public interface IRenderView {
|
||||
|
||||
public interface IRenderCallback {
|
||||
void a(ISurfaceHolder iSurfaceHolder);
|
||||
|
||||
void a(ISurfaceHolder iSurfaceHolder, int i, int i2);
|
||||
|
||||
void a(ISurfaceHolder iSurfaceHolder, int i, int i2, int i3);
|
||||
}
|
||||
|
||||
public interface ISurfaceHolder {
|
||||
IRenderView a();
|
||||
|
||||
void a(IMediaPlayer iMediaPlayer);
|
||||
}
|
||||
|
||||
void a(int i, int i2);
|
||||
|
||||
void a(IRenderCallback iRenderCallback);
|
||||
|
||||
boolean a();
|
||||
|
||||
void b(int i, int i2);
|
||||
|
||||
void b(IRenderCallback iRenderCallback);
|
||||
|
||||
Bitmap getBitmap();
|
||||
|
||||
View getView();
|
||||
|
||||
void release();
|
||||
|
||||
void setAspectRatio(int i);
|
||||
|
||||
void setVideoRotation(int i);
|
||||
}
|
@@ -0,0 +1,78 @@
|
||||
package com.ubt.jimu.widgets.player.widget;
|
||||
|
||||
import android.view.View;
|
||||
import java.lang.ref.WeakReference;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public final class MeasureHelper {
|
||||
private int a;
|
||||
private int b;
|
||||
private int c;
|
||||
private int d;
|
||||
private int e;
|
||||
private int f;
|
||||
private int g;
|
||||
private int h = 0;
|
||||
|
||||
public MeasureHelper(View view) {
|
||||
new WeakReference(view);
|
||||
}
|
||||
|
||||
/* JADX WARN: Code restructure failed: missing block: B:32:0x00ab, code lost:
|
||||
|
||||
if (r4 != false) goto L52;
|
||||
*/
|
||||
/* JADX WARN: Code restructure failed: missing block: B:33:0x00b0, code lost:
|
||||
|
||||
r12 = (int) (r0 / r1);
|
||||
*/
|
||||
/* JADX WARN: Code restructure failed: missing block: B:34:0x00b4, code lost:
|
||||
|
||||
r11 = (int) (r3 * r1);
|
||||
*/
|
||||
/* JADX WARN: Code restructure failed: missing block: B:35:0x00ae, code lost:
|
||||
|
||||
if (r4 != false) goto L51;
|
||||
*/
|
||||
/* JADX WARN: Code restructure failed: missing block: B:64:0x00f4, code lost:
|
||||
|
||||
if (r1 > r11) goto L83;
|
||||
*/
|
||||
/*
|
||||
Code decompiled incorrectly, please refer to instructions dump.
|
||||
To view partially-correct code enable 'Show inconsistent code' option in preferences
|
||||
*/
|
||||
public void a(int r11, int r12) {
|
||||
/*
|
||||
Method dump skipped, instructions count: 288
|
||||
To view this dump change 'Code comments level' option to 'DEBUG'
|
||||
*/
|
||||
throw new UnsupportedOperationException("Method not decompiled: com.ubt.jimu.widgets.player.widget.MeasureHelper.a(int, int):void");
|
||||
}
|
||||
|
||||
public void b(int i, int i2) {
|
||||
this.c = i;
|
||||
this.d = i2;
|
||||
}
|
||||
|
||||
public void c(int i, int i2) {
|
||||
this.a = i;
|
||||
this.b = i2;
|
||||
}
|
||||
|
||||
public void b(int i) {
|
||||
this.e = i;
|
||||
}
|
||||
|
||||
public int b() {
|
||||
return this.f;
|
||||
}
|
||||
|
||||
public int a() {
|
||||
return this.g;
|
||||
}
|
||||
|
||||
public void a(int i) {
|
||||
this.h = i;
|
||||
}
|
||||
}
|
@@ -0,0 +1,217 @@
|
||||
package com.ubt.jimu.widgets.player.widget;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.os.Build;
|
||||
import android.util.Log;
|
||||
import android.view.SurfaceHolder;
|
||||
import android.view.SurfaceView;
|
||||
import android.view.View;
|
||||
import android.view.accessibility.AccessibilityEvent;
|
||||
import android.view.accessibility.AccessibilityNodeInfo;
|
||||
import com.baidu.cloud.media.player.IMediaPlayer;
|
||||
import com.ubt.jimu.widgets.player.widget.IRenderView;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class SurfaceRenderView extends SurfaceView implements IRenderView {
|
||||
private MeasureHelper a;
|
||||
private SurfaceCallback b;
|
||||
|
||||
private static final class InternalSurfaceHolder implements IRenderView.ISurfaceHolder {
|
||||
private SurfaceRenderView a;
|
||||
private SurfaceHolder b;
|
||||
|
||||
public InternalSurfaceHolder(SurfaceRenderView surfaceRenderView, SurfaceHolder surfaceHolder) {
|
||||
this.a = surfaceRenderView;
|
||||
this.b = surfaceHolder;
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.widgets.player.widget.IRenderView.ISurfaceHolder
|
||||
public void a(IMediaPlayer iMediaPlayer) {
|
||||
if (iMediaPlayer != null) {
|
||||
iMediaPlayer.setDisplay(this.b);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.widgets.player.widget.IRenderView.ISurfaceHolder
|
||||
public IRenderView a() {
|
||||
return this.a;
|
||||
}
|
||||
}
|
||||
|
||||
private static final class SurfaceCallback implements SurfaceHolder.Callback {
|
||||
private SurfaceHolder a;
|
||||
private boolean b;
|
||||
private int c;
|
||||
private int d;
|
||||
private int e;
|
||||
private WeakReference<SurfaceRenderView> f;
|
||||
private Map<IRenderView.IRenderCallback, Object> g = new ConcurrentHashMap();
|
||||
|
||||
public SurfaceCallback(SurfaceRenderView surfaceRenderView) {
|
||||
this.f = new WeakReference<>(surfaceRenderView);
|
||||
}
|
||||
|
||||
public void a(IRenderView.IRenderCallback iRenderCallback) {
|
||||
InternalSurfaceHolder internalSurfaceHolder;
|
||||
this.g.put(iRenderCallback, iRenderCallback);
|
||||
if (this.a != null) {
|
||||
internalSurfaceHolder = new InternalSurfaceHolder(this.f.get(), this.a);
|
||||
iRenderCallback.a(internalSurfaceHolder, this.d, this.e);
|
||||
} else {
|
||||
internalSurfaceHolder = null;
|
||||
}
|
||||
if (this.b) {
|
||||
if (internalSurfaceHolder == null) {
|
||||
internalSurfaceHolder = new InternalSurfaceHolder(this.f.get(), this.a);
|
||||
}
|
||||
iRenderCallback.a(internalSurfaceHolder, this.c, this.d, this.e);
|
||||
}
|
||||
}
|
||||
|
||||
public void b(IRenderView.IRenderCallback iRenderCallback) {
|
||||
this.g.remove(iRenderCallback);
|
||||
}
|
||||
|
||||
@Override // android.view.SurfaceHolder.Callback
|
||||
public void surfaceChanged(SurfaceHolder surfaceHolder, int i, int i2, int i3) {
|
||||
this.a = surfaceHolder;
|
||||
this.b = true;
|
||||
this.c = i;
|
||||
this.d = i2;
|
||||
this.e = i3;
|
||||
InternalSurfaceHolder internalSurfaceHolder = new InternalSurfaceHolder(this.f.get(), this.a);
|
||||
Iterator<IRenderView.IRenderCallback> it = this.g.keySet().iterator();
|
||||
while (it.hasNext()) {
|
||||
it.next().a(internalSurfaceHolder, i, i2, i3);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.view.SurfaceHolder.Callback
|
||||
public void surfaceCreated(SurfaceHolder surfaceHolder) {
|
||||
this.a = surfaceHolder;
|
||||
this.b = false;
|
||||
this.c = 0;
|
||||
this.d = 0;
|
||||
this.e = 0;
|
||||
Log.d("SurfaceRenderView", "surfaceCreated: " + surfaceHolder.getSurface());
|
||||
InternalSurfaceHolder internalSurfaceHolder = new InternalSurfaceHolder(this.f.get(), this.a);
|
||||
Iterator<IRenderView.IRenderCallback> it = this.g.keySet().iterator();
|
||||
while (it.hasNext()) {
|
||||
it.next().a(internalSurfaceHolder, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.view.SurfaceHolder.Callback
|
||||
public void surfaceDestroyed(SurfaceHolder surfaceHolder) {
|
||||
this.a = null;
|
||||
this.b = false;
|
||||
this.c = 0;
|
||||
this.d = 0;
|
||||
this.e = 0;
|
||||
InternalSurfaceHolder internalSurfaceHolder = new InternalSurfaceHolder(this.f.get(), this.a);
|
||||
Iterator<IRenderView.IRenderCallback> it = this.g.keySet().iterator();
|
||||
while (it.hasNext()) {
|
||||
it.next().a(internalSurfaceHolder);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public SurfaceRenderView(Context context) {
|
||||
super(context);
|
||||
a(context);
|
||||
}
|
||||
|
||||
private void a(Context context) {
|
||||
this.a = new MeasureHelper(this);
|
||||
this.b = new SurfaceCallback(this);
|
||||
getHolder().addCallback(this.b);
|
||||
getHolder().setType(0);
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.widgets.player.widget.IRenderView
|
||||
public boolean a() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.widgets.player.widget.IRenderView
|
||||
public void b(int i, int i2) {
|
||||
if (i <= 0 || i2 <= 0) {
|
||||
return;
|
||||
}
|
||||
this.a.b(i, i2);
|
||||
requestLayout();
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.widgets.player.widget.IRenderView
|
||||
public Bitmap getBitmap() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.widgets.player.widget.IRenderView
|
||||
public View getView() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override // android.view.View
|
||||
@TargetApi(14)
|
||||
public void onInitializeAccessibilityEvent(AccessibilityEvent accessibilityEvent) {
|
||||
super.onInitializeAccessibilityEvent(accessibilityEvent);
|
||||
accessibilityEvent.setClassName(SurfaceRenderView.class.getName());
|
||||
}
|
||||
|
||||
@Override // android.view.View
|
||||
@TargetApi(14)
|
||||
public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo accessibilityNodeInfo) {
|
||||
super.onInitializeAccessibilityNodeInfo(accessibilityNodeInfo);
|
||||
if (Build.VERSION.SDK_INT >= 14) {
|
||||
accessibilityNodeInfo.setClassName(SurfaceRenderView.class.getName());
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.view.SurfaceView, android.view.View
|
||||
protected void onMeasure(int i, int i2) {
|
||||
this.a.a(i, i2);
|
||||
setMeasuredDimension(this.a.b(), this.a.a());
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.widgets.player.widget.IRenderView
|
||||
public void release() {
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.widgets.player.widget.IRenderView
|
||||
public void setAspectRatio(int i) {
|
||||
this.a.a(i);
|
||||
requestLayout();
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.widgets.player.widget.IRenderView
|
||||
public void setVideoRotation(int i) {
|
||||
Log.e("", "SurfaceView doesn't support rotation (" + i + ")!\n");
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.widgets.player.widget.IRenderView
|
||||
public void b(IRenderView.IRenderCallback iRenderCallback) {
|
||||
this.b.a(iRenderCallback);
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.widgets.player.widget.IRenderView
|
||||
public void a(int i, int i2) {
|
||||
if (i <= 0 || i2 <= 0) {
|
||||
return;
|
||||
}
|
||||
this.a.c(i, i2);
|
||||
getHolder().setFixedSize(i, i2);
|
||||
requestLayout();
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.widgets.player.widget.IRenderView
|
||||
public void a(IRenderView.IRenderCallback iRenderCallback) {
|
||||
this.b.b(iRenderCallback);
|
||||
}
|
||||
}
|
@@ -0,0 +1,266 @@
|
||||
package com.ubt.jimu.widgets.player.widget;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.content.Context;
|
||||
import android.graphics.SurfaceTexture;
|
||||
import android.util.Log;
|
||||
import android.view.Surface;
|
||||
import android.view.TextureView;
|
||||
import android.view.View;
|
||||
import android.view.accessibility.AccessibilityEvent;
|
||||
import android.view.accessibility.AccessibilityNodeInfo;
|
||||
import com.baidu.cloud.media.player.IMediaPlayer;
|
||||
import com.ubt.jimu.widgets.player.widget.IRenderView;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
@TargetApi(14)
|
||||
/* loaded from: classes2.dex */
|
||||
public class TextureRenderView extends TextureView implements IRenderView {
|
||||
private MeasureHelper a;
|
||||
private int b;
|
||||
private SurfaceTexture c;
|
||||
private SurfaceCallback d;
|
||||
|
||||
private static final class SurfaceCallback implements TextureView.SurfaceTextureListener {
|
||||
private SurfaceTexture a;
|
||||
private boolean b;
|
||||
private int c;
|
||||
private int d;
|
||||
private WeakReference<TextureRenderView> f;
|
||||
private volatile boolean e = false;
|
||||
private Map<IRenderView.IRenderCallback, Object> g = new ConcurrentHashMap();
|
||||
|
||||
public SurfaceCallback(TextureRenderView textureRenderView) {
|
||||
this.f = new WeakReference<>(textureRenderView);
|
||||
}
|
||||
|
||||
public void a(boolean z) {
|
||||
this.e = z;
|
||||
}
|
||||
|
||||
public void b(IRenderView.IRenderCallback iRenderCallback) {
|
||||
this.g.remove(iRenderCallback);
|
||||
}
|
||||
|
||||
@Override // android.view.TextureView.SurfaceTextureListener
|
||||
@TargetApi(16)
|
||||
public void onSurfaceTextureAvailable(SurfaceTexture surfaceTexture, int i, int i2) {
|
||||
this.a = surfaceTexture;
|
||||
if (this.f.get() == null) {
|
||||
Log.e("TextureRenderView", "!!!!!Too bad, textureview in callback is released. function will not work normally");
|
||||
} else if (this.f.get().getLastSurfaceTexture() == null) {
|
||||
this.f.get().setLastSurfaceTexture(surfaceTexture);
|
||||
}
|
||||
this.b = false;
|
||||
this.c = 0;
|
||||
this.d = 0;
|
||||
InternalSurfaceHolder internalSurfaceHolder = new InternalSurfaceHolder(this.f.get());
|
||||
Iterator<IRenderView.IRenderCallback> it = this.g.keySet().iterator();
|
||||
while (it.hasNext()) {
|
||||
it.next().a(internalSurfaceHolder, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.view.TextureView.SurfaceTextureListener
|
||||
public boolean onSurfaceTextureDestroyed(SurfaceTexture surfaceTexture) {
|
||||
this.a = surfaceTexture;
|
||||
this.b = false;
|
||||
this.c = 0;
|
||||
this.d = 0;
|
||||
InternalSurfaceHolder internalSurfaceHolder = new InternalSurfaceHolder(this.f.get());
|
||||
Iterator<IRenderView.IRenderCallback> it = this.g.keySet().iterator();
|
||||
while (it.hasNext()) {
|
||||
it.next().a(internalSurfaceHolder);
|
||||
}
|
||||
return this.e;
|
||||
}
|
||||
|
||||
@Override // android.view.TextureView.SurfaceTextureListener
|
||||
public void onSurfaceTextureSizeChanged(SurfaceTexture surfaceTexture, int i, int i2) {
|
||||
this.a = surfaceTexture;
|
||||
this.b = true;
|
||||
this.c = i;
|
||||
this.d = i2;
|
||||
InternalSurfaceHolder internalSurfaceHolder = new InternalSurfaceHolder(this.f.get());
|
||||
Iterator<IRenderView.IRenderCallback> it = this.g.keySet().iterator();
|
||||
while (it.hasNext()) {
|
||||
it.next().a(internalSurfaceHolder, 0, i, i2);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.view.TextureView.SurfaceTextureListener
|
||||
public void onSurfaceTextureUpdated(SurfaceTexture surfaceTexture) {
|
||||
}
|
||||
|
||||
public void a(IRenderView.IRenderCallback iRenderCallback) {
|
||||
InternalSurfaceHolder internalSurfaceHolder;
|
||||
this.g.put(iRenderCallback, iRenderCallback);
|
||||
if (this.a != null) {
|
||||
internalSurfaceHolder = new InternalSurfaceHolder(this.f.get());
|
||||
iRenderCallback.a(internalSurfaceHolder, this.c, this.d);
|
||||
} else {
|
||||
internalSurfaceHolder = null;
|
||||
}
|
||||
if (this.b) {
|
||||
if (internalSurfaceHolder == null) {
|
||||
internalSurfaceHolder = new InternalSurfaceHolder(this.f.get());
|
||||
}
|
||||
iRenderCallback.a(internalSurfaceHolder, 0, this.c, this.d);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public TextureRenderView(Context context) {
|
||||
super(context);
|
||||
this.b = 0;
|
||||
a(context);
|
||||
}
|
||||
|
||||
private void a(Context context) {
|
||||
this.a = new MeasureHelper(this);
|
||||
this.d = new SurfaceCallback(this);
|
||||
setSurfaceTextureListener(this.d);
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.widgets.player.widget.IRenderView
|
||||
public boolean a() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.widgets.player.widget.IRenderView
|
||||
public void b(int i, int i2) {
|
||||
if (i <= 0 || i2 <= 0) {
|
||||
return;
|
||||
}
|
||||
this.a.b(i, i2);
|
||||
requestLayout();
|
||||
}
|
||||
|
||||
public int getCurrentMediaPlayerCode() {
|
||||
return this.b;
|
||||
}
|
||||
|
||||
public SurfaceTexture getLastSurfaceTexture() {
|
||||
return this.c;
|
||||
}
|
||||
|
||||
public IRenderView.ISurfaceHolder getSurfaceHolder() {
|
||||
return new InternalSurfaceHolder(this);
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.widgets.player.widget.IRenderView
|
||||
public View getView() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override // android.view.View
|
||||
protected void onDetachedFromWindow() {
|
||||
super.onDetachedFromWindow();
|
||||
Log.d("TextureRenderView", "onDetachedFromWindow");
|
||||
}
|
||||
|
||||
@Override // android.view.View
|
||||
public void onInitializeAccessibilityEvent(AccessibilityEvent accessibilityEvent) {
|
||||
super.onInitializeAccessibilityEvent(accessibilityEvent);
|
||||
accessibilityEvent.setClassName(TextureRenderView.class.getName());
|
||||
}
|
||||
|
||||
@Override // android.view.View
|
||||
public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo accessibilityNodeInfo) {
|
||||
super.onInitializeAccessibilityNodeInfo(accessibilityNodeInfo);
|
||||
accessibilityNodeInfo.setClassName(TextureRenderView.class.getName());
|
||||
}
|
||||
|
||||
@Override // android.view.View
|
||||
protected void onMeasure(int i, int i2) {
|
||||
this.a.a(i, i2);
|
||||
setMeasuredDimension(this.a.b(), this.a.a());
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.widgets.player.widget.IRenderView
|
||||
@TargetApi(16)
|
||||
public void release() {
|
||||
if (this.c != null) {
|
||||
if (isAvailable()) {
|
||||
this.d.a(true);
|
||||
} else {
|
||||
this.c.release();
|
||||
this.c = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.widgets.player.widget.IRenderView
|
||||
public void setAspectRatio(int i) {
|
||||
this.a.a(i);
|
||||
requestLayout();
|
||||
}
|
||||
|
||||
public void setCurrentMediaPlayerCode(int i) {
|
||||
this.b = i;
|
||||
}
|
||||
|
||||
public void setLastSurfaceTexture(SurfaceTexture surfaceTexture) {
|
||||
this.c = surfaceTexture;
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.widgets.player.widget.IRenderView
|
||||
public void setVideoRotation(int i) {
|
||||
this.a.b(i);
|
||||
setRotation(i);
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.widgets.player.widget.IRenderView
|
||||
public void b(IRenderView.IRenderCallback iRenderCallback) {
|
||||
this.d.a(iRenderCallback);
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.widgets.player.widget.IRenderView
|
||||
public void a(int i, int i2) {
|
||||
if (i <= 0 || i2 <= 0) {
|
||||
return;
|
||||
}
|
||||
this.a.c(i, i2);
|
||||
requestLayout();
|
||||
}
|
||||
|
||||
private static final class InternalSurfaceHolder implements IRenderView.ISurfaceHolder {
|
||||
private TextureRenderView a;
|
||||
|
||||
public InternalSurfaceHolder(TextureRenderView textureRenderView) {
|
||||
this.a = textureRenderView;
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.widgets.player.widget.IRenderView.ISurfaceHolder
|
||||
@TargetApi(16)
|
||||
public void a(IMediaPlayer iMediaPlayer) {
|
||||
if (iMediaPlayer == null || this.a.getSurfaceTexture() == null) {
|
||||
return;
|
||||
}
|
||||
if (iMediaPlayer.hashCode() != this.a.getCurrentMediaPlayerCode()) {
|
||||
iMediaPlayer.setSurface(b());
|
||||
} else if (!this.a.getLastSurfaceTexture().equals(this.a.getSurfaceTexture())) {
|
||||
TextureRenderView textureRenderView = this.a;
|
||||
textureRenderView.setSurfaceTexture(textureRenderView.getLastSurfaceTexture());
|
||||
}
|
||||
this.a.setCurrentMediaPlayerCode(iMediaPlayer.hashCode());
|
||||
}
|
||||
|
||||
public Surface b() {
|
||||
return new Surface(this.a.getSurfaceTexture());
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.widgets.player.widget.IRenderView.ISurfaceHolder
|
||||
public IRenderView a() {
|
||||
return this.a;
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.widgets.player.widget.IRenderView
|
||||
public void a(IRenderView.IRenderCallback iRenderCallback) {
|
||||
this.d.b(iRenderCallback);
|
||||
}
|
||||
}
|
@@ -0,0 +1,47 @@
|
||||
package com.ubt.jimu.widgets.player.widget.datasource;
|
||||
|
||||
import android.util.Log;
|
||||
import com.baidu.cloud.media.player.misc.IMediaDataSource;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class ExtDataSourceProvider implements IMediaDataSource {
|
||||
private InputStream a;
|
||||
private long b = 0;
|
||||
|
||||
public ExtDataSourceProvider(InputStream inputStream) {
|
||||
this.a = inputStream;
|
||||
}
|
||||
|
||||
@Override // com.baidu.cloud.media.player.misc.IMediaDataSource
|
||||
public void close() throws IOException {
|
||||
InputStream inputStream = this.a;
|
||||
if (inputStream != null) {
|
||||
inputStream.close();
|
||||
}
|
||||
this.a = null;
|
||||
}
|
||||
|
||||
@Override // com.baidu.cloud.media.player.misc.IMediaDataSource
|
||||
public long getSize() throws IOException {
|
||||
Log.w("ExtDataSourceProvider", "data available length: " + this.a.available());
|
||||
return this.a.available();
|
||||
}
|
||||
|
||||
@Override // com.baidu.cloud.media.player.misc.IMediaDataSource
|
||||
public int readAt(long j, byte[] bArr, int i, int i2) throws IOException {
|
||||
if (i2 <= 0) {
|
||||
return i2;
|
||||
}
|
||||
if (this.b != j) {
|
||||
this.a.reset();
|
||||
this.b = this.a.skip(j);
|
||||
Log.w("ExtDataSourceProvider", "Seek pos to " + this.b);
|
||||
}
|
||||
int read = this.a.read(bArr, i, i2);
|
||||
this.b += read;
|
||||
Log.w("ExtDataSourceProvider", "Current Pos " + this.b + " read length: " + read);
|
||||
return read;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user