the equalizer will apparently have to be set up dynamically

This commit is contained in:
tibbi 2021-02-03 20:48:21 +01:00
parent eebc1f66cd
commit d6d4eed1a8
3 changed files with 14 additions and 9 deletions

View file

@ -1,5 +1,8 @@
package com.simplemobiletools.musicplayer.activities
import android.annotation.SuppressLint
import android.media.MediaPlayer
import android.media.audiofx.Equalizer
import android.os.Bundle
import android.view.Menu
import com.simplemobiletools.commons.extensions.updateTextColors
@ -11,10 +14,19 @@ class EqualizerActivity : SimpleActivity() {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_equalizer)
updateTextColors(equalizer_holder)
initMediaPlayer()
}
override fun onCreateOptionsMenu(menu: Menu): Boolean {
updateMenuItemColors(menu)
return super.onCreateOptionsMenu(menu)
}
@SuppressLint("SetTextI18n")
private fun initMediaPlayer() {
val player = MediaPlayer()
val equalizer = Equalizer(0, player.audioSessionId)
equalizer_label_bottom.text = (equalizer.bandLevelRange[0] / 100).toString()
equalizer_label_top.text = "+${equalizer.bandLevelRange[1] / 100}"
}
}

View file

@ -12,7 +12,6 @@ import android.media.AudioManager
import android.media.AudioManager.*
import android.media.MediaMetadataRetriever
import android.media.MediaPlayer
import android.media.audiofx.Equalizer
import android.media.session.PlaybackState.PLAYBACK_POSITION_UNKNOWN
import android.net.Uri
import android.os.CountDownTimer
@ -31,7 +30,6 @@ import androidx.media.session.MediaButtonReceiver
import com.simplemobiletools.commons.extensions.getColoredBitmap
import com.simplemobiletools.commons.extensions.getRealPathFromURI
import com.simplemobiletools.commons.extensions.hasPermission
import com.simplemobiletools.commons.extensions.showErrorToast
import com.simplemobiletools.commons.helpers.*
import com.simplemobiletools.musicplayer.R
import com.simplemobiletools.musicplayer.activities.MainActivity

View file

@ -24,7 +24,7 @@
app:layout_constraintTop_toTopOf="parent">
<com.simplemobiletools.commons.views.MyTextView
android:id="@+id/equalizer_label_15"
android:id="@+id/equalizer_label_top"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
@ -42,7 +42,7 @@
android:textSize="@dimen/normal_text_size" />
<com.simplemobiletools.commons.views.MyTextView
android:id="@+id/equalizer_label_minus_15"
android:id="@+id/equalizer_label_bottom"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
@ -56,7 +56,6 @@
android:id="@+id/equalizer_60"
android:layout_width="0dp"
android:layout_height="@dimen/equalizer_seekbar_height"
android:max="30"
android:paddingStart="@dimen/activity_margin"
android:paddingEnd="@dimen/activity_margin"
app:layout_constraintEnd_toStartOf="@+id/equalizer_230"
@ -68,7 +67,6 @@
android:id="@+id/equalizer_230"
android:layout_width="0dp"
android:layout_height="@dimen/equalizer_seekbar_height"
android:max="30"
android:padding="@dimen/activity_margin"
app:layout_constraintEnd_toStartOf="@+id/equalizer_960"
app:layout_constraintHorizontal_bias="0.5"
@ -79,7 +77,6 @@
android:id="@+id/equalizer_960"
android:layout_width="0dp"
android:layout_height="@dimen/equalizer_seekbar_height"
android:max="30"
android:padding="@dimen/activity_margin"
app:layout_constraintEnd_toStartOf="@+id/equalizer_3600"
app:layout_constraintHorizontal_bias="0.5"
@ -90,7 +87,6 @@
android:id="@+id/equalizer_3600"
android:layout_width="0dp"
android:layout_height="@dimen/equalizer_seekbar_height"
android:max="30"
android:padding="@dimen/activity_margin"
app:layout_constraintEnd_toStartOf="@+id/equalizer_14000"
app:layout_constraintHorizontal_bias="0.5"
@ -101,7 +97,6 @@
android:id="@+id/equalizer_14000"
android:layout_width="0dp"
android:layout_height="@dimen/equalizer_seekbar_height"
android:max="30"
android:padding="@dimen/activity_margin"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"