mirror of
https://github.com/libre-tube/LibreTube.git
synced 2024-12-13 22:00:30 +05:30
Merge pull request #6739 from Bnyro/master
refactor: reimplement stats for nerds
This commit is contained in:
commit
383ca730ab
@ -815,18 +815,38 @@ object PlayerHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@OptIn(androidx.media3.common.util.UnstableApi::class)
|
@OptIn(androidx.media3.common.util.UnstableApi::class)
|
||||||
fun getVideoStats(player: ExoPlayer, videoId: String): VideoStats {
|
fun getVideoStats(tracks: Tracks, videoId: String): VideoStats {
|
||||||
val videoInfo = "${player.videoFormat?.codecs.orEmpty()} ${
|
val videoStats = VideoStats(videoId, "", "", "")
|
||||||
TextUtils.formatBitrate(
|
|
||||||
player.videoFormat?.bitrate
|
for (group in tracks.groups) {
|
||||||
)
|
if (!group.isSelected || group.length == 0) continue
|
||||||
}"
|
|
||||||
val audioInfo = "${player.audioFormat?.codecs.orEmpty()} ${
|
when (group.type) {
|
||||||
TextUtils.formatBitrate(player.audioFormat?.bitrate)
|
C.TRACK_TYPE_AUDIO -> {
|
||||||
}"
|
val audioFormat = (0..group.length).firstOrNull { index ->
|
||||||
val videoQuality =
|
group.isTrackSelected(index)
|
||||||
"${player.videoFormat?.width}x${player.videoFormat?.height} ${player.videoFormat?.frameRate?.toInt()}fps"
|
}?.let { index -> group.getTrackFormat(index) } ?: continue
|
||||||
return VideoStats(videoId, videoInfo, videoQuality, audioInfo)
|
|
||||||
|
videoStats.audioInfo = "${audioFormat.codecs.orEmpty()} ${
|
||||||
|
TextUtils.formatBitrate(audioFormat.bitrate)
|
||||||
|
}"
|
||||||
|
}
|
||||||
|
|
||||||
|
C.TRACK_TYPE_VIDEO -> {
|
||||||
|
val videoFormat = (0..group.length).firstOrNull { index ->
|
||||||
|
group.isTrackSelected(index)
|
||||||
|
}?.let { index -> group.getTrackFormat(index) } ?: continue
|
||||||
|
|
||||||
|
videoStats.videoInfo = "${videoFormat.codecs.orEmpty()} ${
|
||||||
|
TextUtils.formatBitrate(videoFormat.bitrate)
|
||||||
|
}"
|
||||||
|
videoStats.videoQuality =
|
||||||
|
"${videoFormat.width}x${videoFormat.height} ${videoFormat.frameRate.toInt()}fps"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return videoStats
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getPlayPauseActionIcon(player: Player) = when {
|
fun getPlayPauseActionIcon(player: Player) = when {
|
||||||
|
@ -6,7 +6,7 @@ import kotlinx.parcelize.Parcelize
|
|||||||
@Parcelize
|
@Parcelize
|
||||||
data class VideoStats(
|
data class VideoStats(
|
||||||
val videoId: String,
|
val videoId: String,
|
||||||
val videoInfo: String,
|
var videoInfo: String,
|
||||||
val videoQuality: String,
|
var videoQuality: String,
|
||||||
val audioInfo: String
|
var audioInfo: String
|
||||||
) : Parcelable
|
) : Parcelable
|
||||||
|
@ -106,6 +106,7 @@ import com.github.libretube.ui.models.CommonPlayerViewModel
|
|||||||
import com.github.libretube.ui.models.PlayerViewModel
|
import com.github.libretube.ui.models.PlayerViewModel
|
||||||
import com.github.libretube.ui.sheets.BaseBottomSheet
|
import com.github.libretube.ui.sheets.BaseBottomSheet
|
||||||
import com.github.libretube.ui.sheets.CommentsSheet
|
import com.github.libretube.ui.sheets.CommentsSheet
|
||||||
|
import com.github.libretube.ui.sheets.StatsSheet
|
||||||
import com.github.libretube.util.OnlineTimeFrameReceiver
|
import com.github.libretube.util.OnlineTimeFrameReceiver
|
||||||
import com.github.libretube.util.PauseableTimer
|
import com.github.libretube.util.PauseableTimer
|
||||||
import com.github.libretube.util.PlayingQueue
|
import com.github.libretube.util.PlayingQueue
|
||||||
@ -153,7 +154,7 @@ class PlayerFragment : Fragment(), OnlinePlayerOptions {
|
|||||||
// if null, use same quality as fullscreen
|
// if null, use same quality as fullscreen
|
||||||
private var noFullscreenResolution: Int? = null
|
private var noFullscreenResolution: Int? = null
|
||||||
|
|
||||||
private var selectedAudioLanguageAndRoleFlags: Pair<String?, @C. RoleFlags Int>? = null
|
private var selectedAudioLanguageAndRoleFlags: Pair<String?, @C.RoleFlags Int>? = null
|
||||||
|
|
||||||
private val handler = Handler(Looper.getMainLooper())
|
private val handler = Handler(Looper.getMainLooper())
|
||||||
|
|
||||||
@ -1421,11 +1422,11 @@ class PlayerFragment : Fragment(), OnlinePlayerOptions {
|
|||||||
|
|
||||||
override fun onStatsClicked() {
|
override fun onStatsClicked() {
|
||||||
if (!this::streams.isInitialized) return
|
if (!this::streams.isInitialized) return
|
||||||
// TODO: reimplement video stats
|
|
||||||
// val videoStats = getVideoStats(playerController, videoId)
|
val videoStats = PlayerHelper.getVideoStats(playerController.currentTracks, videoId)
|
||||||
// StatsSheet()
|
StatsSheet()
|
||||||
// .apply { arguments = bundleOf(IntentData.videoStats to videoStats) }
|
.apply { arguments = bundleOf(IntentData.videoStats to videoStats) }
|
||||||
// .show(childFragmentManager)
|
.show(childFragmentManager)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onPictureInPictureModeChanged(isInPictureInPictureMode: Boolean) {
|
override fun onPictureInPictureModeChanged(isInPictureInPictureMode: Boolean) {
|
||||||
|
Loading…
Reference in New Issue
Block a user