0xced / XCDYouTubeKit

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

Client Data Source Not Registered #435

Closed pdiazmon closed 3 years ago

pdiazmon commented 5 years ago

When I try to play a Youtube video in my tvOS app (within the simulator) I get the following error: [MediaRemote] [MRPlaybackQueueServiceClient] playbackQueueRequest 2E591177-D3D8-4CE8-A18F-FCF83FDA992E PineBoard-21384 /A600.000000x600.000000/R[0:1] responded to asset request with error Error Domain=kMRMediaRemoteFrameworkErrorDomain Code=15 "Operation requires a client data source to have been registered." UserInfo={NSLocalizedDescription=Operation requires a client data source to have been registered.}

I've set the api key in the YouTubeService object. And everything runs well until the AVPlayerViewController.player.play() method is called.

I have run the tvOS demo and I get the same error.

ravdamani commented 4 years ago

Adding the following to appDelegate.swift should fix the error.

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
    // Override point for customization after application launch.
    let audioSession = AVAudioSession.sharedInstance()
    do {
        try audioSession.setCategory(.playback, mode: .moviePlayback)
    }
    catch {
        print("Setting category to AVAudioSessionCategoryPlayback failed.")
    }
    return true
}