desc:视频播放增加音量键

main
xiaowusky 1 year ago
parent d4cc57e0dd
commit d915812236

@ -10,6 +10,7 @@ import android.view.View
import android.view.ViewGroup
import android.widget.EditText
import android.widget.ImageButton
import android.widget.ImageView
import android.widget.LinearLayout
import android.widget.RelativeLayout
import android.widget.SeekBar
@ -76,10 +77,27 @@ abstract class BaseActivity : AppCompatActivity() {
RecordHelper.stopRecording()
}
private val setVoiceAreaRunnable = Runnable {
volumeUtil.mediaVolume = baseBinding.sbSound.progress
}
private fun initSound() {
baseBinding.sbSound.max = volumeUtil.mediaMaxVolume
val mediaVolume = volumeUtil.mediaVolume
baseBinding.sbSound.progress = mediaVolume
baseBinding.sbSound.setOnSeekBarChangeListener(object : SeekBar.OnSeekBarChangeListener {
override fun onProgressChanged(seekBar: SeekBar, progress: Int, fromUser: Boolean) {
baseBinding.root.removeCallbacks(setVoiceAreaRunnable)
baseBinding.root.postDelayed(setVoiceAreaRunnable, 200)
autoHideVoiceArea(1500)
}
override fun onStartTrackingTouch(seekBar: SeekBar) {
}
override fun onStopTrackingTouch(seekBar: SeekBar) {
}
})
}
private fun setChildContent() {
@ -181,6 +199,7 @@ abstract class BaseActivity : AppCompatActivity() {
"SeekBar" -> SeekBar(context, attrs)
"EditText" -> EditText(context, attrs)
"ImageButton" -> ImageButton(context, attrs)
"ImageView" -> ImageView(context, attrs)
else -> {
null
}
@ -228,11 +247,7 @@ abstract class BaseActivity : AppCompatActivity() {
val keyCode = event.keyCode
if (KeyEvent.KEYCODE_DPAD_LEFT == keyCode || KeyEvent.KEYCODE_DPAD_RIGHT == keyCode) {
if (isLeftRightLongPress && baseBinding.areaSound.visibility == View.VISIBLE) {
baseBinding.areaSound.postDelayed(300) {
lastFocusView?.requestFocus()
baseBinding.areaSound.visibility = View.GONE
volumeUtil.mediaVolume = baseBinding.sbSound.progress
}
baseBinding.areaSound.postDelayed(hideVoiceAreaRunnable, 1500)
return true
}
} else if (keyCode == KeyEvent.KEYCODE_ENTER) {
@ -254,25 +269,47 @@ abstract class BaseActivity : AppCompatActivity() {
val repeatCount = event.repeatCount
val keyCode = event.keyCode
if (KeyEvent.KEYCODE_DPAD_LEFT == keyCode || KeyEvent.KEYCODE_DPAD_RIGHT == keyCode) {
isLeftRightLongPress = repeatCount > 10
isLeftRightLongPress = repeatCount > 8
if (isLeftRightLongPress && currentFocus !is SeekBar) {
val visibility = baseBinding.areaSound.visibility
if (View.GONE == visibility) {
lastFocusView = currentFocus
baseBinding.areaSound.visibility = View.VISIBLE
baseBinding.sbSound.requestFocus()
}
showVoiceArea()
var mediaVolume = baseBinding.sbSound.progress
if (KeyEvent.KEYCODE_DPAD_LEFT == keyCode) mediaVolume-- else mediaVolume++
baseBinding.sbSound.progress = mediaVolume
return true
return super.dispatchKeyEvent(event)
}
} else if (keyCode == KeyEvent.KEYCODE_ENTER) {
isHomeLongPress = repeatCount > 10
isHomeLongPress = repeatCount > 8
} else if (keyCode == KeyEvent.KEYCODE_F1) {
LogUtils.w("BaseActivity F1 pressed")
SoundUtils.playSoundIo()
}
return super.dispatchKeyEvent(event)
}
fun showVoiceArea() {
val visibility = baseBinding.areaSound.visibility
if (View.GONE == visibility) {
lastFocusView = currentFocus
baseBinding.areaSound.visibility = View.VISIBLE
baseBinding.sbSound.requestFocus()
}
autoHideVoiceArea()
}
private fun hideVoiceArea() {
lastFocusView?.requestFocus()
baseBinding.areaSound.visibility = View.GONE
volumeUtil.mediaVolume = baseBinding.sbSound.progress
baseBinding.root.removeCallbacks(hideVoiceAreaRunnable)
}
private val hideVoiceAreaRunnable = Runnable {
hideVoiceArea()
}
fun autoHideVoiceArea(delayTime: Long = 2500) {
baseBinding.root.removeCallbacks(hideVoiceAreaRunnable)
baseBinding.root.postDelayed(hideVoiceAreaRunnable, delayTime)
}
}

@ -211,7 +211,7 @@ public class ProVideoActivity extends NoOptionsActivity {
}
}
}
mediaController = new VideoControllerView(this);
mediaController = new VideoControllerView(this, v -> showVoiceArea());
mediaController.setMediaPlayer(mBinding.videoView);
mVideoView = mBinding.videoView;
mVideoView.setMediaController(mediaController);

@ -16,6 +16,7 @@ import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.MediaController;
import android.widget.SeekBar;
import android.widget.SeekBar.OnSeekBarChangeListener;
@ -154,6 +155,14 @@ public class VideoControllerView extends FrameLayout implements IMediaController
show(sDefaultTimeout);
}
};
View.OnClickListener outVoiceListener = null;
private OnClickListener mVoiceListener = new OnClickListener() {
public void onClick(View v) {
if (outVoiceListener != null) {
outVoiceListener.onClick(v);
}
}
};
/**
* ==================== constructor ====================
@ -178,9 +187,9 @@ public class VideoControllerView extends FrameLayout implements IMediaController
Log.i(TAG, TAG);
}
public VideoControllerView(Context context) {
public VideoControllerView(Context context, View.OnClickListener voiceListener) {
this(context, true);
outVoiceListener = voiceListener;
Log.i(TAG, TAG);
}
@ -426,6 +435,9 @@ public class VideoControllerView extends FrameLayout implements IMediaController
}
}
ImageView voiceView = (ImageView) v.findViewById(R.id.voice);
voiceView.setOnClickListener(mVoiceListener);
mProgress = (SeekBar) v.findViewById(R.id.media_controller_progress);
if (mProgress != null) {
if (mProgress instanceof SeekBar) {

@ -290,5 +290,7 @@ class SensorSettingActivity : NoOptionsActivity() {
MMKVUtils.sync()
// }
showToast("保存成功")
initView()
}
}

@ -89,7 +89,7 @@ class CommonTopBar : LinearLayout {
override fun onLevel(level: Int) {
Log.i(this@CommonTopBar.javaClass.name, "wifiCallback onLevel = $level")
mBinding?.root?.post {
mBinding?.wifi?.visibility = if (!isVirtuallyNet4()) VISIBLE else GONE
mBinding?.wifi?.visibility = if (level > 0 && !isVirtuallyNet4()) VISIBLE else GONE
val showLevel = (level + 1) * 20
mBinding?.wifi?.setImageLevel(showLevel)
dealForNet4()

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.3 KiB

@ -46,7 +46,7 @@
<TextClock
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:format12Hour="hh.mm"
android:format12Hour="HH.mm"
android:format24Hour="HH.mm"
android:textColor="@color/white"
android:textSize="@dimen/_30dp" />

@ -61,6 +61,7 @@
android:layout_weight="1"
android:nextFocusLeft="@id/media_controller_progress"
android:nextFocusRight="@id/media_controller_progress"
android:nextFocusDown="@id/voice"
android:focusable="true"
android:progress="0" />
@ -84,12 +85,20 @@
android:orientation="horizontal"
android:paddingHorizontal="@dimen/_580dp">
<ImageView
android:id="@+id/voice"
style="@android:style/MediaButton.Rew"
android:layout_weight="1"
android:padding="@dimen/_23dp"
android:focusable="true"
android:nextFocusLeft="@id/voice"
android:src="@drawable/voice_circle" />
<ImageButton
android:id="@+id/rewind"
style="@android:style/MediaButton.Rew"
android:layout_weight="1"
android:focusable="true"
android:nextFocusLeft="@id/rewind"
android:src="@drawable/new_moveback_btn" />
<ImageButton

Loading…
Cancel
Save