--- build73/app/build.gradle.kts +++ build74/app/build.gradle.kts @@ -12,8 +12,8 @@ applicationId = "tv.tivilux.nativeplayer" minSdk = 23 targetSdk = 35 - versionCode = 73 - versionName = "0.4.57" + versionCode = 74 + versionName = "0.4.58" buildConfigField("String", "DEFAULT_SERVER_URL", "\"http://xtreamview.net\"") buildConfigField("String", "UPDATE_MANIFEST_URL", "\"https://play.theappdrop.store/tivilux-updates/latest.json\"") --- build73/app/src/main/java/tv/tivilux/nativeplayer/AppViewModel.kt +++ build74/app/src/main/java/tv/tivilux/nativeplayer/AppViewModel.kt @@ -1351,6 +1351,7 @@ private fun setLivePlayer(item: MediaEntry) { val creds = credentials ?: return + tv.tivilux.nativeplayer.data.LiveStreamTrace.selected(item.id.toString(), item.name) recordLiveTune(item) ensureEpg(item) if (item.type != ContentType.EPISODE) playbackNextItem = null --- build73/app/src/main/java/tv/tivilux/nativeplayer/ui/TiviLuxApp.kt +++ build74/app/src/main/java/tv/tivilux/nativeplayer/ui/TiviLuxApp.kt @@ -530,6 +530,8 @@ externalPlayer = sharedLivePlayer, managedLive = true, liveCandidates = liveSurfaceCandidates, + diagnosticChannelKey = (if (liveFullscreen) vm.playingItem else vm.tunedChannel)?.id?.toString().orEmpty(), + diagnosticChannelName = (if (liveFullscreen) vm.playingItem else vm.tunedChannel)?.name ?: "Live channel", // Fullscreen gets a dedicated SurfaceView-backed PlayerView for the most // direct hardware-composited path and steadier sports frame pacing. The // Guide preview returns to TextureView so drawers/overlays retain their --- build73/app/src/main/java/tv/tivilux/nativeplayer/ui/components/LivePlaybackSession.kt +++ build74/app/src/main/java/tv/tivilux/nativeplayer/ui/components/LivePlaybackSession.kt @@ -24,6 +24,7 @@ import kotlinx.coroutines.delay import java.util.UUID import tv.tivilux.nativeplayer.data.LiveRecoveryPolicy +import tv.tivilux.nativeplayer.data.LiveStreamTrace /** One recovery owner for the existing shared player; never runs for VOD or MultiView. */ @androidx.annotation.OptIn(UnstableApi::class) @@ -33,6 +34,8 @@ url: String?, candidates: List, autoPlay: Boolean, + diagnosticChannelKey: String, + diagnosticChannelName: String, ): String? { val lifecycle = LocalLifecycleOwner.current.lifecycle var status by remember(player, url) { mutableStateOf(null) } @@ -69,6 +72,7 @@ try { // Invalidate callbacks before requesting Media3 loader/source teardown. // Teardown is asynchronous inside Media3; a fixed sleep cannot acknowledge it. + ownedMediaId?.let { LiveStreamTrace.ending(it) } ownedMediaId = null player.playWhenReady = false player.stop() @@ -82,6 +86,8 @@ return try { sessionContext.ensureActive() ownedMediaId = "$sessionId:${++attempt}" + val format = if (android.net.Uri.parse(currentSource).path?.endsWith(".m3u8", true) == true) "HLS" else "TS/OTHER" + LiveStreamTrace.begin(ownedMediaId!!, format, diagnosticChannelKey, diagnosticChannelName) player.setMediaItem(MediaItem.Builder().setUri(currentSource).setMediaId(ownedMediaId!!).build()) player.prepare() player.playWhenReady = autoPlay @@ -183,6 +189,7 @@ // cleanup must never stop that newer owner's MediaItem. player.removeAnalyticsListener(listener) val stillOwnsMedia = ownedMediaId != null && player.currentMediaItem?.mediaId == ownedMediaId + ownedMediaId?.let { LiveStreamTrace.ending(it) } ownedMediaId = null if (stillOwnsMedia) { player.playWhenReady = false --- build73/app/src/main/java/tv/tivilux/nativeplayer/ui/components/LuxComponents.kt +++ build74/app/src/main/java/tv/tivilux/nativeplayer/ui/components/LuxComponents.kt @@ -292,7 +292,9 @@ .setReadTimeoutMs(if (vodOptimized) 30_000 else 12_000) .setAllowCrossProtocolRedirects(true) - val mediaSourceFactory = DefaultMediaSourceFactory(dataSourceFactory) + val mediaSourceFactory: androidx.media3.exoplayer.source.MediaSource.Factory = + if (vodOptimized) DefaultMediaSourceFactory(dataSourceFactory) + else DiagnosticMediaSourceFactory(dataSourceFactory) return ExoPlayer.Builder(context, renderersFactory) .setLoadControl(loadControl) @@ -326,6 +328,8 @@ startPositionMs: Long = 0L, managedLive: Boolean = false, liveCandidates: List = emptyList(), + diagnosticChannelKey: String = "", + diagnosticChannelName: String = "Live channel", preferSurfaceView: Boolean = false, ) { val context = LocalContext.current @@ -398,7 +402,7 @@ } } - val liveStatus = if (managedLive) rememberLivePlaybackSessionStatus(player, url, liveCandidates, autoPlay) else null + val liveStatus = if (managedLive) rememberLivePlaybackSessionStatus(player, url, liveCandidates, autoPlay, diagnosticChannelKey, diagnosticChannelName) else null Box( modifier = modifier.background(if (ownsPlayer) Color.Black else Color.Transparent), --- build73/app/src/main/java/tv/tivilux/nativeplayer/ui/screens/SettingsScreen.kt +++ build74/app/src/main/java/tv/tivilux/nativeplayer/ui/screens/SettingsScreen.kt @@ -47,6 +47,7 @@ import tv.tivilux.nativeplayer.ui.components.LuxButton import tv.tivilux.nativeplayer.ui.components.SupportIssue import tv.tivilux.nativeplayer.ui.components.SupportReportDialog +import tv.tivilux.nativeplayer.ui.components.StreamDiagnosticsDialog import tv.tivilux.nativeplayer.ui.theme.LuxGold import tv.tivilux.nativeplayer.ui.theme.LuxGreen import tv.tivilux.nativeplayer.ui.theme.LuxLine @@ -86,6 +87,7 @@ var section by remember { mutableStateOf(SettingsSection.TV_GUIDE) } var cacheStatus by remember { mutableStateOf(null) } var showSupportReport by remember { mutableStateOf(false) } + var showStreamDiagnostics by remember { mutableStateOf(false) } val context = LocalContext.current.applicationContext val cacheScope = rememberCoroutineScope() @@ -132,6 +134,7 @@ onCheckUpdates = onCheckUpdates, onManageProfiles = onManageProfiles, onReportProblem = { showSupportReport = true }, + onStreamDiagnostics = { showStreamDiagnostics = true }, categoryLists = categoryLists, hiddenCategoryIds = hiddenCategoryIds, hiddenLiveChannels = hiddenLiveChannels, @@ -152,6 +155,9 @@ } } + if (showStreamDiagnostics) { + StreamDiagnosticsDialog(onDismiss = { showStreamDiagnostics = false }) + } if (showSupportReport) { SupportReportDialog( details = reportContext, @@ -191,6 +197,7 @@ onCheckUpdates: () -> Unit, onManageProfiles: () -> Unit, onReportProblem: () -> Unit, + onStreamDiagnostics: () -> Unit, categoryLists: Map>, hiddenCategoryIds: Map>, hiddenLiveChannels: List, @@ -328,6 +335,7 @@ SettingsSection.SUPPORT -> { item { LuxButton("REPORT A PROBLEM", onReportProblem) } + item { LuxButton("STREAM DIAGNOSTICS", onStreamDiagnostics) } item { InfoSetting("What gets attached", "App/build, device + Android version, and available channel/player context") } item { InfoSetting("Privacy", "Passwords and provider credentials are never included in support reports") } item { InfoSetting("Delivery", "Reports are sent to the private TiviLux admin support channel") } --- build73/latest.json +++ build74/latest.json @@ -1,13 +1,13 @@ { - "versionCode": 73, - "versionName": "0.4.57", - "apkUrl": "https://play.theappdrop.store/tivilux-updates/TiviLux-Native-v0.4.57.apk", + "versionCode": 74, + "versionName": "0.4.58", + "apkUrl": "https://play.theappdrop.store/tivilux-updates/TiviLux-Native-v0.4.58.apk", "required": false, "sha256": "", "notes": [ - "Live TV tune/recovery work now ends with its owning playback session", - "Removed the fixed 180 ms channel-switch delay", - "Live TV stops and clears media when backgrounded; obsolete error callbacks are filtered", - "Existing buffer, HLS, decoder and HTTP tuning retained" + "Adds opt-in Stream Diagnostics under Settings > Support", + "Measures old-source request close completion and read returns after channel changes", + "Labels HLS sources and records late playlist/segment requests without logging URLs or credentials", + "Diagnostic release: does not claim immediate XUI session removal; playback tuning retained" ] } --- build73/updates/latest.json +++ build74/updates/latest.json @@ -1,13 +1,13 @@ { - "versionCode": 73, - "versionName": "0.4.57", - "apkUrl": "https://play.theappdrop.store/tivilux-updates/TiviLux-Native-v0.4.57.apk", + "versionCode": 74, + "versionName": "0.4.58", + "apkUrl": "https://play.theappdrop.store/tivilux-updates/TiviLux-Native-v0.4.58.apk", "required": false, "sha256": "", "notes": [ - "Live TV tune/recovery work now ends with its owning playback session", - "Removed the fixed 180 ms channel-switch delay", - "Live TV stops and clears media when backgrounded; obsolete error callbacks are filtered", - "Existing buffer, HLS, decoder and HTTP tuning retained" + "Adds opt-in Stream Diagnostics under Settings > Support", + "Measures old-source request close completion and read returns after channel changes", + "Labels HLS sources and records late playlist/segment requests without logging URLs or credentials", + "Diagnostic release: does not claim immediate XUI session removal; playback tuning retained" ] }