0xced / XCDYouTubeKit

YouTube video player for iOS, tvOS and macOS
MIT License
2.92k stars 627 forks source link

Audio play in background and play multiple sounds for multiple videos. #427

Open sAurangzaib opened 5 years ago

sAurangzaib commented 5 years ago

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.

mobile-appz commented 4 years ago

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?

mobile-appz commented 4 years ago

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.