casting: undo more formatting

This commit is contained in:
Marcus Hanestad 2025-09-04 12:07:14 +02:00
commit 86cafffda7

View file

@ -182,16 +182,12 @@ abstract class StateCasting {
try {
device.disconnect()
} catch (e: Throwable) {
Logger.e(
TAG, "Failed to disconnect from device: $e"
)
Logger.e(TAG, "Failed to disconnect from device: $e")
}
})
)
}));
}
}
}
CastConnectionState.DISCONNECTED -> {
UIDialogs.toast(it, "Disconnected from device")
synchronized(_castingDialogLock) {
@ -229,7 +225,7 @@ abstract class StateCasting {
device.onTimeChanged.clear();
device.onVolumeChanged.clear();
device.onDurationChanged.clear();
return
return;
}
activeDevice = device
@ -242,7 +238,7 @@ abstract class StateCasting {
)
}
suspend fun castIfAvailable(contentResolver: ContentResolver, video: IPlatformVideoDetails, videoSource: IVideoSource?, audioSource: IAudioSource?, subtitleSource: ISubtitleSource?, ms: Long, speed: Double?, onLoadingEstimate: ((Int) -> Unit)?, onLoading: ((Boolean) -> Unit)?): Boolean {
suspend fun castIfAvailable(contentResolver: ContentResolver, video: IPlatformVideoDetails, videoSource: IVideoSource?, audioSource: IAudioSource?, subtitleSource: ISubtitleSource?, ms: Long = -1, speed: Double?, onLoadingEstimate: ((Int) -> Unit)? = null, onLoading: ((Boolean) -> Unit)? = null): Boolean {
return withContext(Dispatchers.IO) {
val ad = activeDevice ?: return@withContext false;
if (ad.connectionState != CastConnectionState.CONNECTED) {
@ -300,45 +296,19 @@ abstract class StateCasting {
val videoPath = "/video-${id}"
val videoUrl = if(proxyStreams) url + videoPath else videoSource.getVideoUrl();
Logger.i(TAG, "Casting as singular video");
ad.loadVideo(
if (video.isLive) "LIVE" else "BUFFERED",
videoSource.container,
videoUrl,
resumePosition,
video.duration.toDouble(),
speed,
metadataFromVideo(video)
);
ad.loadVideo(if (video.isLive) "LIVE" else "BUFFERED", videoSource.container, videoUrl, resumePosition, video.duration.toDouble(), speed, metadataFromVideo(video));
} else if (audioSource is IAudioUrlSource) {
val audioPath = "/audio-${id}"
val audioUrl = if(proxyStreams) url + audioPath else audioSource.getAudioUrl();
Logger.i(TAG, "Casting as singular audio");
ad.loadVideo(
if (video.isLive) "LIVE" else "BUFFERED",
audioSource.container,
audioUrl,
resumePosition,
video.duration.toDouble(),
speed,
metadataFromVideo(video)
);
ad.loadVideo(if (video.isLive) "LIVE" else "BUFFERED", audioSource.container, audioUrl, resumePosition, video.duration.toDouble(), speed, metadataFromVideo(video));
} else if (videoSource is IHLSManifestSource) {
if (proxyStreams || deviceProto == CastProtocolType.CHROMECAST) {
Logger.i(TAG, "Casting as proxied HLS");
castProxiedHls(
video, videoSource.url, videoSource.codec, resumePosition, speed
);
castProxiedHls(video, videoSource.url, videoSource.codec, resumePosition, speed);
} else {
Logger.i(TAG, "Casting as non-proxied HLS");
ad.loadVideo(
if (video.isLive) "LIVE" else "BUFFERED",
videoSource.container,
videoSource.url,
resumePosition,
video.duration.toDouble(),
speed,
metadataFromVideo(video)
);
ad.loadVideo(if (video.isLive) "LIVE" else "BUFFERED", videoSource.container, videoSource.url, resumePosition, video.duration.toDouble(), speed, metadataFromVideo(video));
}
} else if (audioSource is IHLSManifestAudioSource) {
if (proxyStreams || deviceProto == CastProtocolType.CHROMECAST) {
@ -346,15 +316,7 @@ abstract class StateCasting {
castProxiedHls(video, audioSource.url, audioSource.codec, resumePosition, speed);
} else {
Logger.i(TAG, "Casting as non-proxied audio HLS");
ad.loadVideo(
if (video.isLive) "LIVE" else "BUFFERED",
audioSource.container,
audioSource.url,
resumePosition,
video.duration.toDouble(),
speed,
metadataFromVideo(video)
);
ad.loadVideo(if (video.isLive) "LIVE" else "BUFFERED", audioSource.container, audioSource.url, resumePosition, video.duration.toDouble(), speed, metadataFromVideo(video));
}
} else if (videoSource is LocalVideoSource) {
Logger.i(TAG, "Casting as local video");