desc:播放本地视频播放器样式调整

main
xiaowusky 2 years ago
parent 5f01cab9fd
commit f854787b2a

@ -100,6 +100,12 @@
android:name=".watcher.ui.NetSettingActivity"
android:exported="false"
android:screenOrientation="landscape" />
<activity
android:name=".player.ProVideoActivity"
android:screenOrientation="landscape"
android:exported="false"
android:theme="@style/FullscreenTheme" />
<activity
android:name=".MainActivity"
android:exported="false"
@ -119,11 +125,6 @@
android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED"
android:resource="@xml/device_filter" />
</activity>
<activity
android:name=".player.ProVideoActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:exported="false"
android:theme="@style/FullscreenTheme" />
</application>
</manifest>

@ -18,14 +18,12 @@ package com.yinuo.safetywatcher.player;
import static android.content.res.Configuration.ORIENTATION_LANDSCAPE;
import android.Manifest;
import android.annotation.SuppressLint;
import android.content.ContentResolver;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.content.pm.PackageManager;
import android.content.res.Configuration;
import android.graphics.Color;
import android.media.MediaScannerConnection;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
@ -37,24 +35,16 @@ import android.view.View;
import android.view.ViewConfiguration;
import android.view.WindowManager;
import android.widget.LinearLayout;
import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.app.ActivityCompat;
import androidx.core.view.ViewCompat;
import androidx.core.view.ViewConfigurationCompat;
import com.bumptech.glide.Glide;
import com.yinuo.safetywatcher.BuildConfig;
import com.yinuo.safetywatcher.databinding.ActivityMainProBinding;
import com.yinuo.safetywatcher.player.utils.FileUtil;
import com.yinuo.safetywatcher.player.utils.SPUtil;
import java.io.File;
import java.text.SimpleDateFormat;
import java.util.Date;
import tv.danmaku.ijk.media.player.IMediaPlayer;
import tv.danmaku.ijk.media.player.IjkMediaPlayer;
@ -73,12 +63,9 @@ public class ProVideoActivity extends AppCompatActivity {
private GestureDetector detector;
private VideoControllerView mediaController;
private MediaScannerConnection mScanner;
private Runnable mSpeedCalcTask;
private int mMode; // 画面模式
@SuppressLint("ClickableViewAccessibility")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@ -145,9 +132,7 @@ public class ProVideoActivity extends AppCompatActivity {
mVideoView.setMediaController(mediaController);
mProgress = mBinding.progress;
mVideoView.setOnInfoListener(new IMediaPlayer.OnInfoListener() {
@Override
public boolean onInfo(IMediaPlayer iMediaPlayer, int arg1, int arg2) {
mVideoView.setOnInfoListener((iMediaPlayer, arg1, arg2) -> {
switch (arg1) {
case IMediaPlayer.MEDIA_INFO_VIDEO_TRACK_LAGGING:
Log.i(TAG, "MEDIA_INFO_VIDEO_TRACK_LAGGING");
@ -158,11 +143,6 @@ public class ProVideoActivity extends AppCompatActivity {
mBinding.surfaceCover.setVisibility(View.GONE);
mBinding.playerContainer.setVisibility(View.GONE);
mBinding.videoView.setVisibility(View.VISIBLE);
mBinding.videoView2.setVisibility(View.VISIBLE);
// 快照
File file = FileUtil.getSnapshotFile(mVideoPath);
mVideoView.takePicture(file.getPath());
break;
case IMediaPlayer.MEDIA_INFO_BUFFERING_START:
Log.i(TAG, "MEDIA_INFO_BUFFERING_START");
@ -197,54 +177,22 @@ public class ProVideoActivity extends AppCompatActivity {
}
return false;
}
});
mVideoView.setOnErrorListener(new IMediaPlayer.OnErrorListener() {
@Override
public boolean onError(IMediaPlayer iMediaPlayer, int i, int i1) {
mVideoView.setOnErrorListener((iMediaPlayer, i, i1) -> {
Log.i(TAG, "播放错误");
mBinding.videoView.setVisibility(View.GONE);
mBinding.videoView2.setVisibility(View.GONE);
mProgress.setVisibility(View.GONE);
mBinding.playerContainer.setVisibility(View.VISIBLE);
mVideoView.postDelayed(new Runnable() {
@Override
public void run() {
mVideoView.reStart();
}
}, 5000);
return true;
}
});
mVideoView.setOnCompletionListener(new IMediaPlayer.OnCompletionListener() {
@Override
public void onCompletion(IMediaPlayer iMediaPlayer) {
mVideoView.setOnCompletionListener(iMediaPlayer -> {
Log.i(TAG, "播放完成");
mProgress.setVisibility(View.GONE);
if (mVideoPath.toLowerCase().startsWith("rtsp") ||
mVideoPath.toLowerCase().startsWith("rtmp") ||
mVideoPath.toLowerCase().startsWith("http")) {
mVideoView.postDelayed(new Runnable() {
@Override
public void run() {
mVideoView.reStart();
}
}, 5000);
}
}
});
mVideoView.setOnPreparedListener(new IMediaPlayer.OnPreparedListener() {
@Override
public void onPrepared(IMediaPlayer iMediaPlayer) {
Log.i(TAG, String.format("onPrepared"));
}
});
mVideoView.setOnPreparedListener(iMediaPlayer -> Log.i(TAG, String.format("onPrepared")));
if (mVideoPath != null) {
mVideoView.setVideoPath(mVideoPath);
@ -261,19 +209,6 @@ public class ProVideoActivity extends AppCompatActivity {
GestureDetector.SimpleOnGestureListener listener = new GestureDetector.SimpleOnGestureListener() {
@Override
public boolean onSingleTapConfirmed(MotionEvent e) {
// if (!isLandscape() && mMode == 3) {
// if (mFullScreenMode) {
// mMode = mVideoView.toggleAspectRatio();
// mBinding.playerContainer.setVisibility(View.VISIBLE);
// mFullScreenMode = false;
// } else {
// mFullScreenMode = true;
// mBinding.playerContainer.setVisibility(View.GONE);
// }
// } else {
// mMode = mVideoView.toggleAspectRatio();
// }
if (mVideoView.isInPlaybackState()) {
mVideoView.toggleMediaControlsVisibility();
return true;
@ -284,92 +219,38 @@ public class ProVideoActivity extends AppCompatActivity {
@Override
public boolean onDoubleTap(MotionEvent e) {
// setRequestedOrientation(isLandscape() ? ActivityInfo.SCREEN_ORIENTATION_PORTRAIT : ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
return true;
}
};
detector = new GestureDetector(this, listener);
mVideoView.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
mVideoView.setOnTouchListener((v, event) -> {
detector.onTouchEvent(event);
return true;
}
});
mSpeedCalcTask = new Runnable() {
private long mReceivedBytes;
@Override
public void run() {
long l = mVideoView.getReceivedBytes();
long received = l - mReceivedBytes;
mReceivedBytes = l;
mBinding.loadingSpeed.setText(String.format("%3.01fKB/s", received * 1.0f / 1024));
if (mProgress.getVisibility() == View.VISIBLE){
mVideoView.postDelayed(this,1000);
}
}
};
mVideoView.post(mSpeedCalcTask);
if (BuildConfig.DEBUG) {
mBinding.videoView2.setVideoPath("rtmp://13088.liveplay.myqcloud.com/live/13088_65829b3d3e");
mBinding.videoView2.setShowing(false);
mBinding.videoView2.start();
}
}
// @Override
// protected void onResume() {
// super.onResume();
//
// if (mVideoView != null) {
// mVideoView.postDelayed(new Runnable() {
// @Override
// public void run() {
// mVideoView.reStart();
// }
// }, 5000);
// }
// }
@Override
protected void onStop() {
super.onStop();
mVideoView.stopPlayback();
if (BuildConfig.DEBUG) {
mBinding.videoView2.stopPlayback();
}
}
@Override
protected void onDestroy() {
super.onDestroy();
if (mScanner != null) {
mScanner.disconnect();
mScanner = null;
}
}
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
if (REQUEST_WRITE_STORAGE == requestCode){
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
doTakePicture();
}
}
}
// @Override
// public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
// super.onRequestPermissionsResult(requestCode, permissions, grantResults);
// if (REQUEST_WRITE_STORAGE == requestCode){
// if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
// doTakePicture();
// }
// }
// }
@Override
public void onConfigurationChanged(Configuration newConfig) {
@ -400,10 +281,6 @@ public class ProVideoActivity extends AppCompatActivity {
int newVis = View.SYSTEM_UI_FLAG_LAYOUT_STABLE;
if (!visible) {
// } else {
// newVis &= ~(View.SYSTEM_UI_FLAG_LOW_PROFILE |
// View.SYSTEM_UI_FLAG_FULLSCREEN |
// View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);
newVis |= View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_IMMERSIVE;
}
@ -421,50 +298,50 @@ public class ProVideoActivity extends AppCompatActivity {
Log.i(TAG, "画面模式:" + mMode);
}
/*
*
* */
public void onTakePicture(View view) {
if (mVideoView.isInPlaybackState()) {
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED){
ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, REQUEST_WRITE_STORAGE);
} else {
doTakePicture();
}
}
}
private void doTakePicture() {
File file = new File(FileUtil.getPicturePath());
file.mkdirs();
file = new File(file, "pic_" + new SimpleDateFormat("yyyyMMddHHmmss").format(new Date()) + ".jpg");
final String picture = mVideoView.takePicture(file.getPath());
if (!TextUtils.isEmpty(picture)) {
Toast.makeText(ProVideoActivity.this,"图片已保存", Toast.LENGTH_SHORT).show();
if (mScanner == null) {
MediaScannerConnection connection = new MediaScannerConnection(ProVideoActivity.this, new MediaScannerConnection.MediaScannerConnectionClient() {
public void onMediaScannerConnected() {
mScanner.scanFile(picture, "image/jpeg");
}
public void onScanCompleted(String path1, Uri uri) {
}
});
try {
connection.connect();
} catch (Exception e) {
e.printStackTrace();
}
mScanner = connection;
} else {
mScanner.scanFile(picture, "image/jpeg");
}
}
}
// /*
// * 截图
// * */
// public void onTakePicture(View view) {
// if (mVideoView.isInPlaybackState()) {
// if (ActivityCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED){
// ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, REQUEST_WRITE_STORAGE);
// } else {
// doTakePicture();
// }
// }
// }
//
// private void doTakePicture() {
// File file = new File(FileUtil.getPicturePath());
// file.mkdirs();
//
// file = new File(file, "pic_" + new SimpleDateFormat("yyyyMMddHHmmss").format(new Date()) + ".jpg");
// final String picture = mVideoView.takePicture(file.getPath());
//
// if (!TextUtils.isEmpty(picture)) {
// Toast.makeText(ProVideoActivity.this,"图片已保存", Toast.LENGTH_SHORT).show();
//
// if (mScanner == null) {
// MediaScannerConnection connection = new MediaScannerConnection(ProVideoActivity.this, new MediaScannerConnection.MediaScannerConnectionClient() {
// public void onMediaScannerConnected() {
// mScanner.scanFile(picture, "image/jpeg");
// }
//
// public void onScanCompleted(String path1, Uri uri) {
//
// }
// });
//
// try {
// connection.connect();
// } catch (Exception e) {
// e.printStackTrace();
// }
//
// mScanner = connection;
// } else {
// mScanner.scanFile(picture, "image/jpeg");
// }
// }
// }
}

@ -135,10 +135,6 @@ public class ProVideoView extends IjkVideoView implements VideoControllerView.Fu
@Override
public void reStart() {
super.reStart();
if (mRecordPath != null) {
toggleRecord();
toggleRecord();
}
}
@Override
@ -191,7 +187,6 @@ public class ProVideoView extends IjkVideoView implements VideoControllerView.Fu
if (mMediaPlayer == null) {
return;
}
if (mMediaPlayer instanceof IjkMediaPlayer) {
IjkMediaPlayer player = (IjkMediaPlayer) mMediaPlayer;
player.setSpeed(speed);
@ -200,10 +195,6 @@ public class ProVideoView extends IjkVideoView implements VideoControllerView.Fu
@Override
public void takePicture() {
if (getContext() instanceof ProVideoActivity) {
ProVideoActivity pro = (ProVideoActivity) getContext();
pro.onTakePicture(null);
}
}
@Override

@ -3,7 +3,6 @@ package com.yinuo.safetywatcher.player;
import android.content.Context;
import android.os.Handler;
import android.os.Message;
import android.os.SystemClock;
import android.util.AttributeSet;
import android.util.Log;
import android.view.Gravity;
@ -27,7 +26,6 @@ import java.util.Formatter;
import java.util.Locale;
import tv.danmaku.ijk.media.widget.media.IMediaController;
import tv.danmaku.ijk.media.widget.media.IjkVideoView;
/**
*
@ -63,15 +61,6 @@ public class VideoControllerView extends FrameLayout implements IMediaController
private ImageButton mPauseButton; // 暂停or开始
private ImageButton mFastButton; // 快进
private ImageButton mRewindButton; // 快退
private ImageButton mFullscreenButton; // 全屏
private ImageButton mRecordButton; // 录像
private ImageButton mFastPlay; // 播放速度加快
private ImageButton mSlowPlay; // 播放速度减慢
private TextView mTVSpeed;
private TextView mTVRecordDuration;
private TextView fps, kbps;
private View mPictureBtn, mChangeModeBtn;
private long mReceivedBytes;
private long mReceivedPackets;
@ -80,98 +69,27 @@ public class VideoControllerView extends FrameLayout implements IMediaController
private Handler mHandler = new MessageHandler(this);
Runnable mRecordTickTask = new Runnable() {
@Override
public void run() {
long recordSecond = (System.currentTimeMillis() - recordBeginTime) / 1000;
if (recordSecond >= 300) { // 分段
}
recordSecond %= 3600;
mTVRecordDuration.setText(String.format("%02d:%02d", recordSecond / 60, recordSecond % 60));
mTVRecordDuration.setCompoundDrawablesWithIntrinsicBounds(recordSecond % 2 == 0 ? R.drawable.red_dot : R.drawable.transparent_dot, 0, 0, 0);
postDelayed(this, 1000);
}
};
// 每一秒更新fps/bps
Runnable fpsBpsTickTask = new Runnable() {
long firstTimeStamp = 0l;
@Override
public void run() {
if (firstTimeStamp == 0l)
firstTimeStamp = System.currentTimeMillis();
if (mPlayer != null && (mPlayer instanceof IjkVideoView)) {
IjkVideoView ijk = (IjkVideoView) mPlayer;
long l = ijk.getReceivedBytes();
long received = l - mReceivedBytes;
long packets = ijk.getVideoCachePackets();
long receivedPackets = packets - mReceivedPackets;
mReceivedBytes = l;
mReceivedPackets = packets;
if (ijk.isPlaying() && lastBitsMillis != 0) {
long l1 = SystemClock.uptimeMillis() - lastBitsMillis;
if (l1 >= 300) {
long time = System.currentTimeMillis() - firstTimeStamp;
if (time < 900) {
fps.setText("");
kbps.setText("");
} else {
receivedPackets = Math.min(receivedPackets, 30);
fps.setText(String.format("%dfps", receivedPackets));
kbps.setText(String.format("%3.01fKB/s", received * 1.0f * 1000 / l1 / 1024));
}
}
} else {
fps.setText("");
kbps.setText("");
}
lastBitsMillis = SystemClock.uptimeMillis();
}
postDelayed(this, 1000);
}
};
private Runnable mSeekingPending;
// 暂停/开始的点击事件
private OnClickListener mPauseListener = new OnClickListener() {
public void onClick(View v) {
private OnClickListener mPauseListener = v -> {
doPauseResume();
show(sDefaultTimeout);
}
};
// 全屏的点击事件
private OnClickListener mFullscreenListener = new OnClickListener() {
public void onClick(View v) {
private OnClickListener mFullscreenListener = v -> {
doToggleFullscreen();
show(sDefaultTimeout);
}
};
// 录像的点击事件
private OnClickListener mRecordingListener = new OnClickListener() {
public void onClick(View v) {
doToggleRecord();
show(sDefaultTimeout);
}
};
private OnClickListener mRecordingListener = v -> show(sDefaultTimeout);
// 滚动条的点击事件
private OnSeekBarChangeListener mSeekListener = new OnSeekBarChangeListener() {
public void onStartTrackingTouch(SeekBar bar) {
show(3600000);
mDragging = true;
mHandler.removeMessages(SHOW_PROGRESS);
}
@ -243,91 +161,6 @@ public class VideoControllerView extends FrameLayout implements IMediaController
}
};
// 播放速度加快
private OnClickListener mFastPlayListener = new OnClickListener() {
@Override
public void onClick(View v) {
show(sDefaultTimeout);
if (mPlayer instanceof FullScreenAbleMediaPlayerControl) {
FullScreenAbleMediaPlayerControl player = (FullScreenAbleMediaPlayerControl) mPlayer;
float speed = player.getSpeed();
if (speed > 2.0) {
return;
}
if (speed >= 1.0f) {
mTVSpeed.setText(String.format("%d倍速", (int) (speed * 2)));
} else {
mTVSpeed.setText(String.format("%.02f倍速", speed * 2));
}
if (speed == 0.5) {
mTVSpeed.setVisibility(GONE);
} else {
mTVSpeed.setVisibility(VISIBLE);
}
player.setSpeed(speed * 2);
} else {
}
}
};
private OnClickListener mSlowPlayListener = new OnClickListener() {
@Override
public void onClick(View v) {
if (mPlayer instanceof FullScreenAbleMediaPlayerControl) {
FullScreenAbleMediaPlayerControl player = (FullScreenAbleMediaPlayerControl) mPlayer;
float speed = player.getSpeed();
if (speed < 0.5) {
return;
}
if (speed >= 2.0f) {
mTVSpeed.setText(String.format("%d倍速", (int) (speed * 0.5)));
} else {
mTVSpeed.setText(String.format("%.02f倍速", speed * 0.5));
}
if (speed == 2.0) {
mTVSpeed.setVisibility(GONE);
} else {
mTVSpeed.setVisibility(VISIBLE);
}
player.setSpeed(speed * 0.5f);
}
show(sDefaultTimeout);
}
};
private OnClickListener takePicListener = new OnClickListener() {
@Override
public void onClick(View v) {
show(sDefaultTimeout);
if (mPlayer instanceof FullScreenAbleMediaPlayerControl) {
FullScreenAbleMediaPlayerControl player = (FullScreenAbleMediaPlayerControl) mPlayer;
player.takePicture();
}
}
};
private OnClickListener modeListener = new OnClickListener() {
@Override
public void onClick(View v) {
show(sDefaultTimeout);
if (mPlayer instanceof FullScreenAbleMediaPlayerControl) {
FullScreenAbleMediaPlayerControl player = (FullScreenAbleMediaPlayerControl) mPlayer;
player.toggleMode();
}
}
};
/** ==================== constructor ==================== */
public VideoControllerView(Context context, AttributeSet attrs) {
@ -505,9 +338,6 @@ public class VideoControllerView extends FrameLayout implements IMediaController
mPlayer = player;
updatePausePlay();
updateFullScreen();
updateRecord();
updateSpeedCtrl();
}
@Override
@ -540,9 +370,6 @@ public class VideoControllerView extends FrameLayout implements IMediaController
}
updatePausePlay();
updateFullScreen();
updateRecord();
updateSpeedCtrl();
mHandler.sendEmptyMessage(SHOW_PROGRESS);
@ -552,11 +379,6 @@ public class VideoControllerView extends FrameLayout implements IMediaController
mHandler.removeMessages(FADE_OUT);
mHandler.sendMessageDelayed(msg, timeout);
}
if (mPlayer != null && mPlayer.isPlaying()) {
removeCallbacks(fpsBpsTickTask);
post(fpsBpsTickTask);
}
}
@Override
@ -572,9 +394,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);
initControllerView(mRoot);
return mRoot;
}
@ -587,18 +407,6 @@ public class VideoControllerView extends FrameLayout implements IMediaController
mPauseButton.setOnClickListener(mPauseListener);
}
mFullscreenButton = (ImageButton) v.findViewById(R.id.fullscreen);
if (mFullscreenButton != null) {
mFullscreenButton.requestFocus();
mFullscreenButton.setOnClickListener(mFullscreenListener);
}
mRecordButton = (ImageButton) v.findViewById(R.id.action_record);
if (mRecordButton != null) {
mRecordButton.requestFocus();
mRecordButton.setOnClickListener(mRecordingListener);
}
mFastButton = (ImageButton) v.findViewById(R.id.fast_forward);
if (mFastButton != null) {
mFastButton.setOnClickListener(mFastListener);
@ -621,45 +429,15 @@ public class VideoControllerView extends FrameLayout implements IMediaController
SeekBar seeker = (SeekBar) mProgress;
seeker.setOnSeekBarChangeListener(mSeekListener);
}
mProgress.setMax(1000);
}
fps = (TextView) v.findViewById(R.id.tv_fps);
kbps = (TextView) v.findViewById(R.id.tv_kbps);
mEndTime = (TextView) v.findViewById(R.id.total_time);
mCurrentTime = (TextView) v.findViewById(R.id.time_current);
mTVSpeed = (TextView) v.findViewById(R.id.tv_speed);
mFormatBuilder = new StringBuilder();
mFormatter = new Formatter(mFormatBuilder, Locale.getDefault());
mFastPlay = (ImageButton) v.findViewById(R.id.fast);
mFastPlay.setOnClickListener(mFastPlayListener);
mSlowPlay = (ImageButton) v.findViewById(R.id.slow);
mSlowPlay.setOnClickListener(mSlowPlayListener);
mPictureBtn = v.findViewById(R.id.action_take_picture);
mPictureBtn.setOnClickListener(takePicListener);
mChangeModeBtn = v.findViewById(R.id.action_change_mode);
mChangeModeBtn.setOnClickListener(modeListener);
mTVRecordDuration = (TextView) v.findViewById(R.id.tv_record_time);
mTVRecordDuration.setOnClickListener(mRecordingListener);
if (this.mPlayer instanceof FullScreenAbleMediaPlayerControl) {
FullScreenAbleMediaPlayerControl mPlayer = (FullScreenAbleMediaPlayerControl) this.mPlayer;
} else {
mFastPlay.setVisibility(GONE);
mSlowPlay.setVisibility(GONE);
}
if (mPlayer.isPlaying()) {
post(fpsBpsTickTask);
}
if (!mPlayer.canSeekBackward() || !mPlayer.canSeekForward()) {
v.findViewById(R.id.seek_bar_container).setVisibility(GONE);
} else {
@ -693,32 +471,6 @@ public class VideoControllerView extends FrameLayout implements IMediaController
}
}
private void updateSpeedCtrl() {
if (mRoot == null || mRecordButton == null || this.mPlayer == null) {
return;
}
if (this.mPlayer instanceof FullScreenAbleMediaPlayerControl) {
FullScreenAbleMediaPlayerControl mPlayer = (FullScreenAbleMediaPlayerControl) this.mPlayer;
if (mPlayer.speedCtrlEnable()) {
mFastPlay.setVisibility(VISIBLE);
mSlowPlay.setVisibility(VISIBLE);
mTVSpeed.setVisibility(VISIBLE);
kbps.setVisibility(GONE);
fps.setVisibility(GONE);
} else {
mFastPlay.setVisibility(GONE);
mSlowPlay.setVisibility(GONE);
mTVSpeed.setVisibility(GONE);
kbps.setVisibility(VISIBLE);
fps.setVisibility(VISIBLE);
}
}
}
/*
* /
* */
@ -727,8 +479,6 @@ public class VideoControllerView extends FrameLayout implements IMediaController
return;
}
removeCallbacks(fpsBpsTickTask);
if (mPlayer.isPlaying()) {
mPlayer.pause();
} else {
@ -758,7 +508,6 @@ public class VideoControllerView extends FrameLayout implements IMediaController
postDelayed(mSeekingPending,500);
}
post(fpsBpsTickTask);
mReceivedBytes = 0;
mReceivedPackets = 0;
}
@ -826,46 +575,6 @@ public class VideoControllerView extends FrameLayout implements IMediaController
return position;
}
public void updateFullScreen() {
if (mRoot == null || mFullscreenButton == null || this.mPlayer == null) {
return;
}
if (this.mPlayer instanceof FullScreenAbleMediaPlayerControl) {
FullScreenAbleMediaPlayerControl mPlayer = (FullScreenAbleMediaPlayerControl) this.mPlayer;
if (mPlayer.isFullScreen()) {
mFullscreenButton.setImageResource(R.drawable.new_full);
} else {
mFullscreenButton.setImageResource(R.drawable.new_full_white);
}
}
}
private void updateRecord() {
if (mRoot == null || mRecordButton == null || this.mPlayer == null) {
return;
}
if (this.mPlayer instanceof FullScreenAbleMediaPlayerControl) {
FullScreenAbleMediaPlayerControl mPlayer = (FullScreenAbleMediaPlayerControl) this.mPlayer;
if (mPlayer.isRecording()) {
mRecordButton.setImageResource(R.drawable.new_videotape_click);
removeCallbacks(mRecordTickTask);
post(mRecordTickTask);
} else {
mRecordButton.setImageResource(R.drawable.new_videotape_btn);
}
if (mPlayer.recordEnable()) {
mRecordButton.setVisibility(VISIBLE);
} else {
mRecordButton.setVisibility(GONE);
}
}
}
private void doToggleFullscreen() {
if (mPlayer == null) {
return;
@ -875,28 +584,6 @@ public class VideoControllerView extends FrameLayout implements IMediaController
FullScreenAbleMediaPlayerControl mPlayer = (FullScreenAbleMediaPlayerControl) this.mPlayer;
mPlayer.toggleFullScreen();
}
updateFullScreen();
}
private void doToggleRecord() {
if (mPlayer == null) {
return;
}
if (this.mPlayer instanceof FullScreenAbleMediaPlayerControl) {
FullScreenAbleMediaPlayerControl mPlayer = (FullScreenAbleMediaPlayerControl) this.mPlayer;
mPlayer.toggleRecord();
if (mPlayer.isRecording()) {
findViewById(R.id.tv_record_time).setVisibility(VISIBLE);
recordBeginTime = System.currentTimeMillis();
post(mRecordTickTask);
} else {
findViewById(R.id.tv_record_time).setVisibility(GONE);
removeCallbacks(mRecordTickTask);
}
}
}
private String stringForTime(int timeMs) {

@ -1,16 +1,13 @@
package com.yinuo.safetywatcher.watcher.ui
import android.content.Intent
import android.view.View
import androidx.recyclerview.widget.LinearLayoutManager
import com.yinuo.safetywatcher.R
import com.yinuo.safetywatcher.databinding.ActivityHistoryVideoBinding
import com.yinuo.safetywatcher.databinding.ActivityWarndataBinding
import com.yinuo.safetywatcher.watcher.adapter.HistoryDataAdapter
import com.yinuo.safetywatcher.watcher.adapter.WarnDataAdapter
import com.yinuo.safetywatcher.player.ProVideoActivity
import com.yinuo.safetywatcher.watcher.base.BaseActivity
import com.yinuo.safetywatcher.watcher.bean.HistoryData
import com.yinuo.safetywatcher.watcher.bean.WarnData
import com.yinuo.safetywatcher.watcher.view.CommonTopBar
import com.yinuo.safetywatcher.xls.utils.PathUtils
class HistoryVideoActivity : BaseActivity() {
@ -22,7 +19,10 @@ class HistoryVideoActivity : BaseActivity() {
if (0 == type) {
} else if (1 == type) {
val intent = Intent(this@HistoryVideoActivity, ProVideoActivity::class.java)
val path = PathUtils.getExternalStorageDirectory() + "/test.mp4"
intent.putExtra("videoPath", path)
startActivity(intent)
}
}

@ -67,7 +67,7 @@
android:id="@+id/divider2"
android:layout_width="@dimen/_6dp"
android:layout_height="@dimen/_28dp"
android:layout_marginStart="@dimen/_55dp"
android:layout_marginStart="@dimen/_132dp"
android:background="@drawable/white_rectangle"
app:layout_constraintBottom_toBottomOf="@id/tv_endTime"
app:layout_constraintStart_toStartOf="parent"
@ -114,7 +114,7 @@
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal"
android:paddingTop="@dimen/_20dp">
android:paddingTop="@dimen/font_46dp">
<View
android:layout_width="@dimen/_6dp"
@ -180,7 +180,7 @@
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal"
android:paddingTop="@dimen/_20dp">
android:paddingTop="@dimen/font_46dp">
<View
android:layout_width="@dimen/_6dp"
@ -202,7 +202,7 @@
android:layout_width="@dimen/_480dp"
android:layout_height="@dimen/_81dp"
android:background="@drawable/confirm_btn_bg"
android:layout_marginTop="@dimen/_20dp"
android:layout_marginTop="@dimen/font_46dp"
android:gravity="center"
android:text="@string/confirm"
android:textColor="@color/white"

@ -12,12 +12,12 @@
android:layout_gravity="center"
android:background="#000000">
<com.yinuo.safetywatcher.player.ProVideoView
<!--<com.yinuo.safetywatcher.player.ProVideoView
android:id="@+id/video_view2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:keepScreenOn="true"
android:visibility="gone" />
android:visibility="gone" />-->
<com.yinuo.safetywatcher.player.ProVideoView
android:id="@+id/video_view"
@ -34,8 +34,8 @@
<LinearLayout
android:id="@android:id/progress"
android:layout_width="match_parent"
android:layout_height="200dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="@color/white"
android:gravity="center"
@ -46,15 +46,6 @@
android:layout_height="100dp"
android:indeterminateBehavior="repeat"
android:indeterminateDrawable="@drawable/anim" />
<TextView
android:id="@+id/loading_speed"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:text="加载中"
android:textColor="@color/colorTheme" />
</LinearLayout>
<ImageView

@ -1,176 +1,76 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/media_controller_ll"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/media_controller_ll"
android:background="#6000"
android:orientation="vertical">
<LinearLayout
android:id="@+id/seek_bar_container"
android:layout_width="match_parent"
android:layout_height="30dp"
android:gravity="center"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:paddingTop="@dimen/_30dp"
android:orientation="horizontal">
<TextView
android:id="@+id/tv_speed"
style="@style/Widget.AppCompat.ActionButton"
android:layout_width="0dp"
android:layout_weight="1"
android:id="@+id/time_current"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone"
android:textColor="@color/white" />
android:layout_gravity="center_horizontal"
android:paddingLeft="@dimen/_20dp"
android:paddingRight="@dimen/_20dp"
android:textColor="@color/white"
android:textSize="@dimen/_30dp"
android:textStyle="bold" />
<TextView
android:id="@+id/tv_fps"
style="@style/Widget.AppCompat.ActionButton"
android:layout_width="0dp"
android:layout_weight="1"
android:visibility="gone"
<SeekBar
android:id="@+id/media_controller_progress"
style="@style/CustomSeekbarStyle"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:textColor="@color/white" />
android:layout_weight="1"
android:progress="0"
android:secondaryProgress="60" />
<TextView
android:id="@+id/tv_kbps"
style="@style/Widget.AppCompat.ActionButton"
android:layout_width="0dp"
android:layout_weight="1"
android:id="@+id/total_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:paddingLeft="@dimen/_20dp"
android:paddingRight="@dimen/_20dp"
android:textColor="@color/white"
android:visibility="gone" />
android:textSize="@dimen/_30dp"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="30dp"
android:layout_height="@dimen/_108dp"
android:gravity="center"
android:orientation="horizontal">
<ImageButton
android:id="@+id/slow"
android:layout_weight="1"
style="@android:style/MediaButton.Next"
android:src="@drawable/new_slow_btn" />
android:orientation="horizontal"
android:paddingHorizontal="@dimen/_580dp">
<ImageButton
android:id="@+id/rewind"
android:layout_weight="1"
style="@android:style/MediaButton.Rew"
android:layout_weight="1"
android:src="@drawable/new_moveback_btn" />
<ImageButton
android:id="@+id/pause"
android:layout_weight="1"
style="@android:style/MediaButton.Play"
android:layout_weight="1"
android:src="@drawable/new_stop_white" />
<ImageButton
android:id="@+id/fast_forward"
android:layout_weight="1"
style="@android:style/MediaButton.Ffwd"
android:src="@drawable/new_forward_btn"/>
<ImageButton
android:id="@+id/fast"
android:layout_weight="1"
style="@android:style/MediaButton.Ffwd"
android:src="@drawable/new_fast_btn" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="30dp"
android:gravity="center"
android:orientation="horizontal"
android:paddingTop="4dip">
<ImageButton
android:id="@+id/action_take_picture"
style="@style/Widget.AppCompat.ActionButton"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:src="@drawable/new_snapshot_btn" />
<ImageButton
android:id="@+id/action_record"
style="@style/Widget.AppCompat.ActionButton"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:src="@drawable/new_videotape_btn" />
<TextView
android:id="@+id/tv_record_time"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:gravity="center"
android:visibility="gone"
android:textColor="#ff0000"
android:drawablePadding="5dp"
android:drawableLeft="@drawable/red_dot"
android:text="00:00" />
<ImageButton
android:id="@+id/action_change_mode"
style="@style/Widget.AppCompat.ActionButton"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:src="@drawable/new_stretch_btn" />
<ImageButton
android:id="@+id/fullscreen"
style="@style/Widget.AppCompat.ActionButton"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:src="@drawable/new_full" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="30dp"
android:id="@+id/seek_bar_container"
android:gravity="center_vertical"
android:orientation="horizontal">
<TextView
android:id="@+id/time_current"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:paddingLeft="4dip"
android:paddingRight="4dip"
android:paddingTop="4dip"
android:textSize="14sp"
android:textColor="@color/white"
android:textStyle="bold" />
<SeekBar
android:id="@+id/media_controller_progress"
style="@style/CustomSeekbarStyle"
android:progress="10"
android:secondaryProgress="60"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1" />
<TextView
android:id="@+id/total_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:paddingLeft="4dip"
android:textColor="@color/white"
android:paddingRight="4dip"
android:paddingTop="4dip"
android:textSize="14sp"
android:textStyle="bold" />
android:src="@drawable/new_forward_btn" />
</LinearLayout>

Loading…
Cancel
Save