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 { try {
device.disconnect() device.disconnect()
} catch (e: Throwable) { } catch (e: Throwable) {
Logger.e( Logger.e(TAG, "Failed to disconnect from device: $e")
TAG, "Failed to disconnect from device: $e"
)
} }
}) }));
)
} }
} }
} }
CastConnectionState.DISCONNECTED -> { CastConnectionState.DISCONNECTED -> {
UIDialogs.toast(it, "Disconnected from device") UIDialogs.toast(it, "Disconnected from device")
synchronized(_castingDialogLock) { synchronized(_castingDialogLock) {
@ -229,7 +225,7 @@ abstract class StateCasting {
device.onTimeChanged.clear(); device.onTimeChanged.clear();
device.onVolumeChanged.clear(); device.onVolumeChanged.clear();
device.onDurationChanged.clear(); device.onDurationChanged.clear();
return return;
} }
activeDevice = device 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) { return withContext(Dispatchers.IO) {
val ad = activeDevice ?: return@withContext false; val ad = activeDevice ?: return@withContext false;
if (ad.connectionState != CastConnectionState.CONNECTED) { if (ad.connectionState != CastConnectionState.CONNECTED) {
@ -300,45 +296,19 @@ abstract class StateCasting {
val videoPath = "/video-${id}" val videoPath = "/video-${id}"
val videoUrl = if(proxyStreams) url + videoPath else videoSource.getVideoUrl(); val videoUrl = if(proxyStreams) url + videoPath else videoSource.getVideoUrl();
Logger.i(TAG, "Casting as singular video"); Logger.i(TAG, "Casting as singular video");
ad.loadVideo( ad.loadVideo(if (video.isLive) "LIVE" else "BUFFERED", videoSource.container, videoUrl, resumePosition, video.duration.toDouble(), speed, metadataFromVideo(video));
if (video.isLive) "LIVE" else "BUFFERED",
videoSource.container,
videoUrl,
resumePosition,
video.duration.toDouble(),
speed,
metadataFromVideo(video)
);
} else if (audioSource is IAudioUrlSource) { } else if (audioSource is IAudioUrlSource) {
val audioPath = "/audio-${id}" val audioPath = "/audio-${id}"
val audioUrl = if(proxyStreams) url + audioPath else audioSource.getAudioUrl(); val audioUrl = if(proxyStreams) url + audioPath else audioSource.getAudioUrl();
Logger.i(TAG, "Casting as singular audio"); Logger.i(TAG, "Casting as singular audio");
ad.loadVideo( ad.loadVideo(if (video.isLive) "LIVE" else "BUFFERED", audioSource.container, audioUrl, resumePosition, video.duration.toDouble(), speed, metadataFromVideo(video));
if (video.isLive) "LIVE" else "BUFFERED",
audioSource.container,
audioUrl,
resumePosition,
video.duration.toDouble(),
speed,
metadataFromVideo(video)
);
} else if (videoSource is IHLSManifestSource) { } else if (videoSource is IHLSManifestSource) {
if (proxyStreams || deviceProto == CastProtocolType.CHROMECAST) { if (proxyStreams || deviceProto == CastProtocolType.CHROMECAST) {
Logger.i(TAG, "Casting as proxied HLS"); Logger.i(TAG, "Casting as proxied HLS");
castProxiedHls( castProxiedHls(video, videoSource.url, videoSource.codec, resumePosition, speed);
video, videoSource.url, videoSource.codec, resumePosition, speed
);
} else { } else {
Logger.i(TAG, "Casting as non-proxied HLS"); Logger.i(TAG, "Casting as non-proxied HLS");
ad.loadVideo( ad.loadVideo(if (video.isLive) "LIVE" else "BUFFERED", videoSource.container, videoSource.url, resumePosition, video.duration.toDouble(), speed, metadataFromVideo(video));
if (video.isLive) "LIVE" else "BUFFERED",
videoSource.container,
videoSource.url,
resumePosition,
video.duration.toDouble(),
speed,
metadataFromVideo(video)
);
} }
} else if (audioSource is IHLSManifestAudioSource) { } else if (audioSource is IHLSManifestAudioSource) {
if (proxyStreams || deviceProto == CastProtocolType.CHROMECAST) { if (proxyStreams || deviceProto == CastProtocolType.CHROMECAST) {
@ -346,15 +316,7 @@ abstract class StateCasting {
castProxiedHls(video, audioSource.url, audioSource.codec, resumePosition, speed); castProxiedHls(video, audioSource.url, audioSource.codec, resumePosition, speed);
} else { } else {
Logger.i(TAG, "Casting as non-proxied audio HLS"); Logger.i(TAG, "Casting as non-proxied audio HLS");
ad.loadVideo( ad.loadVideo(if (video.isLive) "LIVE" else "BUFFERED", audioSource.container, audioSource.url, resumePosition, video.duration.toDouble(), speed, metadataFromVideo(video));
if (video.isLive) "LIVE" else "BUFFERED",
audioSource.container,
audioSource.url,
resumePosition,
video.duration.toDouble(),
speed,
metadataFromVideo(video)
);
} }
} else if (videoSource is LocalVideoSource) { } else if (videoSource is LocalVideoSource) {
Logger.i(TAG, "Casting as local video"); Logger.i(TAG, "Casting as local video");