Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chromecast default subtitles language #274

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 34 additions & 1 deletion Addons/GoogleCast/BasicCastBuilder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import GoogleCast
@objc public var partnerID: String?
@objc public var uiconfID: String?
@objc public var adTagURL: String?
@objc public var defaultCCLanguage : String?
@objc public var metaData: GCKMediaMetadata?

@objc public var streamType = StreamType.unknown {
Expand Down Expand Up @@ -171,6 +172,23 @@ import GoogleCast
}


/**
Set - defaultCCLanguage
*/
@discardableResult
@nonobjc public func set(defaultCCLanguage: String?) -> Self{

guard defaultCCLanguage != nil
else {
PKLog.warning("Trying to set nil to defaultCCLanguage")
return self
}

self.defaultCCLanguage = defaultCCLanguage
return self
}


internal func validate() throws {
guard self.contentId != nil else {
throw BasicCastBuilder.BasicBuilderDataError.missingContentId
Expand Down Expand Up @@ -210,12 +228,27 @@ import GoogleCast
internal func customData() -> [String:Any]? {

if let embedConfig = self.embedConfig() {
let customData: [String:Any] = ["embedConfig":embedConfig]
var customData: [String:Any] = ["embedConfig":embedConfig]

// add chromecast defaultLanguageKey
customData["receiverConfig"] = self.chromeDefaultLanguageKey()

return customData
}
return nil
}

internal func chromeDefaultLanguageKey() -> [String:Any]? {
var chromeDefaultLanguageKey: [String:Any] = [:]

if let defaultLanguage = self.defaultCCLanguage {
chromeDefaultLanguageKey ["defaultLanguageKey"] = defaultLanguage
}

return chromeDefaultLanguageKey

}


internal func embedConfig() -> [String:Any]? {

Expand Down