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

main
xiaowusky 2 years ago
parent baa280fff0
commit 4916b69e1e

@ -189,6 +189,7 @@ public class ProVideoActivity extends AppCompatActivity {
mVideoView.setOnCompletionListener(iMediaPlayer -> { mVideoView.setOnCompletionListener(iMediaPlayer -> {
Log.i(TAG, "播放完成"); Log.i(TAG, "播放完成");
mVideoView.seekTo(0);
mProgress.setVisibility(View.GONE); mProgress.setVisibility(View.GONE);
}); });

@ -127,10 +127,12 @@ public class VideoControllerView extends FrameLayout implements IMediaController
if (pos < 0) { if (pos < 0) {
pos = 0; pos = 0;
} }
mPlayer.pause();
mPlayer.seekTo(pos); mPlayer.seekTo(pos);
setProgress();
show(sDefaultTimeout); show(sDefaultTimeout);
if (!mPlayer.isPlaying()) {
mPlayer.start();
}
} }
}; };
@ -143,10 +145,15 @@ public class VideoControllerView extends FrameLayout implements IMediaController
int pos = mPlayer.getCurrentPosition(); int pos = mPlayer.getCurrentPosition();
pos += 15000; // милисекунд pos += 15000; // милисекунд
if (pos > mPlayer.getDuration()) {
pos = mPlayer.getDuration();
}
mPlayer.pause();
mPlayer.seekTo(pos); mPlayer.seekTo(pos);
setProgress();
show(sDefaultTimeout); show(sDefaultTimeout);
if (!mPlayer.isPlaying()) {
mPlayer.start();
}
} }
}; };
@ -544,9 +551,7 @@ public class VideoControllerView extends FrameLayout implements IMediaController
mProgress.setMax(duration); mProgress.setMax(duration);
mProgress.setProgress(position); mProgress.setProgress(position);
} else { } else {
if (position > mProgress.getProgress()) { mProgress.setProgress(position);
mProgress.setProgress(position);
}
} }
} else { } else {
mProgress.setMax(0); mProgress.setMax(0);

@ -1,6 +1,7 @@
package com.yinuo.safetywatcher.watcher.ui package com.yinuo.safetywatcher.watcher.ui
import android.content.Intent import android.content.Intent
import android.net.Uri
import android.view.View import android.view.View
import com.yinuo.safetywatcher.R import com.yinuo.safetywatcher.R
import com.yinuo.safetywatcher.databinding.ActivityHistoryVideoBinding import com.yinuo.safetywatcher.databinding.ActivityHistoryVideoBinding
@ -8,6 +9,8 @@ import com.yinuo.safetywatcher.player.ProVideoActivity
import com.yinuo.safetywatcher.watcher.base.BaseActivity import com.yinuo.safetywatcher.watcher.base.BaseActivity
import com.yinuo.safetywatcher.watcher.view.CommonTopBar import com.yinuo.safetywatcher.watcher.view.CommonTopBar
import com.yinuo.safetywatcher.xls.utils.PathUtils import com.yinuo.safetywatcher.xls.utils.PathUtils
import java.io.File
class HistoryVideoActivity : BaseActivity() { class HistoryVideoActivity : BaseActivity() {
@ -17,7 +20,13 @@ class HistoryVideoActivity : BaseActivity() {
override fun onOptionClick(type: Int, target: View) { override fun onOptionClick(type: Int, target: View) {
if (0 == type) { if (0 == type) {
// val intent = Intent(Intent.ACTION_VIEW)
// val path = PathUtils.getExternalStorageDirectory() + "/test2.mp4" //该路径可以自定义
// val file = File(path)
// val uri = Uri.fromFile(file)
// intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
// intent.setDataAndType(uri, "video/*")
// startActivity(intent)
} else if (1 == type) { } else if (1 == type) {
val intent = Intent(this@HistoryVideoActivity, ProVideoActivity::class.java) val intent = Intent(this@HistoryVideoActivity, ProVideoActivity::class.java)
val path = PathUtils.getExternalStorageDirectory() + "/test.mp4" val path = PathUtils.getExternalStorageDirectory() + "/test.mp4"

Loading…
Cancel
Save