android播放器时间显示,Android 节操视频播放器jiecaovideoplayer自定义播放音频使用:屏蔽全屏按钮,增加倒计时,当前时间/总时间...

本文主要介绍了Android播放器的优化操作。一是屏蔽全屏按钮,通过修改JCVideoPlayerStandard.java文件中的代码实现;二是自动检测并增加倒计时、当前时间/总时间显示,同样对该文件中的相关代码进行修改,还说明了不同隐藏设置下的时间显示效果。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

一、屏蔽全屏按钮

96c6ce07c06d3e7961b6d7ef30fbb573.png

找到JCVideoPlayerStandard.java文件中的代码:

private void fixAudio() {

if (SrcType.equalsIgnoreCase("Audio")) {

//如果是音频,始终显示coverImageView

//thumbImageView.setVisibility(View.VISIBLE);

coverImageView.setVisibility(View.VISIBLE);

bottomProgressBar.setVisibility(View.VISIBLE);

fullscreenButton.setVisibility(View.INVISIBLE);

}

}

改为:fullscreenButton.setVisibility(View.GONE);

二、自动检测,增加倒计时,当前时间/总时间

1、找到JCVideoPlayerStandard.java文件中的代码:

@Override

protected void setProgressAndTime(int progress, int secProgress, int currentTime, int totalTime) {

super.setProgressAndTime(progress, secProgress, currentTime, totalTime);

if (progress != 0)

bottomProgressBar.setProgress(progress);

if (secProgress != 0)

bottomProgressBar.setSecondaryProgress(secProgress);

}

修改为:

@Override

protected void setProgressAndTime(int progress, int secProgress, int currentTime, int totalTime) {

super.setProgressAndTime(progress, secProgress, currentTime, totalTime);

if (progress != 0)

bottomProgressBar.setProgress(progress);

if (secProgress != 0)

bottomProgressBar.setSecondaryProgress(secProgress);

//zheng 2019.05.13 进度栏

// if (progressBar.getVisibility() != View.VISIBLE) {//没有进度条

((LinearLayout) bottomContainer).setGravity(Gravity.END | Gravity.CENTER_VERTICAL);

progressBar.setVisibility(View.GONE);

totalTimeTextView.setText(" / " + JCUtils.stringForTime(totalTime));

if (currentTimeTextView.getVisibility() != View.VISIBLE) {//没有当前播放进度

totalTimeTextView.setText(JCUtils.stringForTime(totalTime - currentTime));

}

}

//

}

1、找到JCVideoPlayerStandard.java文件中的代码:

@Override

protected void resetProgressAndTime() {

super.resetProgressAndTime();

bottomProgressBar.setProgress(0);

bottomProgressBar.setSecondaryProgress(0);

}

修改为:

@Override

protected void resetProgressAndTime() {

super.resetProgressAndTime();

bottomProgressBar.setProgress(0);

bottomProgressBar.setSecondaryProgress(0);

// if (progressBar.getVisibility() != View.VISIBLE) {//没有进度条

((LinearLayout) bottomContainer).setGravity(Gravity.END | Gravity.CENTER_VERTICAL);

progressBar.setVisibility(View.GONE);

int currentTime = getCurrentPositionWhenPlaying();

int totalTime = getDuration();

totalTimeTextView.setText(" / " + JCUtils.stringForTime(totalTime));

if (currentTimeTextView.getVisibility() != View.VISIBLE) {//没有当前播放进度

totalTimeTextView.setText(JCUtils.stringForTime(totalTime - currentTime));

}

}

//

}

如果调用时只设置了隐藏了 progressBar:

mJcAudioPlayerStandard.progressBar.setVisibility(View.INVISIBLE);

显示效果如下图:“00:02/06:20” 当前时间/总时间

f628d6eb5aa8bf45c60cf16a867aae5a.png

如果调用时设置了隐藏了 progressBar,同时隐藏了currentTimeTextView:

mJcAudioPlayerStandard.progressBar.setVisibility(View.INVISIBLE);

mJcAudioPlayerStandard.currentTimeTextView.setVisibility(View.INVISIBLE);

显示效果如下:“06:18”为时间倒计时。

64c4d561d41e3ace860efa86f5f76614.png

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值