【发布时间】:2017-04-09 05:03:46
【问题描述】:
我正在使用 Swift 3.0 开发一个应用程序,让用户有机会在线观看电视频道。它当时仅限于意大利,所以我正在尝试用意大利语翻译应用程序中的每个按钮......但我在顶部的“完成”按钮(和“直播”字段)遇到问题每当用户选择要流式传输的频道时出现的 AVPlayer 屏幕。我确信有一种方法可以编辑它们,因为当我在 Safari 中打开流时,完成按钮正确显示为“Fine”并且“实时流”变为“Trasmissione in diretta”......我想看看他们也是这样,但我不知道如何达到这个目标。
我没有为播放器创建任何特定的类,只是创建了从情节提要到 AVPlayerController 的转场,我完全从包含频道的表视图中管理流;这是我的重要代码:
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if segue.identifier == "guardaCanale" {
let destinazione = segue.destination as! AVPlayerViewController
if let cellaCanaleSelezionata = sender as? CanaleTableViewCell {
let indexPath = tableView.indexPath(for: cellaCanaleSelezionata)!
let canaleSelezionato = ritornaIlCanaleCorretto(indexPath: indexPath)
let url = URL(string: canaleSelezionato.urlCanale)
if let streamingURL = url {
destinazione.player = AVPlayer(url: streamingURL)
// Il do-try-catch seguente serve per far funzionare l'audio dell'app anche se l'iPhone è in modalità silenziosa; togli il blocco per fare in modo che l'app non produca audio se l'iPhone è in modalità silenziosa
do {
try AVAudioSession.sharedInstance().setCategory(AVAudioSessionCategoryPlayback)
} catch {
print("Errore: non riesco a riprodurre l'audio se iPhone è in modalità silenziosa.")
}
destinazione.player?.play()
}
}
}
}
有人可以帮帮我吗?我不想修改完成按钮的行为,只需更改其在屏幕上的可见名称...希望有人可以帮助我!太感谢了! :)
【问题讨论】:
-
“但我不知道如何实现该目标” 这称为本地化。如果您为意大利语本地化应用程序,按钮将自动显示意大利语(在意大利语设备上)。
标签: ios swift button avplayer live-streaming