XCDYouTubeKit
XCDYouTubeKit copied to clipboard
Audio play in background and play multiple sounds for multiple videos.
I implement this @IBOutlet weak var ytPlayer: UIView!
func playYoutubeVideo() {
let strUrl = youTubeObjc.link
if let range = strUrl!.range(of: "=") {
let strIdentifier = strUrl!.substring(from: range.upperBound)
print("Identifier:\(strIdentifier)")
let videoPlayerViewController =
XCDYouTubeVideoPlayerViewController(videoIdentifier: strIdentifier)
videoPlayerViewController.present(in: ytPlayer)
// videoPlayerViewController.moviePlayer.play() videoPlayerViewController.moviePlayer.shouldAutoplay = false videoPlayerViewController.moviePlayer.prepareToPlay() } } i try to stop it but failed.
The demo app doesn't seem to be playing audio in the background by default when the app goes to the background or the phone is locked. Does something else have to be set somewhere?
The demo app doesn't seem to be playing audio in the background by default when the app goes to the background or the phone is locked. Does something else have to be set somewhere?
Have just found the solution to play audio in the background is to tap on the settings icon in the top right corner of the demo app, and change Audio Session category to Playback.