mirror of
https://gitlab.futo.org/videostreaming/grayjay.git
synced 2025-08-21 09:49:29 +00:00
fix delay when opening quality overlay
Changelog: changed
This commit is contained in:
parent
e1abb7f8ae
commit
db5aaf0b84
2 changed files with 36 additions and 25 deletions
|
@ -370,6 +370,33 @@ class ShortView : FrameLayout {
|
||||||
dislikeContainer.visibility = VISIBLE
|
dislikeContainer.visibility = VISIBLE
|
||||||
likeContainer.visibility = VISIBLE
|
likeContainer.visibility = VISIBLE
|
||||||
}
|
}
|
||||||
|
|
||||||
|
player.onPlaybackStateChanged.subscribe {
|
||||||
|
val videoSource = _lastVideoSource
|
||||||
|
|
||||||
|
if (videoSource is IDashManifestSource || videoSource is IHLSManifestSource) {
|
||||||
|
val videoTracks =
|
||||||
|
player.exoPlayer?.player?.currentTracks?.groups?.firstOrNull { it.mediaTrackGroup.type == C.TRACK_TYPE_VIDEO }
|
||||||
|
val audioTracks =
|
||||||
|
player.exoPlayer?.player?.currentTracks?.groups?.firstOrNull { it.mediaTrackGroup.type == C.TRACK_TYPE_AUDIO }
|
||||||
|
|
||||||
|
val videoTrackFormats = mutableListOf<Format>()
|
||||||
|
val audioTrackFormats = mutableListOf<Format>()
|
||||||
|
|
||||||
|
if (videoTracks != null) {
|
||||||
|
for (i in 0 until videoTracks.mediaTrackGroup.length) videoTrackFormats.add(videoTracks.mediaTrackGroup.getFormat(i))
|
||||||
|
}
|
||||||
|
if (audioTracks != null) {
|
||||||
|
for (i in 0 until audioTracks.mediaTrackGroup.length) audioTrackFormats.add(audioTracks.mediaTrackGroup.getFormat(i))
|
||||||
|
}
|
||||||
|
|
||||||
|
updateQualitySourcesOverlay(videoDetails, null, videoTrackFormats.distinctBy { it.height }
|
||||||
|
.sortedBy { it.height }, audioTrackFormats.distinctBy { it.bitrate }
|
||||||
|
.sortedBy { it.bitrate })
|
||||||
|
} else {
|
||||||
|
updateQualitySourcesOverlay(videoDetails, null)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun showPlayPauseIcon() {
|
private fun showPlayPauseIcon() {
|
||||||
|
@ -544,31 +571,6 @@ class ShortView : FrameLayout {
|
||||||
private fun showVideoSettings() {
|
private fun showVideoSettings() {
|
||||||
Logger.i(TAG, "showVideoSettings")
|
Logger.i(TAG, "showVideoSettings")
|
||||||
|
|
||||||
val videoSource = _lastVideoSource
|
|
||||||
|
|
||||||
if (videoSource is IDashManifestSource || videoSource is IHLSManifestSource) {
|
|
||||||
val videoTracks =
|
|
||||||
player.exoPlayer?.player?.currentTracks?.groups?.firstOrNull { it.mediaTrackGroup.type == C.TRACK_TYPE_VIDEO }
|
|
||||||
val audioTracks =
|
|
||||||
player.exoPlayer?.player?.currentTracks?.groups?.firstOrNull { it.mediaTrackGroup.type == C.TRACK_TYPE_AUDIO }
|
|
||||||
|
|
||||||
val videoTrackFormats = mutableListOf<Format>()
|
|
||||||
val audioTrackFormats = mutableListOf<Format>()
|
|
||||||
|
|
||||||
if (videoTracks != null) {
|
|
||||||
for (i in 0 until videoTracks.mediaTrackGroup.length) videoTrackFormats.add(videoTracks.mediaTrackGroup.getFormat(i))
|
|
||||||
}
|
|
||||||
if (audioTracks != null) {
|
|
||||||
for (i in 0 until audioTracks.mediaTrackGroup.length) audioTrackFormats.add(audioTracks.mediaTrackGroup.getFormat(i))
|
|
||||||
}
|
|
||||||
|
|
||||||
updateQualitySourcesOverlay(videoDetails, null, videoTrackFormats.distinctBy { it.height }
|
|
||||||
.sortedBy { it.height }, audioTrackFormats.distinctBy { it.bitrate }
|
|
||||||
.sortedBy { it.bitrate })
|
|
||||||
} else {
|
|
||||||
updateQualitySourcesOverlay(videoDetails, null)
|
|
||||||
}
|
|
||||||
|
|
||||||
overlayQualitySelector?.selectOption("video", _lastVideoSource)
|
overlayQualitySelector?.selectOption("video", _lastVideoSource)
|
||||||
overlayQualitySelector?.selectOption("audio", _lastAudioSource)
|
overlayQualitySelector?.selectOption("audio", _lastAudioSource)
|
||||||
overlayQualitySelector?.selectOption("subtitles", _lastSubtitleSource)
|
overlayQualitySelector?.selectOption("subtitles", _lastSubtitleSource)
|
||||||
|
@ -819,6 +821,8 @@ class ShortView : FrameLayout {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
updateQualitySourcesOverlay(videoDetails, null)
|
||||||
|
|
||||||
try {
|
try {
|
||||||
val videoSource = _lastVideoSource
|
val videoSource = _lastVideoSource
|
||||||
?: player.getPreferredVideoSource(videoDetails, Settings.instance.playback.getCurrentPreferredQualityPixelCount())
|
?: player.getPreferredVideoSource(videoDetails, Settings.instance.playback.getCurrentPreferredQualityPixelCount())
|
||||||
|
|
|
@ -14,6 +14,7 @@ import androidx.media3.ui.DefaultTimeBar
|
||||||
import androidx.media3.ui.PlayerView
|
import androidx.media3.ui.PlayerView
|
||||||
import androidx.media3.ui.TimeBar
|
import androidx.media3.ui.TimeBar
|
||||||
import com.futo.platformplayer.R
|
import com.futo.platformplayer.R
|
||||||
|
import com.futo.platformplayer.constructs.Event1
|
||||||
import com.futo.platformplayer.logging.Logger
|
import com.futo.platformplayer.logging.Logger
|
||||||
import com.futo.platformplayer.states.StatePlayer
|
import com.futo.platformplayer.states.StatePlayer
|
||||||
import com.futo.platformplayer.video.PlayerManager
|
import com.futo.platformplayer.video.PlayerManager
|
||||||
|
@ -33,6 +34,8 @@ class FutoShortPlayer(context: Context, attrs: AttributeSet? = null) :
|
||||||
private lateinit var player: PlayerManager
|
private lateinit var player: PlayerManager
|
||||||
private var progressAnimator: ValueAnimator = createProgressBarAnimator()
|
private var progressAnimator: ValueAnimator = createProgressBarAnimator()
|
||||||
|
|
||||||
|
val onPlaybackStateChanged = Event1<Int>();
|
||||||
|
|
||||||
private var playerEventListener = object : Player.Listener {
|
private var playerEventListener = object : Player.Listener {
|
||||||
override fun onEvents(player: Player, events: Player.Events) {
|
override fun onEvents(player: Player, events: Player.Events) {
|
||||||
if (events.containsAny(
|
if (events.containsAny(
|
||||||
|
@ -50,6 +53,10 @@ class FutoShortPlayer(context: Context, attrs: AttributeSet? = null) :
|
||||||
progressAnimator.start()
|
progressAnimator.start()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (events.containsAny(Player.EVENT_PLAYBACK_STATE_CHANGED)) {
|
||||||
|
onPlaybackStateChanged.emit(player.playbackState)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue