Fix rewinding issues
Fix a problem where rewinding wouldnt cause the playback to start again.
This commit is contained in:
parent
d86e5f1414
commit
929ef0a1b4
5 changed files with 7 additions and 47 deletions
|
@ -17,7 +17,6 @@ import org.oxycblt.auxio.databinding.FragmentPlaybackBinding
|
|||
import org.oxycblt.auxio.detail.DetailViewModel
|
||||
import org.oxycblt.auxio.logD
|
||||
import org.oxycblt.auxio.playback.state.LoopMode
|
||||
import org.oxycblt.auxio.settings.SettingsManager
|
||||
import org.oxycblt.auxio.ui.accent
|
||||
import org.oxycblt.auxio.ui.memberBinding
|
||||
import org.oxycblt.auxio.ui.toColor
|
||||
|
@ -63,7 +62,6 @@ class PlaybackFragment : Fragment(), SeekBar.OnSeekBarChangeListener {
|
|||
)
|
||||
|
||||
val queueMenuItem: MenuItem
|
||||
val showCoverArt = SettingsManager.getInstance().showCovers
|
||||
|
||||
// --- UI SETUP ---
|
||||
|
||||
|
@ -100,10 +98,6 @@ class PlaybackFragment : Fragment(), SeekBar.OnSeekBarChangeListener {
|
|||
|
||||
binding.song = it
|
||||
binding.playbackSeekBar.max = it.seconds.toInt()
|
||||
|
||||
if (!showCoverArt) {
|
||||
binding.playbackCover.setImageResource(R.drawable.ic_album)
|
||||
}
|
||||
} else {
|
||||
logD("No song is being played, leaving.")
|
||||
|
||||
|
|
|
@ -501,7 +501,7 @@ class PlaybackService : Service(), Player.EventListener, PlaybackStateManager.Ca
|
|||
|
||||
// Rewind if the key is rewind
|
||||
KeyEvent.KEYCODE_MEDIA_REWIND -> {
|
||||
player.seekTo(0)
|
||||
playbackManager.rewind()
|
||||
true
|
||||
}
|
||||
|
||||
|
|
|
@ -322,7 +322,7 @@ class PlaybackStateManager private constructor() {
|
|||
fun prev() {
|
||||
// If enabled, rewind before skipping back if the position is past 3 seconds [3000ms]
|
||||
if (settingsManager.rewindWithPrev && mPosition >= 3000) {
|
||||
seekTo(0)
|
||||
rewind()
|
||||
} else {
|
||||
// Only decrement the index if there's a song to move back to AND if we are not exiting
|
||||
// the user queue.
|
||||
|
@ -593,6 +593,11 @@ class PlaybackStateManager private constructor() {
|
|||
}
|
||||
}
|
||||
|
||||
fun rewind() {
|
||||
seekTo(0)
|
||||
setPlayingStatus(true)
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the [LoopMode]
|
||||
* @param mode The [LoopMode] to be used
|
||||
|
|
|
@ -8,13 +8,9 @@ import androidx.lifecycle.ViewModel
|
|||
import androidx.lifecycle.viewModelScope
|
||||
import kotlinx.coroutines.launch
|
||||
import org.oxycblt.auxio.R
|
||||
import org.oxycblt.auxio.music.Album
|
||||
import org.oxycblt.auxio.music.Artist
|
||||
import org.oxycblt.auxio.music.BaseModel
|
||||
import org.oxycblt.auxio.music.Genre
|
||||
import org.oxycblt.auxio.music.Header
|
||||
import org.oxycblt.auxio.music.MusicStore
|
||||
import org.oxycblt.auxio.music.Song
|
||||
import org.oxycblt.auxio.recycler.DisplayMode
|
||||
import org.oxycblt.auxio.settings.SettingsManager
|
||||
|
||||
|
@ -99,16 +95,6 @@ class SearchViewModel : ViewModel() {
|
|||
return if (filtered.isNotEmpty()) filtered else null
|
||||
}
|
||||
|
||||
private fun List<BaseModel>.filterByDisplayMode(mode: DisplayMode): List<BaseModel> {
|
||||
return when (mode) {
|
||||
DisplayMode.SHOW_ALL -> this
|
||||
DisplayMode.SHOW_SONGS -> filterIsInstance<Song>()
|
||||
DisplayMode.SHOW_ALBUMS -> filterIsInstance<Album>()
|
||||
DisplayMode.SHOW_ARTISTS -> filterIsInstance<Artist>()
|
||||
DisplayMode.SHOW_GENRES -> filterIsInstance<Genre>()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the current navigation status
|
||||
* @param value Whether LibraryFragment is navigating or not
|
||||
|
|
|
@ -3,8 +3,6 @@ package org.oxycblt.auxio.ui
|
|||
import android.content.Context
|
||||
import android.content.res.Resources
|
||||
import android.text.Spanned
|
||||
import android.util.TypedValue
|
||||
import androidx.annotation.AttrRes
|
||||
import androidx.annotation.ColorInt
|
||||
import androidx.annotation.ColorRes
|
||||
import androidx.core.content.ContextCompat
|
||||
|
@ -96,29 +94,6 @@ fun Int.toColor(context: Context): Int {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolve an attribute into a color.
|
||||
* @param context [Context] required
|
||||
* @param attr The Resource ID for the attribute
|
||||
* @return The resolved color for that attribute. Black if the process failed.
|
||||
*/
|
||||
@ColorInt
|
||||
fun resolveAttr(context: Context, @AttrRes attr: Int): Int {
|
||||
// Convert the attribute into its color
|
||||
val resolvedAttr = TypedValue().apply {
|
||||
context.theme.resolveAttribute(attr, this, true)
|
||||
}
|
||||
|
||||
// Then convert it to a proper color
|
||||
val color = if (resolvedAttr.resourceId != 0) {
|
||||
resolvedAttr.resourceId
|
||||
} else {
|
||||
resolvedAttr.data
|
||||
}
|
||||
|
||||
return color.toColor(context)
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of an accent.
|
||||
* @param context [Context] required
|
||||
|
|
Loading…
Reference in a new issue