mirror of
https://gitlab.futo.org/videostreaming/grayjay.git
synced 2025-09-06 17:49:13 +00:00
casting: set metadata for video load requests
This commit is contained in:
parent
5540ec1531
commit
a9a78ba674
2 changed files with 36 additions and 14 deletions
|
@ -20,6 +20,7 @@ import org.fcast.sender_sdk.CastingDevice as RsCastingDevice;
|
|||
import org.fcast.sender_sdk.DeviceEventHandler as RsDeviceEventHandler;
|
||||
import org.fcast.sender_sdk.DeviceConnectionState
|
||||
import org.fcast.sender_sdk.LoadRequest
|
||||
import org.fcast.sender_sdk.Metadata
|
||||
|
||||
class CastingDeviceHandle {
|
||||
class EventHandler : RsDeviceEventHandler {
|
||||
|
@ -110,10 +111,11 @@ class CastingDeviceHandle {
|
|||
contentId: String,
|
||||
resumePosition: Double,
|
||||
duration: Double,
|
||||
speed: Double?
|
||||
speed: Double?,
|
||||
metadata: Metadata? = null
|
||||
) {
|
||||
try {
|
||||
device.load(LoadRequest.Video(contentType, contentId, resumePosition, speed, duration))
|
||||
device.load(LoadRequest.Video(contentType, contentId, resumePosition, speed, duration, metadata))
|
||||
} catch (e: Throwable) {
|
||||
Logger.e(TAG, "Failed to load video: $e")
|
||||
}
|
||||
|
|
|
@ -62,6 +62,7 @@ import org.fcast.sender_sdk.CastingDevice as RsCastingDevice
|
|||
import org.fcast.sender_sdk.ProtocolType
|
||||
import org.fcast.sender_sdk.CastContext
|
||||
import org.fcast.sender_sdk.DeviceConnectionState
|
||||
import org.fcast.sender_sdk.Metadata
|
||||
import org.fcast.sender_sdk.NsdDeviceDiscoverer
|
||||
import org.fcast.sender_sdk.urlFormatIpAddr
|
||||
import java.util.concurrent.atomic.AtomicInteger
|
||||
|
@ -463,6 +464,13 @@ class ExpStateCasting {
|
|||
_castId.incrementAndGet()
|
||||
}
|
||||
|
||||
private fun metadataFromVideo(video: IPlatformVideoDetails): Metadata {
|
||||
return Metadata(
|
||||
title = video.name,
|
||||
thumbnailUrl = video.thumbnails.getHQThumbnail()
|
||||
)
|
||||
}
|
||||
|
||||
suspend fun castIfAvailable(
|
||||
contentResolver: ContentResolver,
|
||||
video: IPlatformVideoDetails,
|
||||
|
@ -561,7 +569,8 @@ class ExpStateCasting {
|
|||
videoUrl,
|
||||
resumePosition,
|
||||
video.duration.toDouble(),
|
||||
speed
|
||||
speed,
|
||||
metadataFromVideo(video)
|
||||
)
|
||||
} else if (audioSource is IAudioUrlSource) {
|
||||
val audioPath = "/audio-${id}"
|
||||
|
@ -572,7 +581,8 @@ class ExpStateCasting {
|
|||
audioUrl,
|
||||
resumePosition,
|
||||
video.duration.toDouble(),
|
||||
speed
|
||||
speed,
|
||||
metadataFromVideo(video)
|
||||
);
|
||||
} else if (videoSource is IHLSManifestSource) {
|
||||
if (proxyStreams || ad.device.castingProtocol() == ProtocolType.CHROMECAST) {
|
||||
|
@ -591,7 +601,8 @@ class ExpStateCasting {
|
|||
videoSource.url,
|
||||
resumePosition,
|
||||
video.duration.toDouble(),
|
||||
speed
|
||||
speed,
|
||||
metadataFromVideo(video)
|
||||
);
|
||||
}
|
||||
} else if (audioSource is IHLSManifestAudioSource) {
|
||||
|
@ -611,7 +622,8 @@ class ExpStateCasting {
|
|||
audioSource.url,
|
||||
resumePosition,
|
||||
video.duration.toDouble(),
|
||||
speed
|
||||
speed,
|
||||
metadataFromVideo(video)
|
||||
);
|
||||
}
|
||||
} else if (videoSource is LocalVideoSource) {
|
||||
|
@ -726,7 +738,8 @@ class ExpStateCasting {
|
|||
videoUrl,
|
||||
resumePosition,
|
||||
video.duration.toDouble(),
|
||||
speed
|
||||
speed,
|
||||
metadataFromVideo(video)
|
||||
);
|
||||
|
||||
return listOf(videoUrl);
|
||||
|
@ -756,7 +769,8 @@ class ExpStateCasting {
|
|||
audioUrl,
|
||||
resumePosition,
|
||||
video.duration.toDouble(),
|
||||
speed
|
||||
speed,
|
||||
metadataFromVideo(video)
|
||||
);
|
||||
|
||||
return listOf(audioUrl);
|
||||
|
@ -949,7 +963,8 @@ class ExpStateCasting {
|
|||
hlsUrl,
|
||||
resumePosition,
|
||||
video.duration.toDouble(),
|
||||
speed
|
||||
speed,
|
||||
metadataFromVideo(video)
|
||||
)
|
||||
|
||||
return listOf(hlsUrl, videoUrl, audioUrl, subtitleUrl)
|
||||
|
@ -1028,7 +1043,8 @@ class ExpStateCasting {
|
|||
dashUrl,
|
||||
resumePosition,
|
||||
video.duration.toDouble(),
|
||||
speed
|
||||
speed,
|
||||
metadataFromVideo(video)
|
||||
);
|
||||
|
||||
return listOf(dashUrl, videoUrl, audioUrl, subtitleUrl);
|
||||
|
@ -1303,7 +1319,8 @@ class ExpStateCasting {
|
|||
hlsUrl,
|
||||
hackfixResumePosition,
|
||||
video.duration.toDouble(),
|
||||
speed
|
||||
speed,
|
||||
metadataFromVideo(video)
|
||||
);
|
||||
|
||||
return listOf(hlsUrl);
|
||||
|
@ -1575,7 +1592,8 @@ class ExpStateCasting {
|
|||
hlsUrl,
|
||||
resumePosition,
|
||||
video.duration.toDouble(),
|
||||
speed
|
||||
speed,
|
||||
metadataFromVideo(video)
|
||||
);
|
||||
|
||||
return listOf(
|
||||
|
@ -1690,7 +1708,8 @@ class ExpStateCasting {
|
|||
dashUrl,
|
||||
resumePosition,
|
||||
video.duration.toDouble(),
|
||||
speed
|
||||
speed,
|
||||
metadataFromVideo(video)
|
||||
);
|
||||
|
||||
return listOf(
|
||||
|
@ -1958,7 +1977,8 @@ class ExpStateCasting {
|
|||
dashUrl,
|
||||
resumePosition,
|
||||
video.duration.toDouble(),
|
||||
speed
|
||||
speed,
|
||||
metadataFromVideo(video)
|
||||
);
|
||||
|
||||
return listOf()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue