How we cast local gallery video to GoogleCast SDK iOS?
let url = URL.init(string: "Local Gallery pickup URL file:///private/var/mobile/Containers/Data/PluginKitPlugin/CBC411B1-375B-44F1-8183-CD932E37F0F3/tmp/trim.922BBE6C-5C61-4613-B881-3FCF65079885.MOV")
guard let mediaURL = url else {
print("invalid mediaURL") return }
if let device = connectedDevice {
castContext.discoveryManager.device(withUniqueID: device.uniqueID)
castContext.sessionManager.startSession(with: device)
}
let metadata = GCKMediaMetadata()
metadata.setString("movieModel!.desc", forKey: kGCKMetadataKeyTitle)
metadata.setString("movieModel!.desc", forKey: kGCKMetadataKeySubtitle)
metadata.addImage(GCKImage(url: URL(string: "https://commondatastorage.googleapis.com/gtv-videos-bucket/sample/images/BigBuckBunny.jpg")!,width: 480,height: 360))
let mediaInfoBuilder = GCKMediaInformationBuilder.init(contentURL: mediaURL)
mediaInfoBuilder.streamType = GCKMediaStreamType.none;
mediaInfoBuilder.contentType = "video/mp4"
mediaInfoBuilder.metadata = metadata;
let mediaInformation = mediaInfoBuilder.build()
if let request = sessionManager.currentSession?.remoteMediaClient?.loadMedia(mediaInformation) {
request.delegate = self
}
GCKCastContext.sharedInstance().presentDefaultExpandedMediaControls()
How we cast selected gallery video to GoogleCast Smart TV Device