mirror of
https://gitlab.com/vyla-entertainment/TV.git
synced 2026-11-19 22:47:21 -05:00
playback improvements, dependancy updates, and updated SDK
This commit is contained in:
@@ -152,6 +152,7 @@ fun PlayerScreen(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun showControlsAndFocusPlay() {
|
fun showControlsAndFocusPlay() {
|
||||||
areControlsVisible = true
|
areControlsVisible = true
|
||||||
resetHideTimer()
|
resetHideTimer()
|
||||||
@@ -162,6 +163,7 @@ fun PlayerScreen(
|
|||||||
} catch (_: Exception) {}
|
} catch (_: Exception) {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val exoPlayer = remember {
|
val exoPlayer = remember {
|
||||||
ExoPlayer.Builder(context).build().apply {
|
ExoPlayer.Builder(context).build().apply {
|
||||||
playWhenReady = true
|
playWhenReady = true
|
||||||
@@ -172,6 +174,7 @@ fun PlayerScreen(
|
|||||||
durationMs = duration.coerceAtLeast(0L)
|
durationMs = duration.coerceAtLeast(0L)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onIsPlayingChanged(playing: Boolean) {
|
override fun onIsPlayingChanged(playing: Boolean) {
|
||||||
isPlaying = playing
|
isPlaying = playing
|
||||||
if (playing) {
|
if (playing) {
|
||||||
@@ -226,32 +229,36 @@ fun PlayerScreen(
|
|||||||
resetHideTimer()
|
resetHideTimer()
|
||||||
}
|
}
|
||||||
DisposableEffect(exoPlayer) {
|
DisposableEffect(exoPlayer) {
|
||||||
val errorListener = object : Player.Listener { // source auto-fallback
|
val errorListener = object : Player.Listener { // source auto-fallback
|
||||||
override fun onPlayerError(error: androidx.media3.common.PlaybackException) {
|
override fun onPlayerError(error: androidx.media3.common.PlaybackException) {
|
||||||
val currentIdx = resolvedStreams.indexOf(activeStream)
|
val currentIdx = resolvedStreams.indexOf(activeStream)
|
||||||
if (currentIdx != -1 && currentIdx + 1 < resolvedStreams.size) {
|
if (currentIdx != -1 && currentIdx + 1 < resolvedStreams.size) {
|
||||||
// android.widget.Toast.makeText(context, "Source failed. Trying next...", android.widget.Toast.LENGTH_SHORT).show()
|
// android.widget.Toast.makeText(context, "Source failed. Trying next...", android.widget.Toast.LENGTH_SHORT).show()
|
||||||
Log.e("vyla", "Source failed. Trying next...")
|
Log.e("vyla", "Source failed. Trying next...")
|
||||||
|
|
||||||
coroutineScope.launch {
|
coroutineScope.launch {
|
||||||
delay(1500) // follow rate limits
|
delay(1500) // follow rate limits
|
||||||
val nextStream = resolvedStreams[currentIdx + 1]
|
val nextStream = resolvedStreams[currentIdx + 1]
|
||||||
activeStream = nextStream
|
activeStream = nextStream
|
||||||
playStream(nextStream.primaryUrl, nextStream.headers)
|
playStream(nextStream.primaryUrl, nextStream.headers)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
isBuffering = false
|
||||||
|
Log.e("vyla", "All Sources Failed")
|
||||||
|
android.widget.Toast.makeText(
|
||||||
|
context,
|
||||||
|
"All available sources failed. Please disable any VPN or try again later",
|
||||||
|
android.widget.Toast.LENGTH_LONG
|
||||||
|
).show()
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
isBuffering = false
|
|
||||||
Log.e("vyla", "All Sources Failed")
|
|
||||||
android.widget.Toast.makeText(context, "All available sources failed. Please disable any VPN or try again later", android.widget.Toast.LENGTH_LONG).show()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
exoPlayer.addListener(errorListener)
|
||||||
|
|
||||||
|
onDispose {
|
||||||
|
exoPlayer.removeListener(errorListener)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
exoPlayer.addListener(errorListener)
|
|
||||||
|
|
||||||
onDispose {
|
|
||||||
exoPlayer.removeListener(errorListener)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
suspend fun focusEpisodeCard() {
|
suspend fun focusEpisodeCard() {
|
||||||
var tries = 0
|
var tries = 0
|
||||||
while (tries < 15) {
|
while (tries < 15) {
|
||||||
@@ -260,9 +267,11 @@ fun PlayerScreen(
|
|||||||
try {
|
try {
|
||||||
episodeFocusRequester.requestFocus()
|
episodeFocusRequester.requestFocus()
|
||||||
return
|
return
|
||||||
} catch (_: Exception) {}
|
} catch (_: Exception) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun loadSeasonEpisodes(seasonNum: Int, focusFirst: Boolean = false) {
|
fun loadSeasonEpisodes(seasonNum: Int, focusFirst: Boolean = false) {
|
||||||
selectedSeasonNum = seasonNum
|
selectedSeasonNum = seasonNum
|
||||||
coroutineScope.launch {
|
coroutineScope.launch {
|
||||||
@@ -367,26 +376,31 @@ fun PlayerScreen(
|
|||||||
}
|
}
|
||||||
|
|
||||||
BackHandler {
|
BackHandler {
|
||||||
when {
|
fun closeActiveMenu() {
|
||||||
activeMenu != ActivePlayerMenu.NONE -> {
|
val closedMenu = activeMenu
|
||||||
val closedMenu = activeMenu
|
activeMenu = ActivePlayerMenu.NONE
|
||||||
activeMenu = ActivePlayerMenu.NONE
|
areControlsVisible = true
|
||||||
areControlsVisible = true
|
resetHideTimer()
|
||||||
resetHideTimer()
|
coroutineScope.launch {
|
||||||
coroutineScope.launch {
|
delay(50)
|
||||||
delay(50)
|
try {
|
||||||
try {
|
when (closedMenu) {
|
||||||
when (closedMenu) {
|
ActivePlayerMenu.QUALITY -> qualityButtonFocusRequester.requestFocus()
|
||||||
ActivePlayerMenu.QUALITY -> qualityButtonFocusRequester.requestFocus()
|
ActivePlayerMenu.SUBTITLES -> ccButtonFocusRequester.requestFocus()
|
||||||
ActivePlayerMenu.SUBTITLES -> ccButtonFocusRequester.requestFocus()
|
ActivePlayerMenu.VOLUME -> volButtonFocusRequester.requestFocus()
|
||||||
ActivePlayerMenu.VOLUME -> volButtonFocusRequester.requestFocus()
|
ActivePlayerMenu.SETTINGS -> setButtonFocusRequester.requestFocus()
|
||||||
ActivePlayerMenu.SETTINGS -> setButtonFocusRequester.requestFocus()
|
ActivePlayerMenu.MORE -> moreButtonFocusRequester.requestFocus()
|
||||||
ActivePlayerMenu.MORE -> moreButtonFocusRequester.requestFocus()
|
else -> playPauseFocusRequester.requestFocus()
|
||||||
else -> playPauseFocusRequester.requestFocus()
|
}
|
||||||
}
|
} catch (_: Exception) {
|
||||||
} catch (_: Exception) {}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
when {
|
||||||
|
activeMenu != ActivePlayerMenu.NONE -> {
|
||||||
|
closeActiveMenu()
|
||||||
|
}
|
||||||
|
|
||||||
isEpisodesDrawerOpen -> {
|
isEpisodesDrawerOpen -> {
|
||||||
isEpisodesDrawerOpen = false
|
isEpisodesDrawerOpen = false
|
||||||
areControlsVisible = true
|
areControlsVisible = true
|
||||||
@@ -395,12 +409,20 @@ fun PlayerScreen(
|
|||||||
delay(50)
|
delay(50)
|
||||||
try {
|
try {
|
||||||
episodesButtonFocusRequester.requestFocus()
|
episodesButtonFocusRequester.requestFocus()
|
||||||
} catch (_: Exception) {}
|
} catch (_: Exception) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
areControlsVisible -> {
|
areControlsVisible -> {
|
||||||
|
hideControlsJob?.cancel()
|
||||||
areControlsVisible = false
|
areControlsVisible = false
|
||||||
|
try {
|
||||||
|
playerContainerFocusRequester.requestFocus()
|
||||||
|
} catch (_: Exception) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
else -> onBack()
|
else -> onBack()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -412,6 +434,7 @@ fun PlayerScreen(
|
|||||||
idx >= 0 && (idx + 1 < allEpisodes.size || seasons.any { it.seasonNumber > ep.seasonNumber })
|
idx >= 0 && (idx + 1 < allEpisodes.size || seasons.any { it.seasonNumber > ep.seasonNumber })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun playNextEpisode() {
|
fun playNextEpisode() {
|
||||||
val ep = currentEpisode ?: return
|
val ep = currentEpisode ?: return
|
||||||
val idx = allEpisodes.indexOfFirst { it.episodeNumber == ep.episodeNumber }
|
val idx = allEpisodes.indexOfFirst { it.episodeNumber == ep.episodeNumber }
|
||||||
@@ -450,6 +473,25 @@ fun PlayerScreen(
|
|||||||
playerViewRef?.videoSurfaceView
|
playerViewRef?.videoSurfaceView
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun closeActiveMenu() {
|
||||||
|
val closedMenu = activeMenu
|
||||||
|
activeMenu = ActivePlayerMenu.NONE
|
||||||
|
resetHideTimer()
|
||||||
|
coroutineScope.launch {
|
||||||
|
delay(50)
|
||||||
|
try {
|
||||||
|
when (closedMenu) {
|
||||||
|
ActivePlayerMenu.QUALITY -> qualityButtonFocusRequester.requestFocus()
|
||||||
|
ActivePlayerMenu.SUBTITLES -> ccButtonFocusRequester.requestFocus()
|
||||||
|
ActivePlayerMenu.VOLUME -> volButtonFocusRequester.requestFocus()
|
||||||
|
ActivePlayerMenu.SETTINGS -> setButtonFocusRequester.requestFocus()
|
||||||
|
ActivePlayerMenu.MORE -> moreButtonFocusRequester.requestFocus()
|
||||||
|
else -> playPauseFocusRequester.requestFocus()
|
||||||
|
}
|
||||||
|
} catch (_: Exception) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Box(
|
Box(
|
||||||
modifier = modifier
|
modifier = modifier
|
||||||
.fillMaxSize()
|
.fillMaxSize()
|
||||||
@@ -461,10 +503,14 @@ fun PlayerScreen(
|
|||||||
val code = event.nativeKeyEvent.keyCode
|
val code = event.nativeKeyEvent.keyCode
|
||||||
|
|
||||||
if (!areControlsVisible) {
|
if (!areControlsVisible) {
|
||||||
|
if (code == KeyEvent.KEYCODE_BACK || code == KeyEvent.KEYCODE_ESCAPE) { // defer to backhandler
|
||||||
|
return@onKeyEvent false
|
||||||
|
}
|
||||||
val pendingSegment = activeSegment
|
val pendingSegment = activeSegment
|
||||||
val isConfirm = code == KeyEvent.KEYCODE_DPAD_CENTER ||
|
val isConfirm = code == KeyEvent.KEYCODE_DPAD_CENTER ||
|
||||||
code == KeyEvent.KEYCODE_ENTER ||
|
code == KeyEvent.KEYCODE_ENTER ||
|
||||||
code == KeyEvent.KEYCODE_NUMPAD_ENTER
|
code == KeyEvent.KEYCODE_NUMPAD_ENTER
|
||||||
|
|
||||||
if (pendingSegment != null && isConfirm && activeMenu == ActivePlayerMenu.NONE && !isEpisodesDrawerOpen) {
|
if (pendingSegment != null && isConfirm && activeMenu == ActivePlayerMenu.NONE && !isEpisodesDrawerOpen) {
|
||||||
skipSegment(pendingSegment)
|
skipSegment(pendingSegment)
|
||||||
return@onKeyEvent true
|
return@onKeyEvent true
|
||||||
@@ -476,41 +522,70 @@ fun PlayerScreen(
|
|||||||
return@onKeyEvent true
|
return@onKeyEvent true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (code == KeyEvent.KEYCODE_BACK || code == KeyEvent.KEYCODE_ESCAPE) {
|
||||||
|
when {
|
||||||
|
activeMenu != ActivePlayerMenu.NONE -> {
|
||||||
|
return@onKeyEvent false // defer to backhandler
|
||||||
|
}
|
||||||
|
|
||||||
|
isEpisodesDrawerOpen -> {
|
||||||
|
return@onKeyEvent false // defer to backhandler
|
||||||
|
}
|
||||||
|
|
||||||
|
else -> { // hide controls
|
||||||
|
|
||||||
|
hideControlsJob?.cancel()
|
||||||
|
areControlsVisible = false
|
||||||
|
try {
|
||||||
|
playerContainerFocusRequester.requestFocus()
|
||||||
|
} catch (_: Exception) {
|
||||||
|
}
|
||||||
|
return@onKeyEvent true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
when (code) {
|
when (code) {
|
||||||
KeyEvent.KEYCODE_MEDIA_PLAY -> {
|
KeyEvent.KEYCODE_MEDIA_PLAY -> {
|
||||||
exoPlayer.play()
|
exoPlayer.play()
|
||||||
showControlsAndFocusPlay()
|
showControlsAndFocusPlay()
|
||||||
return@onKeyEvent true
|
return@onKeyEvent true
|
||||||
}
|
}
|
||||||
|
|
||||||
KeyEvent.KEYCODE_MEDIA_PAUSE -> {
|
KeyEvent.KEYCODE_MEDIA_PAUSE -> {
|
||||||
exoPlayer.pause()
|
exoPlayer.pause()
|
||||||
showControlsAndFocusPlay()
|
showControlsAndFocusPlay()
|
||||||
return@onKeyEvent true
|
return@onKeyEvent true
|
||||||
}
|
}
|
||||||
|
|
||||||
KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE -> {
|
KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE -> {
|
||||||
if (exoPlayer.isPlaying) exoPlayer.pause() else exoPlayer.play()
|
if (exoPlayer.isPlaying) exoPlayer.pause() else exoPlayer.play()
|
||||||
showControlsAndFocusPlay()
|
showControlsAndFocusPlay()
|
||||||
return@onKeyEvent true
|
return@onKeyEvent true
|
||||||
}
|
}
|
||||||
|
|
||||||
KeyEvent.KEYCODE_MEDIA_FAST_FORWARD -> {
|
KeyEvent.KEYCODE_MEDIA_FAST_FORWARD -> {
|
||||||
exoPlayer.seekTo((exoPlayer.currentPosition + 10000).coerceAtMost(exoPlayer.duration))
|
exoPlayer.seekTo((exoPlayer.currentPosition + 10000).coerceAtMost(exoPlayer.duration))
|
||||||
resetHideTimer()
|
resetHideTimer()
|
||||||
return@onKeyEvent true
|
return@onKeyEvent true
|
||||||
}
|
}
|
||||||
|
|
||||||
KeyEvent.KEYCODE_MEDIA_REWIND -> {
|
KeyEvent.KEYCODE_MEDIA_REWIND -> {
|
||||||
exoPlayer.seekTo((exoPlayer.currentPosition - 10000).coerceAtLeast(0))
|
exoPlayer.seekTo((exoPlayer.currentPosition - 10000).coerceAtLeast(0))
|
||||||
resetHideTimer()
|
resetHideTimer()
|
||||||
return@onKeyEvent true
|
return@onKeyEvent true
|
||||||
}
|
}
|
||||||
|
|
||||||
KeyEvent.KEYCODE_SPACE -> {
|
KeyEvent.KEYCODE_SPACE -> {
|
||||||
if (exoPlayer.isPlaying) exoPlayer.pause() else exoPlayer.play()
|
if (exoPlayer.isPlaying) exoPlayer.pause() else exoPlayer.play()
|
||||||
showControlsAndFocusPlay()
|
showControlsAndFocusPlay()
|
||||||
return@onKeyEvent true
|
return@onKeyEvent true
|
||||||
}
|
}
|
||||||
|
|
||||||
KeyEvent.KEYCODE_BACK -> {
|
KeyEvent.KEYCODE_BACK -> {
|
||||||
resetHideTimer()
|
resetHideTimer()
|
||||||
return@onKeyEvent false
|
return@onKeyEvent false
|
||||||
}
|
}
|
||||||
|
|
||||||
KeyEvent.KEYCODE_DPAD_CENTER -> {
|
KeyEvent.KEYCODE_DPAD_CENTER -> {
|
||||||
resetHideTimer()
|
resetHideTimer()
|
||||||
return@onKeyEvent false
|
return@onKeyEvent false
|
||||||
@@ -529,7 +604,8 @@ fun PlayerScreen(
|
|||||||
isFocusable = false
|
isFocusable = false
|
||||||
isFocusableInTouchMode = false
|
isFocusableInTouchMode = false
|
||||||
descendantFocusability = ViewGroup.FOCUS_BLOCK_DESCENDANTS
|
descendantFocusability = ViewGroup.FOCUS_BLOCK_DESCENDANTS
|
||||||
resizeMode = if (isFillScreen) AspectRatioFrameLayout.RESIZE_MODE_ZOOM else AspectRatioFrameLayout.RESIZE_MODE_FIT
|
resizeMode =
|
||||||
|
if (isFillScreen) AspectRatioFrameLayout.RESIZE_MODE_ZOOM else AspectRatioFrameLayout.RESIZE_MODE_FIT
|
||||||
layoutParams = FrameLayout.LayoutParams(
|
layoutParams = FrameLayout.LayoutParams(
|
||||||
ViewGroup.LayoutParams.MATCH_PARENT,
|
ViewGroup.LayoutParams.MATCH_PARENT,
|
||||||
ViewGroup.LayoutParams.MATCH_PARENT
|
ViewGroup.LayoutParams.MATCH_PARENT
|
||||||
@@ -781,7 +857,8 @@ fun PlayerScreen(
|
|||||||
onLeftPress = {
|
onLeftPress = {
|
||||||
try {
|
try {
|
||||||
seekbarFocusRequester.requestFocus()
|
seekbarFocusRequester.requestFocus()
|
||||||
} catch (_: Exception) {}
|
} catch (_: Exception) {
|
||||||
|
}
|
||||||
},
|
},
|
||||||
onUpPress = {
|
onUpPress = {
|
||||||
try {
|
try {
|
||||||
@@ -800,6 +877,7 @@ fun PlayerScreen(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (activeMenu != ActivePlayerMenu.NONE) {
|
if (activeMenu != ActivePlayerMenu.NONE) {
|
||||||
|
var menuHasFocus by remember { mutableStateOf(false) }
|
||||||
Box(
|
Box(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.align(Alignment.TopEnd)
|
.align(Alignment.TopEnd)
|
||||||
@@ -811,6 +889,30 @@ fun PlayerScreen(
|
|||||||
.border(1.dp, Color(0x33FFFFFF), RoundedCornerShape(18.dp))
|
.border(1.dp, Color(0x33FFFFFF), RoundedCornerShape(18.dp))
|
||||||
.padding(14.dp)
|
.padding(14.dp)
|
||||||
.zIndex(25f)
|
.zIndex(25f)
|
||||||
|
.onFocusChanged { state ->
|
||||||
|
if (menuHasFocus && !state.hasFocus) {
|
||||||
|
// Focus navigated outside the menu popup: dismiss it
|
||||||
|
activeMenu = ActivePlayerMenu.NONE
|
||||||
|
resetHideTimer()
|
||||||
|
}
|
||||||
|
menuHasFocus = state.hasFocus
|
||||||
|
}
|
||||||
|
.onKeyEvent { event ->
|
||||||
|
if (event.type == KeyEventType.KeyDown) {
|
||||||
|
when (event.nativeKeyEvent.keyCode) {
|
||||||
|
KeyEvent.KEYCODE_BACK, KeyEvent.KEYCODE_ESCAPE -> {
|
||||||
|
closeActiveMenu()
|
||||||
|
return@onKeyEvent true
|
||||||
|
}
|
||||||
|
|
||||||
|
KeyEvent.KEYCODE_DPAD_LEFT -> {
|
||||||
|
closeActiveMenu()
|
||||||
|
return@onKeyEvent true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
false
|
||||||
|
}
|
||||||
) {
|
) {
|
||||||
LazyColumn(modifier = Modifier.fillMaxWidth()) {
|
LazyColumn(modifier = Modifier.fillMaxWidth()) {
|
||||||
when (activeMenu) {
|
when (activeMenu) {
|
||||||
@@ -846,6 +948,7 @@ fun PlayerScreen(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ActivePlayerMenu.SUBTITLES -> {
|
ActivePlayerMenu.SUBTITLES -> {
|
||||||
item {
|
item {
|
||||||
MenuSectionHeader("Subtitles")
|
MenuSectionHeader("Subtitles")
|
||||||
@@ -900,7 +1003,11 @@ fun PlayerScreen(
|
|||||||
horizontalArrangement = Arrangement.spacedBy(8.dp),
|
horizontalArrangement = Arrangement.spacedBy(8.dp),
|
||||||
modifier = Modifier.padding(horizontal = 6.dp, vertical = 4.dp)
|
modifier = Modifier.padding(horizontal = 6.dp, vertical = 4.dp)
|
||||||
) {
|
) {
|
||||||
listOf("White" to "#FFFFFF", "Yellow" to "#FFD700", "Cyan" to "#00FFFF").forEach { (name, hex) ->
|
listOf(
|
||||||
|
"White" to "#FFFFFF",
|
||||||
|
"Yellow" to "#FFD700",
|
||||||
|
"Cyan" to "#00FFFF"
|
||||||
|
).forEach { (name, hex) ->
|
||||||
MiniSelectButton(
|
MiniSelectButton(
|
||||||
text = name,
|
text = name,
|
||||||
isSelected = subtitleColorHex == hex,
|
isSelected = subtitleColorHex == hex,
|
||||||
@@ -910,6 +1017,7 @@ fun PlayerScreen(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ActivePlayerMenu.VOLUME -> {
|
ActivePlayerMenu.VOLUME -> {
|
||||||
item {
|
item {
|
||||||
MenuSectionHeader("Volume Control")
|
MenuSectionHeader("Volume Control")
|
||||||
@@ -961,14 +1069,16 @@ fun PlayerScreen(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ActivePlayerMenu.SETTINGS -> {
|
ActivePlayerMenu.SETTINGS -> {
|
||||||
item {
|
item {
|
||||||
MenuSectionHeader("Available Sources (${resolvedStreams.size})")
|
MenuSectionHeader("Available Sources (${resolvedStreams.size})")
|
||||||
}
|
}
|
||||||
items(resolvedStreams) { stream ->
|
itemsIndexed(resolvedStreams) { index, stream ->
|
||||||
MenuItemRow(
|
MenuItemRow(
|
||||||
label = stream.label,
|
label = stream.label,
|
||||||
isSelected = ((activeStream?.provider == stream.provider) && (activeStream?.primaryUrl == stream.primaryUrl)),
|
isSelected = ((activeStream?.provider == stream.provider) && (activeStream?.primaryUrl == stream.primaryUrl)),
|
||||||
|
focusRequester = if (index == 0) menuFirstItemFocusRequester else null,
|
||||||
onClick = {
|
onClick = {
|
||||||
activeStream = stream
|
activeStream = stream
|
||||||
playStream(stream.primaryUrl, stream.headers)
|
playStream(stream.primaryUrl, stream.headers)
|
||||||
@@ -1014,6 +1124,7 @@ fun PlayerScreen(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ActivePlayerMenu.MORE -> {
|
ActivePlayerMenu.MORE -> {
|
||||||
item {
|
item {
|
||||||
MenuSectionHeader("Library")
|
MenuSectionHeader("Library")
|
||||||
@@ -1038,6 +1149,7 @@ fun PlayerScreen(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
else -> {}
|
else -> {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1104,7 +1216,8 @@ fun PlayerScreen(
|
|||||||
delay(50)
|
delay(50)
|
||||||
try {
|
try {
|
||||||
episodesButtonFocusRequester.requestFocus()
|
episodesButtonFocusRequester.requestFocus()
|
||||||
} catch (_: Exception) {}
|
} catch (_: Exception) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
@@ -1135,6 +1248,7 @@ fun PlayerScreen(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
private fun PlayerCircleButton(
|
private fun PlayerCircleButton(
|
||||||
icon: androidx.compose.ui.graphics.vector.ImageVector,
|
icon: androidx.compose.ui.graphics.vector.ImageVector,
|
||||||
@@ -1155,6 +1269,8 @@ private fun PlayerCircleButton(
|
|||||||
.videoTint(isFocused, isSelected)
|
.videoTint(isFocused, isSelected)
|
||||||
.then(if (focusRequester != null) Modifier.focusRequester(focusRequester) else Modifier)
|
.then(if (focusRequester != null) Modifier.focusRequester(focusRequester) else Modifier)
|
||||||
.onFocusChanged { isFocused = it.isFocused }
|
.onFocusChanged { isFocused = it.isFocused }
|
||||||
|
.focusable()
|
||||||
|
.videoTint(isFocused, isSelected)
|
||||||
.onKeyEvent { event ->
|
.onKeyEvent { event ->
|
||||||
if (event.type == KeyEventType.KeyDown && event.nativeKeyEvent.keyCode == KeyEvent.KEYCODE_DPAD_DOWN && onDownPress != null) {
|
if (event.type == KeyEventType.KeyDown && event.nativeKeyEvent.keyCode == KeyEvent.KEYCODE_DPAD_DOWN && onDownPress != null) {
|
||||||
onDownPress()
|
onDownPress()
|
||||||
@@ -1162,7 +1278,6 @@ private fun PlayerCircleButton(
|
|||||||
}
|
}
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
.focusable()
|
|
||||||
.clickable(
|
.clickable(
|
||||||
interactionSource = remember { MutableInteractionSource() },
|
interactionSource = remember { MutableInteractionSource() },
|
||||||
indication = null
|
indication = null
|
||||||
@@ -1176,6 +1291,7 @@ private fun PlayerCircleButton(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
private fun PlayerEpisodesButton(
|
private fun PlayerEpisodesButton(
|
||||||
focusRequester: FocusRequester,
|
focusRequester: FocusRequester,
|
||||||
@@ -1201,6 +1317,7 @@ private fun PlayerEpisodesButton(
|
|||||||
onLeftPress()
|
onLeftPress()
|
||||||
return@onKeyEvent true
|
return@onKeyEvent true
|
||||||
}
|
}
|
||||||
|
|
||||||
KeyEvent.KEYCODE_DPAD_UP -> {
|
KeyEvent.KEYCODE_DPAD_UP -> {
|
||||||
onUpPress()
|
onUpPress()
|
||||||
return@onKeyEvent true
|
return@onKeyEvent true
|
||||||
@@ -1223,6 +1340,7 @@ private fun PlayerEpisodesButton(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
private fun PlayerCenterPlayButton(
|
private fun PlayerCenterPlayButton(
|
||||||
isPlaying: Boolean,
|
isPlaying: Boolean,
|
||||||
@@ -1262,6 +1380,7 @@ private fun PlayerCenterPlayButton(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
private fun PlayerPillButton(
|
private fun PlayerPillButton(
|
||||||
text: String,
|
text: String,
|
||||||
@@ -1309,6 +1428,7 @@ private fun PlayerPillButton(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
private fun PlayerSeekBar(
|
private fun PlayerSeekBar(
|
||||||
currentPositionMs: Long,
|
currentPositionMs: Long,
|
||||||
@@ -1327,7 +1447,10 @@ private fun PlayerSeekBar(
|
|||||||
if (!isFocused) isScrubbingMode = false
|
if (!isFocused) isScrubbingMode = false
|
||||||
}
|
}
|
||||||
val barHeight by animateDpAsState(if (isFocused || isScrubbingMode) 6.dp else 4.dp, label = "bar_height")
|
val barHeight by animateDpAsState(if (isFocused || isScrubbingMode) 6.dp else 4.dp, label = "bar_height")
|
||||||
val thumbScale by animateFloatAsState(if (isScrubbingMode) 1.5f else if (isFocused) 1.3f else 1.0f, label = "thumb_scale")
|
val thumbScale by animateFloatAsState(
|
||||||
|
if (isScrubbingMode) 1.5f else if (isFocused) 1.3f else 1.0f,
|
||||||
|
label = "thumb_scale"
|
||||||
|
)
|
||||||
val progressFraction = if (durationMs > 0) (currentPositionMs.toFloat() / durationMs).coerceIn(0f, 1f) else 0f
|
val progressFraction = if (durationMs > 0) (currentPositionMs.toFloat() / durationMs).coerceIn(0f, 1f) else 0f
|
||||||
val bufferFraction = if (durationMs > 0) (bufferedPositionMs.toFloat() / durationMs).coerceIn(0f, 1f) else 0f
|
val bufferFraction = if (durationMs > 0) (bufferedPositionMs.toFloat() / durationMs).coerceIn(0f, 1f) else 0f
|
||||||
Box(
|
Box(
|
||||||
@@ -1343,12 +1466,14 @@ private fun PlayerSeekBar(
|
|||||||
onUpPress()
|
onUpPress()
|
||||||
return@onKeyEvent true
|
return@onKeyEvent true
|
||||||
}
|
}
|
||||||
|
|
||||||
KeyEvent.KEYCODE_DPAD_DOWN -> {
|
KeyEvent.KEYCODE_DPAD_DOWN -> {
|
||||||
if (onRequestEpisodesFocus != null) {
|
if (onRequestEpisodesFocus != null) {
|
||||||
onRequestEpisodesFocus()
|
onRequestEpisodesFocus()
|
||||||
return@onKeyEvent true
|
return@onKeyEvent true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
KeyEvent.KEYCODE_DPAD_RIGHT -> {
|
KeyEvent.KEYCODE_DPAD_RIGHT -> {
|
||||||
if (isScrubbingMode) {
|
if (isScrubbingMode) {
|
||||||
onSeekRight()
|
onSeekRight()
|
||||||
@@ -1363,10 +1488,12 @@ private fun PlayerSeekBar(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
KeyEvent.KEYCODE_DPAD_LEFT -> {
|
KeyEvent.KEYCODE_DPAD_LEFT -> {
|
||||||
onSeekLeft()
|
onSeekLeft()
|
||||||
return@onKeyEvent true
|
return@onKeyEvent true
|
||||||
}
|
}
|
||||||
|
|
||||||
KeyEvent.KEYCODE_DPAD_CENTER, KeyEvent.KEYCODE_ENTER -> {
|
KeyEvent.KEYCODE_DPAD_CENTER, KeyEvent.KEYCODE_ENTER -> {
|
||||||
isScrubbingMode = !isScrubbingMode
|
isScrubbingMode = !isScrubbingMode
|
||||||
return@onKeyEvent true
|
return@onKeyEvent true
|
||||||
@@ -1434,6 +1561,7 @@ private fun PlayerSeekBar(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
private fun MenuSectionHeader(title: String) {
|
private fun MenuSectionHeader(title: String) {
|
||||||
Text(
|
Text(
|
||||||
@@ -1445,6 +1573,7 @@ private fun MenuSectionHeader(title: String) {
|
|||||||
modifier = Modifier.padding(start = 12.dp, end = 12.dp, top = 12.dp, bottom = 6.dp)
|
modifier = Modifier.padding(start = 12.dp, end = 12.dp, top = 12.dp, bottom = 6.dp)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
private fun MenuItemRow(
|
private fun MenuItemRow(
|
||||||
label: String,
|
label: String,
|
||||||
@@ -1489,6 +1618,7 @@ private fun MenuItemRow(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
private fun MiniSelectButton(
|
private fun MiniSelectButton(
|
||||||
text: String,
|
text: String,
|
||||||
@@ -1523,6 +1653,7 @@ private fun MiniSelectButton(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
private fun DrawerEpisodeCard(
|
private fun DrawerEpisodeCard(
|
||||||
episode: Episode,
|
episode: Episode,
|
||||||
@@ -1629,6 +1760,7 @@ private fun DrawerEpisodeCard(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
private fun SeasonSelectChip(
|
private fun SeasonSelectChip(
|
||||||
season: Season,
|
season: Season,
|
||||||
@@ -1658,6 +1790,7 @@ private fun SeasonSelectChip(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun formatTime(ms: Long): String {
|
private fun formatTime(ms: Long): String {
|
||||||
val totalSeconds = (ms / 1000).coerceAtLeast(0)
|
val totalSeconds = (ms / 1000).coerceAtLeast(0)
|
||||||
val hours = totalSeconds / 3600
|
val hours = totalSeconds / 3600
|
||||||
|
|||||||
899
package-lock.json
generated
899
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
10
package.json
10
package.json
@@ -9,9 +9,9 @@
|
|||||||
"android": "node scripts/build-android.mjs"
|
"android": "node scripts/build-android.mjs"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@vyla-entertainment/sdk": "^1.20.0",
|
"@vyla-entertainment/sdk": "^1.29.0",
|
||||||
"dotenv": "^16.4.5",
|
"dotenv": "^16.4.5",
|
||||||
"express": "^4.19.2",
|
"express": "^4.22.3",
|
||||||
"hls.js": "^1.7.3"
|
"hls.js": "^1.7.3"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
@@ -21,5 +21,9 @@
|
|||||||
"main": "server.js",
|
"main": "server.js",
|
||||||
"keywords": [],
|
"keywords": [],
|
||||||
"author": "",
|
"author": "",
|
||||||
"license": "ISC"
|
"license": "ISC",
|
||||||
|
"allowScripts": {
|
||||||
|
"esbuild@0.25.12": true,
|
||||||
|
"koffi@2.16.4": true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,14 +56,52 @@ globalThis.VylaLocal = {
|
|||||||
`;
|
`;
|
||||||
fs.writeFileSync(path.join(tmp, 'entry.js'), entry);
|
fs.writeFileSync(path.join(tmp, 'entry.js'), entry);
|
||||||
|
|
||||||
|
const nodeStubPlugin = {
|
||||||
|
name: 'node-stub',
|
||||||
|
setup(build) {
|
||||||
|
build.onResolve(
|
||||||
|
{
|
||||||
|
filter: /^(node:|fs(\/promises)?$|path$|crypto$|https$|http$|events$|os$|stream$|util$|url$|zlib$|net$|tls$|child_process$|worker_threads$|async_hooks$|perf_hooks$|readline$|koffi$|piscina$|node-tls-client$)/,
|
||||||
|
},
|
||||||
|
(args) => ({
|
||||||
|
path: args.path,
|
||||||
|
namespace: 'node-stub',
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
build.onLoad({ filter: /^node-tls-client$/, namespace: 'node-stub' }, () => ({
|
||||||
|
contents: `
|
||||||
|
export const ClientIdentifier = {};
|
||||||
|
export const destroyTLS = async () => {};
|
||||||
|
export const initTLS = async () => {};
|
||||||
|
export class Session {
|
||||||
|
async get() { throw new Error('node-tls-client not supported in webview'); }
|
||||||
|
async post() { throw new Error('node-tls-client not supported on webview'); }
|
||||||
|
async close() {}
|
||||||
|
}
|
||||||
|
export default { ClientIdentifier, destroyTLS, initTLS, Session };
|
||||||
|
`,
|
||||||
|
loader: 'js',
|
||||||
|
}));
|
||||||
|
|
||||||
|
build.onLoad({ filter: /.*/, namespace: 'node-stub' }, () => ({
|
||||||
|
contents: 'module.exports = {};',
|
||||||
|
loader: 'js',
|
||||||
|
}));
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
await build({
|
await build({
|
||||||
entryPoints: [path.join(tmp, 'entry.js')],
|
entryPoints: [path.join(tmp, 'entry.js')],
|
||||||
bundle: true,
|
bundle: true,
|
||||||
format: 'iife',
|
format: 'iife',
|
||||||
target: 'chrome70',
|
target: 'chrome70',
|
||||||
platform: 'browser',
|
platform: 'browser',
|
||||||
|
plugins: [nodeStubPlugin],
|
||||||
minify: true,
|
minify: true,
|
||||||
alias: { 'node:crypto': path.join(shim, 'crypto.js') },
|
alias: {
|
||||||
|
'node:crypto': path.join(shim, 'crypto.js')
|
||||||
|
},
|
||||||
inject: [path.join(shim, 'inject.js')],
|
inject: [path.join(shim, 'inject.js')],
|
||||||
outfile: path.join(www, 'js/vyla-local.js'),
|
outfile: path.join(www, 'js/vyla-local.js'),
|
||||||
logLevel: 'info'
|
logLevel: 'info'
|
||||||
|
|||||||
1
scripts/empty-shim.js
Normal file
1
scripts/empty-shim.js
Normal file
@@ -0,0 +1 @@
|
|||||||
|
export default {};
|
||||||
Reference in New Issue
Block a user