mirror of
https://gitlab.futo.org/videostreaming/grayjay.git
synced 2025-09-13 13:02:34 +00:00
casting: undo more formatting
This commit is contained in:
parent
b1c079aaee
commit
86cafffda7
1 changed files with 13 additions and 51 deletions
|
@ -174,7 +174,7 @@ abstract class StateCasting {
|
||||||
Logger.i(TAG, "Casting connecting to [${device.name}]");
|
Logger.i(TAG, "Casting connecting to [${device.name}]");
|
||||||
UIDialogs.toast(it, "Connecting to device...")
|
UIDialogs.toast(it, "Connecting to device...")
|
||||||
synchronized(_castingDialogLock) {
|
synchronized(_castingDialogLock) {
|
||||||
if (_currentDialog == null) {
|
if(_currentDialog == null) {
|
||||||
_currentDialog = UIDialogs.showDialog(context, R.drawable.ic_loader_animated, true,
|
_currentDialog = UIDialogs.showDialog(context, R.drawable.ic_loader_animated, true,
|
||||||
"Connecting to [${device.name}]",
|
"Connecting to [${device.name}]",
|
||||||
"Make sure you are on the same network\n\nVPNs and guest networks can cause issues", null, -2,
|
"Make sure you are on the same network\n\nVPNs and guest networks can cause issues", null, -2,
|
||||||
|
@ -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) {
|
||||||
|
@ -298,47 +294,21 @@ abstract class StateCasting {
|
||||||
|
|
||||||
if (videoSource is IVideoUrlSource) {
|
if (videoSource is IVideoUrlSource) {
|
||||||
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");
|
||||||
|
@ -437,7 +399,7 @@ abstract class StateCasting {
|
||||||
return listOf(videoUrl);
|
return listOf(videoUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun castLocalAudio(video: IPlatformVideoDetails, audioSource: LocalAudioSource, resumePosition: Double, speed: Double?): List<String> {
|
private fun castLocalAudio(video: IPlatformVideoDetails, audioSource: LocalAudioSource, resumePosition: Double, speed: Double?) : List<String> {
|
||||||
val ad = activeDevice ?: return listOf();
|
val ad = activeDevice ?: return listOf();
|
||||||
|
|
||||||
val url = getLocalUrl(ad);
|
val url = getLocalUrl(ad);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue