1
當我在iOS模擬器中運行以下代碼時,我從嵌入的YouTube視頻獲取聲音。當我在iPhone 6上運行這個功能時,我聽不到來自揚聲器的聲音,但是我確實從耳機聽到了聲音。這是硬件問題還是軟件?沒有聲音來自嵌入的YouTube視頻
import UIKit
class ThreeKeyViewController: UIViewController {
@IBOutlet weak var videoView: UIWebView!
override func viewDidLoad() {
super.viewDidLoad()
let youTubeUrl = "https://www.youtube.com/embed/hP-vuMaoHjU"
videoView.allowsInlineMediaPlayback = true
dispatch_async(dispatch_get_main_queue(), {() -> Void in
self.videoView.loadHTMLString("<iframe width=\"\(self.videoView.frame.width)\" height=\"\(self.videoView.frame.height)\" src=\"\(youTubeUrl)\" frameborder=\"0\" allowfullscreen></iframe>", baseURL: nil)
print("This is run on the main queue, after the previous code in outer block")
})
// Do any additional setup after loading the view.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}