mirror of
https://gitlab.futo.org/videostreaming/grayjay.git
synced 2025-05-02 07:34:25 +02:00
Add UI to show when adaptive streams (HLS and DASH) are in auto mode
Changelog: added
This commit is contained in:
parent
891d3cf966
commit
94454172dd
@ -1901,13 +1901,35 @@ class VideoDetailView : ConstraintLayout {
|
|||||||
return super.onInterceptTouchEvent(ev);
|
return super.onInterceptTouchEvent(ev);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//Actions
|
//Actions
|
||||||
private fun showVideoSettings() {
|
private fun showVideoSettings() {
|
||||||
Logger.i(TAG, "showVideoSettings")
|
Logger.i(TAG, "showVideoSettings")
|
||||||
_overlay_quality_selector?.selectOption("video", _lastVideoSource);
|
_overlay_quality_selector?.selectOption("video", _lastVideoSource);
|
||||||
_overlay_quality_selector?.selectOption("audio", _lastAudioSource);
|
_overlay_quality_selector?.selectOption("audio", _lastAudioSource);
|
||||||
_overlay_quality_selector?.selectOption("subtitles", _lastSubtitleSource);
|
_overlay_quality_selector?.selectOption("subtitles", _lastSubtitleSource);
|
||||||
|
|
||||||
|
if (_lastVideoSource is IDashManifestSource || _lastVideoSource is IHLSManifestSource) {
|
||||||
|
|
||||||
|
val videoTracks =
|
||||||
|
_player.exoPlayer?.player?.currentTracks?.groups?.firstOrNull { it.mediaTrackGroup.type == C.TRACK_TYPE_VIDEO }
|
||||||
|
|
||||||
|
var selectedQuality: Format? = null
|
||||||
|
|
||||||
|
if (videoTracks != null) {
|
||||||
|
for (i in 0 until videoTracks.mediaTrackGroup.length) {
|
||||||
|
if (videoTracks.mediaTrackGroup.getFormat(i).height == _player.targetTrackVideoHeight) {
|
||||||
|
selectedQuality = videoTracks.mediaTrackGroup.getFormat(i)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (selectedQuality != null) {
|
||||||
|
_overlay_quality_selector?.selectOption("video", selectedQuality)
|
||||||
|
} else {
|
||||||
|
_overlay_quality_selector?.selectOption("video", "auto")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
val currentPlaybackRate = (if (_isCasting) StateCasting.instance.activeDevice?.speed else _player.getPlaybackRate()) ?: 1.0
|
val currentPlaybackRate = (if (_isCasting) StateCasting.instance.activeDevice?.speed else _player.getPlaybackRate()) ?: 1.0
|
||||||
_overlay_quality_selector?.groupItems?.firstOrNull { it is SlideUpMenuButtonList && it.id == "playback_rate" }?.let {
|
_overlay_quality_selector?.groupItems?.firstOrNull { it is SlideUpMenuButtonList && it.id == "playback_rate" }?.let {
|
||||||
(it as SlideUpMenuButtonList).setSelected(currentPlaybackRate.toString())
|
(it as SlideUpMenuButtonList).setSelected(currentPlaybackRate.toString())
|
||||||
@ -2081,17 +2103,15 @@ class VideoDetailView : ConstraintLayout {
|
|||||||
call = { handleSelectSubtitleTrack(it) })
|
call = { handleSelectSubtitleTrack(it) })
|
||||||
}.toList().toTypedArray())
|
}.toList().toTypedArray())
|
||||||
else null,
|
else null,
|
||||||
if(liveStreamVideoFormats?.isEmpty() == false)
|
if (liveStreamVideoFormats?.isEmpty() == false) SlideUpMenuGroup(
|
||||||
SlideUpMenuGroup(this.context, context.getString(R.string.stream_video), "video",
|
this.context, context.getString(R.string.stream_video), "video", (listOf(
|
||||||
*liveStreamVideoFormats
|
SlideUpMenuItem(this.context, R.drawable.ic_movie, "Auto", tag = "auto", call = { _player.selectVideoTrack(-1) })
|
||||||
.map {
|
) + (liveStreamVideoFormats.map {
|
||||||
SlideUpMenuItem(this.context,
|
SlideUpMenuItem(this.context, R.drawable.ic_movie, it.label
|
||||||
R.drawable.ic_movie,
|
?: it.containerMimeType
|
||||||
it.label ?: it.containerMimeType ?: it.bitrate.toString(),
|
?: it.bitrate.toString(), "${it.width}x${it.height}", tag = it, call = { _player.selectVideoTrack(it.height) });
|
||||||
"${it.width}x${it.height}",
|
}))
|
||||||
tag = it,
|
)
|
||||||
call = { _player.selectVideoTrack(it.height) });
|
|
||||||
}.toList().toTypedArray())
|
|
||||||
else null,
|
else null,
|
||||||
if(liveStreamAudioFormats?.isEmpty() == false)
|
if(liveStreamAudioFormats?.isEmpty() == false)
|
||||||
SlideUpMenuGroup(this.context, context.getString(R.string.stream_audio), "audio",
|
SlideUpMenuGroup(this.context, context.getString(R.string.stream_audio), "audio",
|
||||||
|
@ -110,8 +110,10 @@ abstract class FutoVideoPlayerBase : RelativeLayout {
|
|||||||
private var _didCallSourceChange = false;
|
private var _didCallSourceChange = false;
|
||||||
private var _lastState: Int = -1;
|
private var _lastState: Int = -1;
|
||||||
|
|
||||||
private var _targetTrackVideoHeight = -1;
|
|
||||||
private var _targetTrackAudioBitrate = -1;
|
var targetTrackVideoHeight = -1
|
||||||
|
private set
|
||||||
|
var _targetTrackAudioBitrate = -1
|
||||||
|
|
||||||
private var _toResume = false;
|
private var _toResume = false;
|
||||||
|
|
||||||
@ -278,7 +280,7 @@ abstract class FutoVideoPlayerBase : RelativeLayout {
|
|||||||
|
|
||||||
//TODO: Temporary solution, Implement custom track selector without using constraints
|
//TODO: Temporary solution, Implement custom track selector without using constraints
|
||||||
fun selectVideoTrack(height: Int) {
|
fun selectVideoTrack(height: Int) {
|
||||||
_targetTrackVideoHeight = height;
|
targetTrackVideoHeight = height;
|
||||||
updateTrackSelector();
|
updateTrackSelector();
|
||||||
}
|
}
|
||||||
fun selectAudioTrack(bitrate: Int) {
|
fun selectAudioTrack(bitrate: Int) {
|
||||||
@ -288,10 +290,10 @@ abstract class FutoVideoPlayerBase : RelativeLayout {
|
|||||||
@OptIn(UnstableApi::class)
|
@OptIn(UnstableApi::class)
|
||||||
private fun updateTrackSelector() {
|
private fun updateTrackSelector() {
|
||||||
var builder = DefaultTrackSelector.Parameters.Builder(context);
|
var builder = DefaultTrackSelector.Parameters.Builder(context);
|
||||||
if(_targetTrackVideoHeight > 0) {
|
if(targetTrackVideoHeight > 0) {
|
||||||
builder = builder
|
builder = builder
|
||||||
.setMinVideoSize(0, _targetTrackVideoHeight - 10)
|
.setMinVideoSize(0, targetTrackVideoHeight - 10)
|
||||||
.setMaxVideoSize(9999, _targetTrackVideoHeight + 10);
|
.setMaxVideoSize(9999, targetTrackVideoHeight + 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(_targetTrackAudioBitrate > 0) {
|
if(_targetTrackAudioBitrate > 0) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user