phawind111 / google-cast-sdk

Automatically exported from code.google.com/p/google-cast-sdk
0 stars 0 forks source link

iOS Sdk Google Chromecast Subtitles #710

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
This is how I have implemented to show subtitles using a Google Chromecast 
device. But the subtitle doesnt appear. 

var subtitleName:String = ""
var subtitleLink:String = ""
var subtitleType:String = ""
var subtitleCode:String = ""

if let _ = self.selectedSubtitle
{
  let subtitleIndex: Int = self.selectedSubtitle! - 1
  subtitleName = self.videoObject.subtitles![subtitleIndex].language!
  subtitleLink = self.videoObject.subtitles![subtitleIndex].link!
  subtitleLink = subtitleLink + ".vtt"

  subtitleType = self.videoObject.subtitles![subtitleIndex].type!
  subtitleCode = (self.subtitleLanguages.objectAtIndex(subtitleIndex) as! ICFLanguageObject).iso_639_3! as String
}

print("\n\nName: \(subtitleName),\n Link:\(subtitleLink) \n Type: 
\(subtitleType)\n Code: \(subtitleCode)\n\n")
//Values Printed on console

//Name: ara,

//Link:http://a**************c.vtt

//Type: subtitles

//Code: ara

let subtitlesTrack = GCKMediaTrack(identifier: 1,
                     contentIdentifier:subtitleLink,
                     contentType: subtitleType,
                     type: GCKMediaTrackType.Text,
                     textSubtype: GCKMediaTextTrackSubtype.Captions,
                     name: subtitleName,
                     languageCode: subtitleCode,
                     customData: nil)

let tracks = [subtitlesTrack]

let mediaInformation = GCKMediaInformation(
                       contentID:self.playbackObject.playbackURL(),
                       streamType: GCKMediaStreamType.None,
                       contentType: self.playbackObject.playbacktype(),
                       metadata: metadata,
                       streamDuration: progress,
                       mediaTracks: tracks,
                        textTrackStyle: textTrackStyle,
                        customData: nil
                    )

deviceManager?.setVolume(0.5)

mediaControlChannel!.loadMedia(mediaInformation, autoplay: true, playPosition: 
progress)

An Android developer advised me to make changes in Google Chromecast API. Do I 
have to make changes in Chromecast API even for iOS ?

Original issue reported on code.google.com by taimur.a...@icflix.com on 16 Dec 2015 at 6:18

GoogleCodeExporter commented 8 years ago
Yes, Google Cast SDK for iOS provides the APIs to develop an iOS sender 
application. Find the relevant documentation here (toggle Swift): 
https://developers.google.com/cast/docs/ios_sender#tracks and sample 
application here: 
https://github.com/googlecast/CastHelloVideo-ios/blob/master/HelloVideoGoogleCas
tSwift/ViewController.swift#L163

With regards to the implementation provided, since you have defined global 
variables for these properties; that might be a good place to look for 
debugging. In general, we do not troubleshoot application level code issues on 
this forum. Please direct this question on Stack Overflow (under Google-Cast or 
Chromecast tag) or other open communities. 

However, if you think this is an issue with Cast SDK, please respond to this 
ticket with detailed steps to reproduce the issue, receiver logs and specific 
information of the testing environment and we'd gladly look into it. 

Original comment by na...@google.com on 18 Dec 2015 at 12:01