Stream Audio

I try to get Streaming Audio to work in WatchKIT. I just simple use the AVPlayer with a remote URL.

The Code working on iOS but WatchOS give me error.

I Added Background Audio to info.plst.


do{

try AVAudioSession.sharedInstance().setCategory(.playback)

try AVAudioSession.sharedInstance().setActive(true, options: .notifyOthersOnDeactivation)

} catch {

NSLog(error.localizedDescription)

}


let playBackURL = URL(string: "https://facyremoturl/stream.mp3")


PlayerItem = AVPlayerItem(url: playBackURL!)

PlayerItem.addObserver(self, forKeyPath: "timedMetadata", options: NSKeyValueObservingOptions(), context: nil)

Player = AVPlayer(playerItem: PlayerItem)

Player.play()


The Logs now show this error:

2019-06-05 14:31:09.149728+0200 watchtest WatchKit Extension[92922:10939355] [] [14:31:09.148] <<< CFByteFlume >>> FigByteFlumeCreateWithHTTP: [0x786984c0] Created CFHTTP byte flume 0x786984b0.

2019-06-05 14:31:09.210511+0200 watchtest WatchKit Extension[92922:10938788] Task <C4B1C312-11B6-4547-8072-EC1CCBD7FCF2>.<1> finished with error [-997] Error Domain=NSURLErrorDomain Code=-997 "Lost connection to background transfer service" UserInfo={_NSURLErrorRelatedURLSessionTaskErrorKey=(

"LocalDataTask <C4B1C312-11B6-4547-8072-EC1CCBD7FCF2>.<1>"

), _NSURLErrorFailingURLSessionTaskErrorKey=LocalDataTask <C4B1C312-11B6-4547-8072-EC1CCBD7FCF2>.<1>, NSLocalizedDescription=Lost connection to background transfer service}

2019-06-05 14:31:09.221282+0200


Anything i can do?