|
|
|
@ -1,6 +1,9 @@
|
|
|
|
|
package com.yinuo.safetywatcher.player;
|
|
|
|
|
package com.yinuo.safetywatcher.watcher.player;
|
|
|
|
|
|
|
|
|
|
import android.app.Activity;
|
|
|
|
|
import android.content.Context;
|
|
|
|
|
import android.graphics.drawable.Drawable;
|
|
|
|
|
import android.graphics.drawable.StateListDrawable;
|
|
|
|
|
import android.os.Handler;
|
|
|
|
|
import android.os.Message;
|
|
|
|
|
import android.util.AttributeSet;
|
|
|
|
@ -18,6 +21,8 @@ import android.widget.SeekBar;
|
|
|
|
|
import android.widget.SeekBar.OnSeekBarChangeListener;
|
|
|
|
|
import android.widget.TextView;
|
|
|
|
|
|
|
|
|
|
import androidx.appcompat.content.res.AppCompatResources;
|
|
|
|
|
|
|
|
|
|
import com.yinuo.safetywatcher.R;
|
|
|
|
|
|
|
|
|
|
import java.lang.ref.WeakReference;
|
|
|
|
@ -56,6 +61,7 @@ public class VideoControllerView extends FrameLayout implements IMediaController
|
|
|
|
|
private TextView mCurrentTime; // 当前播放时间点
|
|
|
|
|
private TextView mEndTime; // 总时长
|
|
|
|
|
|
|
|
|
|
private View mControlView;
|
|
|
|
|
private ImageButton mPauseButton; // 暂停or开始
|
|
|
|
|
private ImageButton mFastButton; // 快进
|
|
|
|
|
private ImageButton mRewindButton; // 快退
|
|
|
|
@ -227,8 +233,8 @@ public class VideoControllerView extends FrameLayout implements IMediaController
|
|
|
|
|
doPauseResume();
|
|
|
|
|
show(sDefaultTimeout);
|
|
|
|
|
|
|
|
|
|
if (mPauseButton != null) {
|
|
|
|
|
mPauseButton.requestFocus();
|
|
|
|
|
if (mControlView != null) {
|
|
|
|
|
mControlView.requestFocus();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -343,15 +349,15 @@ public class VideoControllerView extends FrameLayout implements IMediaController
|
|
|
|
|
if (!mShowing && mAnchor != null) {
|
|
|
|
|
setProgress();
|
|
|
|
|
|
|
|
|
|
if (mPauseButton != null) {
|
|
|
|
|
mPauseButton.requestFocus();
|
|
|
|
|
if (mControlView != null) {
|
|
|
|
|
mControlView.requestFocus();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
disableUnsupportedButtons();
|
|
|
|
|
|
|
|
|
|
LayoutParams tlp = new LayoutParams(
|
|
|
|
|
ViewGroup.LayoutParams.MATCH_PARENT,
|
|
|
|
|
ViewGroup.LayoutParams.WRAP_CONTENT,
|
|
|
|
|
ViewGroup.LayoutParams.MATCH_PARENT,
|
|
|
|
|
Gravity.BOTTOM);
|
|
|
|
|
|
|
|
|
|
if (mAnchor instanceof ViewGroup) {
|
|
|
|
@ -386,7 +392,7 @@ public class VideoControllerView extends FrameLayout implements IMediaController
|
|
|
|
|
*/
|
|
|
|
|
protected View makeControllerView() {
|
|
|
|
|
LayoutInflater inflate = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
|
|
|
|
mRoot = inflate.inflate(R.layout.media_controller, null);
|
|
|
|
|
mRoot = inflate.inflate(R.layout.media_controller, this, false);
|
|
|
|
|
initControllerView(mRoot);
|
|
|
|
|
return mRoot;
|
|
|
|
|
}
|
|
|
|
@ -394,7 +400,6 @@ public class VideoControllerView extends FrameLayout implements IMediaController
|
|
|
|
|
private void initControllerView(View v) {
|
|
|
|
|
mPauseButton = (ImageButton) v.findViewById(R.id.pause);
|
|
|
|
|
if (mPauseButton != null) {
|
|
|
|
|
mPauseButton.requestFocus();
|
|
|
|
|
mPauseButton.setOnClickListener(mPauseListener);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -434,6 +439,39 @@ public class VideoControllerView extends FrameLayout implements IMediaController
|
|
|
|
|
} else {
|
|
|
|
|
v.findViewById(R.id.seek_bar_container).setVisibility(VISIBLE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
View backArea = v.findViewById(R.id.back_area);
|
|
|
|
|
backArea.setOnClickListener(v1 -> {
|
|
|
|
|
if (mContext instanceof Activity) {
|
|
|
|
|
((Activity) mContext).finish();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
setCommonBg(backArea);
|
|
|
|
|
mControlView = v.findViewById(R.id.control_area);
|
|
|
|
|
mControlView.setOnKeyListener((v12, keyCode, event) -> {
|
|
|
|
|
if (keyCode == KeyEvent.KEYCODE_DPAD_CENTER || keyCode == KeyEvent.KEYCODE_ENTER) {
|
|
|
|
|
if (event.getAction() == KeyEvent.ACTION_DOWN) {
|
|
|
|
|
mPauseButton.performClick();
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
});
|
|
|
|
|
setCommonBg(mControlView);
|
|
|
|
|
mControlView.requestFocus();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void setCommonBg(View v) {
|
|
|
|
|
StateListDrawable bg = new StateListDrawable();
|
|
|
|
|
Drawable currentBackground = v.getBackground();
|
|
|
|
|
Drawable drawable = AppCompatResources.getDrawable(
|
|
|
|
|
mContext,
|
|
|
|
|
com.yinuo.safetywatcher.R.drawable.focus_bg
|
|
|
|
|
);
|
|
|
|
|
bg.addState(new int[]{android.R.attr.state_focused}, drawable);
|
|
|
|
|
bg.addState(new int[]{}, currentBackground);
|
|
|
|
|
v.setBackground(bg);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|