Release Kaleido 0.8.0 with a single-countdown Up Next screen
All checks were successful
Validate and publish Kaleido / android (push) Successful in 2m33s
All checks were successful
Validate and publish Kaleido / android (push) Successful in 2m33s
- Credits and episode endings open Up Next: the video keeps playing in a top-left mini-player beside the next episode, season and related shows. Play next episode carries the only countdown; any remote press stops it. Left then OK on the video, or Back, returns to the credits. - Wait for the player's final timeline report before reloading Home, so Continue Watching reflects the episode just watched. - Remove the source label above Home's featured title. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
8533347b51
commit
3e020bd7fa
16 changed files with 217 additions and 84 deletions
|
|
@ -660,8 +660,6 @@ internal fun runtimeLabel(ms:Long):String {val minutes=(ms/60000).coerceAtLeast(
|
|||
val metadata by produceState(item,item.id){value=item;value=vm.previewDetails(item)}
|
||||
Column {
|
||||
val parts=copyParts(3)
|
||||
Eyebrow(feature.reason)
|
||||
Spacer(Modifier.height(9.dp))
|
||||
TitleIdentity(vm.api,item,Modifier.width(264.dp).height(80.dp))
|
||||
if(parts>=2)Row(Modifier.fillMaxWidth().padding(top=8.dp,bottom=8.dp),verticalAlignment=Alignment.CenterVertically) {
|
||||
Text(listOf(item.year,item.genres.firstOrNull().orEmpty(),item.contentRating).filter{it.isNotBlank()}.joinToString(" · "),color=Cinema.secondary,fontSize=10.sp,maxLines=1,overflow=TextOverflow.Ellipsis,modifier=Modifier.weight(1f,fill=false))
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
package tv.kaleido.app
|
||||
|
||||
data class HomeFeature(val item:Title,val reason:String)
|
||||
data class HomeFeature(val item:Title)
|
||||
|
||||
/** Interleave discovery categories; Continue Watching has its own rail. */
|
||||
internal fun homeFeatures(recent:List<Title>,rated:List<Title>,hubs:List<Hub>,continuing:List<Title>,random:kotlin.random.Random=kotlin.random.Random.Default):List<HomeFeature> {
|
||||
|
|
@ -9,10 +9,10 @@ internal fun homeFeatures(recent:List<Title>,rated:List<Title>,hubs:List<Hub>,co
|
|||
item.id !in excluded&&!item.fullyWatched&&item.offset==0L
|
||||
// Shuffle movies and shows together rather than always leading with the same movie section.
|
||||
val buckets=listOf(
|
||||
recent.filter{eligible(it)&&it.releaseDate.isNotBlank()}.sortedByDescending{it.releaseDate}.take(18).shuffled(random).map{HomeFeature(it,"Recently released")},
|
||||
rated.filter{eligible(it)&&it.viewedLeafCount==0}.shuffled(random).map{HomeFeature(it,"Highly rated · Unwatched")},
|
||||
recent.filter{eligible(it)&&it.releaseDate.isNotBlank()}.sortedByDescending{it.releaseDate}.take(18).shuffled(random).map{HomeFeature(it)},
|
||||
rated.filter{eligible(it)&&it.viewedLeafCount==0}.shuffled(random).map{HomeFeature(it)},
|
||||
hubs.filterNot{h->listOf("continue","ondeck","inprogress","recentlyviewed","recentlyadded","recentlyaired","recent").any{h.id.contains(it,true)}}
|
||||
.flatMap{it.items}.filter(::eligible).distinctBy{it.id}.shuffled(random).map{HomeFeature(it,"Suggested for you")}
|
||||
.flatMap{it.items}.filter(::eligible).distinctBy{it.id}.shuffled(random).map{HomeFeature(it)}
|
||||
)
|
||||
val seen=mutableSetOf<String>()
|
||||
return buildList {
|
||||
|
|
|
|||
|
|
@ -39,6 +39,7 @@ private const val SyncQuietMillis=2000L
|
|||
internal const val AutoSkipDefaultSeconds=5
|
||||
/** Returning to Kaleido checks the server almost at once, so watching elsewhere shows up promptly. */
|
||||
private const val ResumeSyncDelayMillis=750L
|
||||
private const val PlaybackReportWaitMillis=4_000L
|
||||
class KaleidoViewModel(app: Application): AndroidViewModel(app) {
|
||||
val application = app as KaleidoApplication
|
||||
val api = application.api
|
||||
|
|
@ -742,6 +743,9 @@ class KaleidoViewModel(app: Application): AndroidViewModel(app) {
|
|||
if(playing?.id!=item.id)return
|
||||
stopPlayback();fail(message){play(item)}
|
||||
}
|
||||
/** Each player's timeline reporter, until it has sent its final position. */
|
||||
private val playbackReports=java.util.concurrent.CopyOnWriteArraySet<Job>()
|
||||
internal fun trackPlaybackReports(job:Job){playbackReports+=job;job.invokeOnCompletion{playbackReports-=job}}
|
||||
fun stopPlayback(){
|
||||
val finished=playing
|
||||
shuffleEpisodes=null
|
||||
|
|
@ -749,6 +753,9 @@ class KaleidoViewModel(app: Application): AndroidViewModel(app) {
|
|||
// A season or episode page shows the last episode played, with fresh progress in its row.
|
||||
detail?.let{if(finished?.type=="episode"&&it.type in listOf("season","episode"))episodeSelections[it.id]=finished.id}
|
||||
launchLoad {
|
||||
// The player closes after this frame and only then reports where it stopped. Reloading
|
||||
// before Plex has that report showed the previous Continue Watching.
|
||||
kotlinx.coroutines.withTimeoutOrNull(PlaybackReportWaitMillis){playbackReports.toList().forEach{it.join()}}
|
||||
homeHubs=loadHome()
|
||||
detail?.let {
|
||||
if(it.type in listOf("movie","episode"))detail=api.details(it.id)
|
||||
|
|
|
|||
|
|
@ -129,6 +129,7 @@ class PlaybackController(private val vm: KaleidoViewModel,val item: Title) {
|
|||
}
|
||||
}
|
||||
init {
|
||||
vm.trackPlaybackReports(reportJob)
|
||||
audit?.let{player.addAnalyticsListener(it)}
|
||||
// Sparse diagnostics also survive in release logcat when an intermittent dropout occurs.
|
||||
player.addAnalyticsListener(object:androidx.media3.exoplayer.analytics.AnalyticsListener {
|
||||
|
|
|
|||
|
|
@ -23,6 +23,15 @@ import androidx.lifecycle.Lifecycle
|
|||
import androidx.lifecycle.compose.LocalLifecycleOwner
|
||||
import androidx.lifecycle.compose.currentStateAsState
|
||||
import kotlinx.coroutines.delay
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.ui.draw.drawBehind
|
||||
import androidx.compose.ui.focus.FocusRequester
|
||||
import androidx.compose.ui.focus.focusProperties
|
||||
import androidx.compose.ui.focus.focusRequester
|
||||
import androidx.compose.ui.graphics.Brush
|
||||
import androidx.compose.ui.input.key.KeyEventType
|
||||
import androidx.compose.ui.input.key.onPreviewKeyEvent
|
||||
import androidx.compose.ui.input.key.type
|
||||
|
||||
@Composable internal fun PlaybackOptions(vm:KaleidoViewModel,controller:PlaybackController,item:Title,menu:Int,open:(Int)->Unit,close:()->Unit) {
|
||||
val speeds=listOf(.5f,.75f,1f,1.25f,1.5f,2f)
|
||||
|
|
@ -46,52 +55,142 @@ import kotlinx.coroutines.delay
|
|||
|
||||
internal fun speedLabel(speed:Float)=if(speed==1f)"Normal" else "${speed.toString().removeSuffix(".0")}×"
|
||||
|
||||
@Composable internal fun PostPlayScreen(vm:KaleidoViewModel,item:Title,dismiss:()->Unit,next:()->Unit) {
|
||||
/** Where the playing video shrinks to while Up Next is open, on the 960 × 540 dp canvas. */
|
||||
internal object UpNextFrame {
|
||||
val x=44.dp;val y=34.dp;val width=352.dp;val height=198.dp
|
||||
}
|
||||
|
||||
/**
|
||||
* Up Next's page beneath the player's surface: the next episode's artwork, top-right, fading into
|
||||
* the page, and a black frame under the mini-player for letterboxed video. Drawn before the
|
||||
* PlayerView, whose SurfaceView shows through only where nothing is drawn above it.
|
||||
*/
|
||||
@Composable internal fun UpNextBackdrop(vm:KaleidoViewModel,item:Title,modifier:Modifier) {
|
||||
val upcoming=vm.followingEpisode(item)
|
||||
// Settings › Playback sets the countdown; 0 turns autoplay off.
|
||||
val countdown=if(vm.shuffling&&vm.autoplaySeconds==0)5 else vm.autoplaySeconds
|
||||
var autoplay by remember{mutableStateOf(countdown>0)}
|
||||
var seconds by remember{mutableIntStateOf(countdown)}
|
||||
// The countdown runs only while Kaleido is on screen; leaving it restarts on return.
|
||||
val lifecycle by LocalLifecycleOwner.current.lifecycle.currentStateAsState()
|
||||
val onScreen=lifecycle.isAtLeast(Lifecycle.State.STARTED)
|
||||
LaunchedEffect(autoplay,upcoming?.id,onScreen) {
|
||||
if(autoplay&&onScreen&&upcoming!=null&&countdown>0){seconds=countdown;android.util.Log.i("KaleidoPlayback","AUTOPLAY countdown item=${item.id} next=${upcoming.id}");repeat(countdown){delay(1000);seconds--};android.util.Log.i("KaleidoPlayback","AUTOPLAY starting next=${upcoming.id}");next()}
|
||||
}
|
||||
val season=vm.episodeQueue.filter{it.parentId==item.parentId}
|
||||
LazyColumn(Modifier.fillMaxSize().background(Color.Black.copy(alpha=.93f)),contentPadding=PaddingValues(horizontal=Cinema.gutter,vertical=29.dp),verticalArrangement=Arrangement.spacedBy(15.dp)) {
|
||||
item {
|
||||
Text(if(vm.shuffling)"Up next · Shuffle"else if(upcoming!=null)"Up next"else "More to watch",color=Accent,fontSize=25.sp,fontWeight=FontWeight.SemiBold)
|
||||
Row(Modifier.padding(top=13.dp),horizontalArrangement=Arrangement.spacedBy(20.dp),verticalAlignment=Alignment.CenterVertically) {
|
||||
if(upcoming!=null)Artwork(vm.api,upcoming.still.ifBlank{upcoming.thumb},Modifier.width(205.dp).aspectRatio(16f/9f).clip(RoundedCornerShape(5.dp)),480,270,animate=false)
|
||||
Column(Modifier.weight(1f)) {
|
||||
Text(upcoming?.displayTitle ?: item.displayTitle,color=Accent,fontSize=21.sp,fontWeight=FontWeight.SemiBold)
|
||||
Text(upcoming?.let{"S${it.parentIndex} · E${it.index} ${it.title}"} ?: "You've reached the end of this series.",color=Cinema.secondary,fontSize=12.sp,modifier=Modifier.padding(top=5.dp,bottom=15.dp))
|
||||
Row(horizontalArrangement=Arrangement.spacedBy(10.dp),verticalAlignment=Alignment.CenterVertically) {
|
||||
if(upcoming!=null)ActionButton(if(vm.transitioningEpisode)"Loading…"else if(autoplay)"Play in $seconds"else "Play now",Icons.Filled.PlayArrow,modifier=Modifier.onFocusChanged{if(it.isFocused&&BuildConfig.DEBUG)android.util.Log.i("KaleidoPlayback","POSTPLAY focus=play")},primary=true,initialFocus=true){autoplay=false;next()}
|
||||
if(upcoming!=null&&countdown>0)TvButton(if(autoplay)"Cancel autoplay"else "Autoplay off"){autoplay=!autoplay;android.util.Log.i("KaleidoPlayback","AUTOPLAY ${if(autoplay)"enabled"else "cancelled"} item=${item.id}")}
|
||||
TvButton("Back to video"){autoplay=false;dismiss()}
|
||||
}
|
||||
}
|
||||
}
|
||||
val path=upcoming?.let{it.still.ifBlank{it.thumb}.ifBlank{it.art}} ?: item.art.ifBlank{item.thumb}
|
||||
Box(modifier.fillMaxSize().background(Ink)) {
|
||||
Box(Modifier.align(Alignment.TopEnd).width(640.dp).aspectRatio(16f/9f)) {
|
||||
if(path.isNotBlank())Artwork(vm.api,path,Modifier.fillMaxSize(),960,540,animate=false)
|
||||
Box(Modifier.fillMaxSize().background(Brush.horizontalGradient(0f to Ink,.42f to Ink.copy(alpha=.72f),1f to Color.Transparent)))
|
||||
Box(Modifier.fillMaxSize().background(Brush.verticalGradient(.35f to Color.Transparent,1f to Ink)))
|
||||
}
|
||||
if(season.isNotEmpty())item {PostPlayRail(vm,"Episodes in this season",season){autoplay=false;vm.play(it,true)}}
|
||||
if(vm.relatedShows.isNotEmpty())item {PostPlayRail(vm,"Related shows",vm.relatedShows){autoplay=false;vm.stopPlayback();vm.open(it)}}
|
||||
Box(Modifier.offset(UpNextFrame.x,UpNextFrame.y).size(UpNextFrame.width,UpNextFrame.height).background(Color.Black))
|
||||
}
|
||||
}
|
||||
|
||||
@Composable private fun PostPlayRail(vm:KaleidoViewModel,label:String,titles:List<Title>,choose:(Title)->Unit) {
|
||||
/**
|
||||
* Up Next, over the shrunken player: the next episode with one countdown, the season and related shows.
|
||||
* Any remote press stops the countdown. Left from Play next (or Back) returns to the playing video.
|
||||
*/
|
||||
@Composable internal fun PostPlayScreen(vm:KaleidoViewModel,item:Title,controller:PlaybackController,watchVideo:()->Unit,next:()->Unit) {
|
||||
val upcoming=vm.followingEpisode(item)
|
||||
// Settings › Playback sets the countdown; 0 turns autoplay off.
|
||||
val countdown=if(vm.shuffling&&vm.autoplaySeconds==0)5 else vm.autoplaySeconds
|
||||
var cancelled by remember{mutableStateOf(false)}
|
||||
val counting=upcoming!=null&&countdown>0&&!cancelled
|
||||
var elapsed by remember{mutableLongStateOf(0)}
|
||||
// The countdown runs only while Kaleido is on screen; leaving it restarts on return.
|
||||
val lifecycle by LocalLifecycleOwner.current.lifecycle.currentStateAsState()
|
||||
val onScreen=lifecycle.isAtLeast(Lifecycle.State.STARTED)
|
||||
LaunchedEffect(counting,upcoming?.id,onScreen) {
|
||||
if(!counting||!onScreen||upcoming==null)return@LaunchedEffect
|
||||
val total=countdown*1000L;elapsed=0
|
||||
android.util.Log.i("KaleidoPlayback","AUTOPLAY countdown item=${item.id} next=${upcoming.id}")
|
||||
while(elapsed<total){delay(50);elapsed+=50}
|
||||
android.util.Log.i("KaleidoPlayback","AUTOPLAY starting next=${upcoming.id}");next()
|
||||
}
|
||||
val playFocus=remember{FocusRequester()}
|
||||
val videoFocus=remember{FocusRequester()}
|
||||
LaunchedEffect(Unit){withFrameNanos{};runCatching{(if(upcoming!=null)playFocus else videoFocus).requestFocus()}}
|
||||
val season=vm.episodeQueue.filter{it.parentId==item.parentId}
|
||||
Box(Modifier.fillMaxSize().onPreviewKeyEvent{
|
||||
if(it.type==KeyEventType.KeyDown&&counting){cancelled=true;android.util.Log.i("KaleidoPlayback","AUTOPLAY cancelled item=${item.id}")}
|
||||
false
|
||||
}) {
|
||||
// The video itself is the PlayerView beneath; this is its focus target and outline.
|
||||
var videoFocused by remember{mutableStateOf(false)}
|
||||
Box(Modifier.offset(UpNextFrame.x-4.dp,UpNextFrame.y-4.dp).size(UpNextFrame.width+8.dp,UpNextFrame.height+8.dp)
|
||||
.focusRequester(videoFocus).focusProperties{right=if(upcoming!=null)playFocus else FocusRequester.Default}
|
||||
.navigationSound().onFocusChanged{videoFocused=it.isFocused}
|
||||
.border(if(videoFocused)2.dp else 1.dp,Color.White.copy(alpha=if(videoFocused)1f else .16f),RoundedCornerShape(8.dp))
|
||||
.semantics{contentDescription="Return to "+item.displayTitle}.clickable(onClick=watchVideo))
|
||||
NowPlaying(item,controller,videoFocused,Modifier.offset(UpNextFrame.x,UpNextFrame.y+UpNextFrame.height+10.dp).width(UpNextFrame.width))
|
||||
Column(Modifier.padding(start=UpNextFrame.x+UpNextFrame.width+36.dp,top=36.dp,end=Cinema.gutter)) {
|
||||
Eyebrow(if(upcoming==null)"More to watch"else if(vm.shuffling)"Up next · Shuffle"else "Up next")
|
||||
Spacer(Modifier.height(8.dp))
|
||||
// The playing episode carries its show's title art; listed episodes may not.
|
||||
TitleIdentity(vm.api,item,Modifier.size(240.dp,44.dp))
|
||||
if(upcoming!=null) {
|
||||
val metadata by produceState(upcoming,upcoming.id){value=upcoming;value=vm.previewDetails(upcoming)}
|
||||
Text(upcoming.title,color=Accent,fontSize=21.sp,lineHeight=26.sp,fontWeight=FontWeight.SemiBold,maxLines=1,overflow=TextOverflow.Ellipsis,modifier=Modifier.padding(top=6.dp))
|
||||
Row(Modifier.padding(top=6.dp).height(17.dp),verticalAlignment=Alignment.CenterVertically) {
|
||||
if(metadata.contentRating.isNotBlank())FormatBadge(metadata.contentRating,Modifier.padding(end=8.dp))
|
||||
Text(listOf("S${upcoming.parentIndex} · E${upcoming.index}",if(upcoming.duration>0)runtimeLabel(upcoming.duration)else "").filter{it.isNotBlank()}.joinToString(" · "),color=Cinema.secondary,fontSize=11.sp,lineHeight=15.sp,maxLines=1)
|
||||
AudienceRatings(metadata,Modifier.padding(start=10.dp))
|
||||
}
|
||||
if(metadata.summary.isNotBlank())Text(metadata.summary,color=Cinema.secondary,fontSize=12.sp,lineHeight=18.sp,maxLines=3,overflow=TextOverflow.Ellipsis,modifier=Modifier.padding(top=8.dp))
|
||||
UpNextButton(if(vm.transitioningEpisode)"Loading…"else "Play next episode",if(counting)({(elapsed.toFloat()/(countdown*1000)).coerceIn(0f,1f)})else null,
|
||||
Modifier.padding(top=14.dp).focusRequester(playFocus).focusProperties{left=videoFocus}.onFocusChanged{if(it.isFocused&&BuildConfig.DEBUG)android.util.Log.i("KaleidoPlayback","POSTPLAY focus=play")}) {
|
||||
cancelled=true;next()
|
||||
}
|
||||
}
|
||||
else Text("You've reached the end of this series.",color=Cinema.secondary,fontSize=12.sp,lineHeight=18.sp,modifier=Modifier.padding(top=8.dp))
|
||||
}
|
||||
LazyColumn(Modifier.fillMaxWidth().padding(top=292.dp),contentPadding=PaddingValues(start=Cinema.gutter,end=Cinema.gutter,bottom=24.dp),verticalArrangement=Arrangement.spacedBy(14.dp)) {
|
||||
val up=if(upcoming!=null)playFocus else videoFocus
|
||||
if(season.isNotEmpty())item {
|
||||
val current=season.indexOfFirst{it.id==item.id}
|
||||
PostPlayRail(vm,if(item.parentIndex>0)"Season ${item.parentIndex}"else "Episodes",season,up,(current-1).coerceAtLeast(0),{when(it.id){item.id->"Now playing";upcoming?.id->"Up next";else->if(it.duration>0)runtimeLabel(it.duration)else ""}}){vm.play(it,true)}
|
||||
}
|
||||
if(vm.relatedShows.isNotEmpty())item {PostPlayRail(vm,"Related shows",vm.relatedShows,if(season.isEmpty())up else null,0,{it.year}){vm.stopPlayback();vm.open(it)}}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** Where the playing episode is, under the mini-player. Its own scope: position ticks recompose only this. */
|
||||
@Composable private fun NowPlaying(item:Title,controller:PlaybackController,focused:Boolean,modifier:Modifier) {
|
||||
Column(modifier) {
|
||||
Row(verticalAlignment=Alignment.CenterVertically) {
|
||||
Text((if(item.type=="episode")"S${item.parentIndex} · E${item.index} "else "")+item.title,color=if(focused)Accent else Cinema.secondary,fontSize=11.sp,lineHeight=15.sp,maxLines=1,overflow=TextOverflow.Ellipsis,modifier=Modifier.weight(1f))
|
||||
Text("−"+clockTime(controller.duration-controller.position),color=Cinema.quiet,fontSize=10.sp,lineHeight=14.sp,maxLines=1,modifier=Modifier.padding(start=10.dp))
|
||||
}
|
||||
val progress=if(controller.duration>0)(controller.position.toFloat()/controller.duration).coerceIn(0f,1f)else 0f
|
||||
Box(Modifier.padding(top=6.dp).fillMaxWidth().height(3.dp).clip(RoundedCornerShape(2.dp)).background(Color.White.copy(alpha=.22f))) {
|
||||
Box(Modifier.fillMaxHeight().fillMaxWidth(progress).background(Accent))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** Play next episode. While autoplay counts down ([progress] non-null) a lighter fill sweeps across it, without numbers. */
|
||||
@Composable private fun UpNextButton(label:String,progress:(()->Float)?,modifier:Modifier,onClick:()->Unit) {
|
||||
var focused by remember{mutableStateOf(false)}
|
||||
val shape=RoundedCornerShape(5.dp)
|
||||
val foreground=if(focused)Ink else Accent
|
||||
Row(modifier.height(34.dp).navigationSound().onFocusChanged{focused=it.isFocused}.clip(shape)
|
||||
.drawBehind{
|
||||
val fill=progress?.invoke()
|
||||
drawRect(if(focused)(if(fill!=null)Color(0xFFBDBDBD)else Accent)else Color.White.copy(alpha=.16f))
|
||||
if(fill!=null)drawRect(if(focused)Accent else Color.White.copy(alpha=.18f),size=androidx.compose.ui.geometry.Size(size.width*fill,size.height))
|
||||
}
|
||||
.semantics{contentDescription=label}.clickable(onClick=onClick).padding(horizontal=14.dp),verticalAlignment=Alignment.CenterVertically,horizontalArrangement=Arrangement.spacedBy(7.dp)) {
|
||||
Icon(Icons.Filled.PlayArrow,null,tint=foreground,modifier=Modifier.size(17.dp))
|
||||
Text(label,color=foreground,fontSize=12.sp,lineHeight=16.sp,fontWeight=FontWeight.SemiBold)
|
||||
}
|
||||
}
|
||||
|
||||
@Composable private fun PostPlayRail(vm:KaleidoViewModel,label:String,titles:List<Title>,up:FocusRequester?,start:Int,caption:(Title)->String,choose:(Title)->Unit) {
|
||||
Column {
|
||||
Text(label,color=Accent,fontSize=16.sp,fontWeight=FontWeight.SemiBold,modifier=Modifier.padding(bottom=8.dp))
|
||||
LazyRow(horizontalArrangement=Arrangement.spacedBy(12.dp)) {
|
||||
Text(label,color=Accent,fontSize=16.sp,lineHeight=21.sp,fontWeight=FontWeight.SemiBold,modifier=Modifier.padding(bottom=8.dp))
|
||||
LazyRow(state=rememberLazyListState(start),horizontalArrangement=Arrangement.spacedBy(12.dp)) {
|
||||
items(titles,key={it.id}){title->
|
||||
var focused by remember{mutableStateOf(false)}
|
||||
Column(Modifier.width(167.dp).navigationSound().onFocusChanged{focused=it.isFocused}.semantics{contentDescription=title.displayTitle+" "+title.subtitle}.clickable{choose(title)}) {
|
||||
Box(Modifier.fillMaxWidth().aspectRatio(16f/9f).clip(RoundedCornerShape(4.dp))) {
|
||||
Column(Modifier.width(188.dp).then(if(up!=null)Modifier.focusProperties{this.up=up}else Modifier).navigationSound().onFocusChanged{focused=it.isFocused}.semantics{contentDescription=title.displayTitle+" "+title.subtitle}.clickable{choose(title)}) {
|
||||
Box(Modifier.fillMaxWidth().aspectRatio(16f/9f).clip(RoundedCornerShape(6.dp))) {
|
||||
Artwork(vm.api,if(title.type=="episode")title.still.ifBlank{title.thumb}else title.art.ifBlank{title.thumb},Modifier.fillMaxSize(),384,216,animate=false)
|
||||
if(focused)Box(Modifier.fillMaxSize().border(2.dp,Accent,RoundedCornerShape(4.dp)))
|
||||
if(focused)Box(Modifier.fillMaxSize().border(2.dp,Accent,RoundedCornerShape(6.dp)))
|
||||
}
|
||||
Text(if(title.type=="episode")"${title.index}. ${title.title}"else title.title,color=if(focused)Accent else Cinema.secondary,fontSize=10.sp,lineHeight=14.sp,maxLines=1,overflow=TextOverflow.Ellipsis,modifier=Modifier.padding(top=4.dp))
|
||||
Text(if(title.type=="episode")"${title.index}. ${title.title}"else title.title,color=if(focused)Accent else Cinema.secondary,fontSize=11.sp,lineHeight=15.sp,maxLines=1,overflow=TextOverflow.Ellipsis,modifier=Modifier.padding(top=5.dp))
|
||||
Text(caption(title),color=Cinema.quiet,fontSize=10.sp,lineHeight=14.sp,maxLines=1)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@ import androidx.compose.ui.geometry.Offset
|
|||
import androidx.compose.ui.graphics.Brush
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.graphics.graphicsLayer
|
||||
import androidx.compose.ui.layout.layout
|
||||
import androidx.compose.ui.graphics.StrokeCap
|
||||
import androidx.compose.ui.input.key.*
|
||||
import androidx.compose.ui.platform.LocalDensity
|
||||
|
|
@ -99,7 +100,8 @@ import kotlinx.coroutines.delay
|
|||
// Derived: the player only recomposes when a marker starts or ends, not on every position tick.
|
||||
val marker by remember{derivedStateOf{item.markers.firstOrNull{controller.position>=it.start&&controller.position<it.end&&it.type in listOf("intro","credits")}}}
|
||||
fun skip(marker:Marker){
|
||||
if(marker.type=="credits"&&item.type=="episode"){controller.pause();android.util.Log.i("KaleidoPlayback","POSTPLAY item=${item.id} reason=skip-credits");postPlay=true}
|
||||
// Episodes go to Up Next, where the credits keep playing in the corner.
|
||||
if(marker.type=="credits"&&item.type=="episode"){android.util.Log.i("KaleidoPlayback","POSTPLAY item=${item.id} reason=skip-credits");postPlay=true}
|
||||
else controller.seekTo(marker.end)
|
||||
}
|
||||
// Each marker counts down to an automatic skip once, so seeking back into it plays it.
|
||||
|
|
@ -114,6 +116,8 @@ import kotlinx.coroutines.delay
|
|||
if(m==null||controller.loading||postPlay||m in autoSkipped){if(m==null||postPlay)autoSkip=null;return@LaunchedEffect}
|
||||
val seconds=when(m.type){"intro"->vm.autoSkipIntroSeconds;"credits"->vm.autoSkipCreditsSeconds;else->0}
|
||||
if(seconds<=0)return@LaunchedEffect
|
||||
// Up Next has the one countdown (to the next episode), so automatic credits open it at once.
|
||||
if(m.type=="credits"&&item.type=="episode"){autoSkipped+=m;android.util.Log.i("KaleidoPlayback","POSTPLAY item=${item.id} reason=credits");postPlay=true;return@LaunchedEffect}
|
||||
if(autoSkip!=m){autoSkip=m;autoSkipTotal=seconds*1000L;autoSkipRemaining=autoSkipTotal;android.util.Log.i("KaleidoPlayback","AUTOSKIP countdown ${m.type} seconds=$seconds item=${item.id}")}
|
||||
while(autoSkipRemaining>0){delay(50);if(autoSkip!=m)return@LaunchedEffect;if(controller.isPlaying)autoSkipRemaining-=50}
|
||||
if(autoSkip!=m)return@LaunchedEffect
|
||||
|
|
@ -127,13 +131,20 @@ import kotlinx.coroutines.delay
|
|||
if(!owner.lifecycle.currentState.isAtLeast(Lifecycle.State.STARTED))controller.enterBackground()
|
||||
onDispose{owner.lifecycle.removeObserver(observer);activity.window.clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);controller.close()}
|
||||
}
|
||||
LaunchedEffect(controls,interaction,controller.isPlaying,trackMenu) {
|
||||
if(controls&&controller.isPlaying&&trackMenu==0){delay(5000);controls=false}
|
||||
// Up Next owns focus while open: hiding the controls behind it must not take focus back.
|
||||
LaunchedEffect(controls,interaction,controller.isPlaying,trackMenu,postPlay) {
|
||||
if(controls&&controller.isPlaying&&trackMenu==0&&!postPlay){delay(5000);controls=false}
|
||||
}
|
||||
LaunchedEffect(controls) {if(!controls){timelineReveal=false;delay(210);runCatching{rootFocus.requestFocus()}}}
|
||||
LaunchedEffect(controls) {if(!controls&&!postPlay){timelineReveal=false;delay(210);if(!postPlay)runCatching{rootFocus.requestFocus()}}}
|
||||
LaunchedEffect(seekFocus,controls) {if(seekFocus&&controls){delay(220);runCatching{timelineFocus.requestFocus()};timelineReveal=true;seekFocus=false}}
|
||||
LaunchedEffect(restoreMenuFocus,trackMenu) {if(restoreMenuFocus!=0&&trackMenu==0){delay(16);runCatching{(when(restoreMenuFocus){1->audioFocus;2->subtitleFocus;else->optionsFocus}).requestFocus()};restoreMenuFocus=0}}
|
||||
fun goBack(){if(postPlay)postPlay=false else if(trackMenu!=0)closeTracks()else if(controls)controls=false else vm.stopPlayback()}
|
||||
// Leaving Up Next returns to the full-screen video without revealing the controls.
|
||||
var refocusRoot by remember{mutableIntStateOf(0)}
|
||||
LaunchedEffect(refocusRoot){if(refocusRoot>0){withFrameNanos{};runCatching{rootFocus.requestFocus()}}}
|
||||
fun leaveUpNext(){postPlay=false;controls=false;refocusRoot++;android.util.Log.i("KaleidoPlayback","POSTPLAY closed item=${item.id}")}
|
||||
// The video shrinks into Up Next's corner and grows back; only its layout reads the animation.
|
||||
val upNext=androidx.compose.animation.core.animateFloatAsState(if(postPlay)1f else 0f,tween(320),label="upNext")
|
||||
fun goBack(){if(postPlay)leaveUpNext() else if(trackMenu!=0)closeTracks()else if(controls)controls=false else vm.stopPlayback()}
|
||||
BackHandler(onBack=::goBack)
|
||||
val visible=controls&&!postPlay
|
||||
Box(Modifier.fillMaxSize().background(Color.Black).focusRequester(rootFocus).onPreviewKeyEvent{event->
|
||||
|
|
@ -170,6 +181,7 @@ import kotlinx.coroutines.delay
|
|||
}
|
||||
}
|
||||
}.focusable()) {
|
||||
if(postPlay)UpNextBackdrop(vm,item,Modifier.graphicsLayer{alpha=upNext.value})
|
||||
AndroidView(factory={context->PlayerView(context).apply {
|
||||
setEnableComposeSurfaceSyncWorkaround(true)
|
||||
player=controller.player
|
||||
|
|
@ -178,8 +190,14 @@ import kotlinx.coroutines.delay
|
|||
descendantFocusability=ViewGroup.FOCUS_BLOCK_DESCENDANTS
|
||||
setShowBuffering(PlayerView.SHOW_BUFFERING_NEVER)
|
||||
setKeepContentOnPlayerReset(true)
|
||||
}},update={view->view.subtitleView?.let{applySubtitleStyle(it,vm.subtitleSize,vm.subtitleStyle)}},modifier=Modifier.fillMaxSize(),onRelease={it.player=null})
|
||||
if(controller.loading)CircularProgressIndicator(color=Accent,strokeWidth=2.dp,modifier=Modifier.align(Alignment.Center).size(30.dp))
|
||||
}},update={view->view.subtitleView?.let{applySubtitleStyle(it,vm.subtitleSize,vm.subtitleStyle)}},modifier=Modifier.fillMaxSize().layout{measurable,constraints->
|
||||
val f=upNext.value
|
||||
fun lerp(a:Int,b:Int)=(a+(b-a)*f).toInt()
|
||||
val width=lerp(constraints.maxWidth,UpNextFrame.width.roundToPx());val height=lerp(constraints.maxHeight,UpNextFrame.height.roundToPx())
|
||||
val placeable=measurable.measure(androidx.compose.ui.unit.Constraints.fixed(width,height))
|
||||
layout(constraints.maxWidth,constraints.maxHeight){placeable.place(lerp(0,UpNextFrame.x.roundToPx()),lerp(0,UpNextFrame.y.roundToPx()))}
|
||||
},onRelease={it.player=null})
|
||||
if(controller.loading&&!postPlay)CircularProgressIndicator(color=Accent,strokeWidth=2.dp,modifier=Modifier.align(Alignment.Center).size(30.dp))
|
||||
QuickSkipFeedback(skipSeconds,skipPulse,!visible&&!postPlay,Modifier.align(if(skipForward)Alignment.CenterEnd else Alignment.CenterStart).padding(horizontal=32.dp))
|
||||
AnimatedVisibility(visible=visible,enter=fadeIn(tween(190))+slideInVertically(tween(190)){it/8},exit=fadeOut(tween(190))+slideOutVertically(tween(190)){it/10},modifier=Modifier.align(Alignment.BottomCenter)) {
|
||||
Column(Modifier.fillMaxWidth().background(Brush.verticalGradient(0f to Color.Transparent,.35f to Color.Black.copy(alpha=.5f),1f to Color.Black.copy(alpha=.85f))).padding(start=Cinema.gutter,end=Cinema.gutter,top=48.dp,bottom=16.dp)) {
|
||||
|
|
@ -233,7 +251,7 @@ import kotlinx.coroutines.delay
|
|||
val counting=autoSkip==marker&&autoSkipTotal>0
|
||||
SkipMarkerButton(marker.type=="intro",if(counting)1f-(autoSkipRemaining.toFloat()/autoSkipTotal).coerceIn(0f,1f)else null){autoSkip=null;autoSkipped+=marker;skip(marker);interacted()}
|
||||
}}
|
||||
if(postPlay)PostPlayScreen(vm,item,{postPlay=false;controls=true},{vm.nextEpisode(item)})
|
||||
if(postPlay)PostPlayScreen(vm,item,controller,::leaveUpNext){vm.nextEpisode(item)}
|
||||
controller.error?.let{ErrorDialog(it,{vm.stopPlayback()},{controller.retry()})}
|
||||
if(trackMenu==1)AudioTrackPanel(controller,::closeTracks,::closeTracks)
|
||||
if(trackMenu==2) {
|
||||
|
|
|
|||
|
|
@ -236,7 +236,7 @@ fun CohesiveSettingsScreen(vm: KaleidoViewModel, install: (File) -> Unit) {
|
|||
)
|
||||
SettingsValueRow(
|
||||
title = "Autoplay next episode",
|
||||
description = "Count down to the next episode when one ends.",
|
||||
description = "Up Next counts down to the next episode. Any remote press stops it.",
|
||||
value = autoplayLabel(vm.autoplaySeconds),
|
||||
requester = autoplayFocus,
|
||||
leftTarget = categoryFocus[1],
|
||||
|
|
@ -252,7 +252,7 @@ fun CohesiveSettingsScreen(vm: KaleidoViewModel, install: (File) -> Unit) {
|
|||
)
|
||||
SettingsValueRow(
|
||||
title = "Skip credits",
|
||||
description = "Episodes go straight to Up Next; movies skip past the credits. Any remote press cancels an automatic skip.",
|
||||
description = "Automatic: episodes open Up Next as the credits start; movies skip past them after the delay.",
|
||||
value = autoSkipLabel(vm.autoSkipCreditsSeconds),
|
||||
requester = creditsFocus,
|
||||
leftTarget = categoryFocus[1],
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue