feat(player): play music at 1x speed (#4634)

Co-authored-by: Bnyro <82752168+Bnyro@users.noreply.github.com>
This commit is contained in:
FineFindus 2023-08-26 19:52:16 +02:00 committed by GitHub
parent d4e10c55d6
commit 85ba045539
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 11 additions and 3 deletions

View File

@ -91,4 +91,8 @@ data class Streams(
shortDescription = description
)
}
companion object {
const val categoryMusic = "Music"
}
}

View File

@ -6,7 +6,6 @@ import androidx.core.content.edit
import androidx.preference.PreferenceManager
import com.github.libretube.constants.PreferenceKeys
import java.time.Instant
import java.util.UUID
object PreferenceHelper {
/**

View File

@ -101,7 +101,6 @@ import com.github.libretube.ui.adapters.VideosAdapter
import com.github.libretube.ui.dialogs.AddToPlaylistDialog
import com.github.libretube.ui.dialogs.DownloadDialog
import com.github.libretube.ui.dialogs.ShareDialog
import com.github.libretube.ui.sheets.StatsSheet
import com.github.libretube.ui.extensions.setupSubscriptionButton
import com.github.libretube.ui.interfaces.OnlinePlayerOptions
import com.github.libretube.ui.listeners.SeekbarPreviewListener
@ -111,6 +110,7 @@ import com.github.libretube.ui.sheets.BaseBottomSheet
import com.github.libretube.ui.sheets.ChaptersBottomSheet
import com.github.libretube.ui.sheets.CommentsSheet
import com.github.libretube.ui.sheets.PlayingQueueSheet
import com.github.libretube.ui.sheets.StatsSheet
import com.github.libretube.util.HtmlParser
import com.github.libretube.util.LinkHandler
import com.github.libretube.util.NowPlayingNotification
@ -938,6 +938,12 @@ class PlayerFragment : Fragment(), OnlinePlayerOptions {
override fun onPlaybackStateChanged(playbackState: Int) {
saveWatchPosition()
if (playbackState == Player.STATE_READY) {
if (streams.category == Streams.categoryMusic) {
exoPlayer.setPlaybackSpeed(1f)
}
}
// set the playback speed to one if having reached the end of a livestream
if (playbackState == Player.STATE_BUFFERING && binding.player.isLive &&
exoPlayer.duration - exoPlayer.currentPosition < 700

View File

@ -7,7 +7,6 @@ import android.view.View
import android.view.ViewGroup
import androidx.media3.exoplayer.ExoPlayer
import com.github.libretube.databinding.DialogStatsBinding
import com.github.libretube.ui.sheets.ExpandedBottomSheet
import com.github.libretube.util.TextUtils
class StatsSheet(