AVPlayer Works on Simulator, but not on device

I'm trying to stream a radio, here is the code:


          guard let streamURL = URL(string: "http://17523.live.streamtheworld.com:3690/JP_SP_FM_SC") else {       
                print("Stream Error ")          
            return
        }
        let streamItem = AVPlayerItem(url: streamURL)
     
        avPlayer = AVPlayer(playerItem: streamItem)
      
        avPlayer.play()

It's working on Simulator but in the device, it's not! In the console, I have the following error:

CredStore - performQuery - Error copying matching creds. Error=-25300, query={

class = inet;

"m_Limit" = "m_LimitAll";

"r_Attributes" = 1;

sync = syna;

}

Can anyone help me with a clue?

Replies

Add: streamURL = streamURL.addingPercentEncoding(withAllowedCharacters: .urlFragmentAllowed) after creating the streamURL. Another interesting thing, was that I had to put the app in the background and then back to foreground in order for the player to play.

i have the same issue, with a HTTPS URL.


The proposed fix didn't work for me

one thing i noticed, is that using the same URL like this, works! :O


let player = AVPlayer(url: videoURL)
    player.allowsExternalPlayback = false
    let viewController = AVPlayerViewController()
    viewController.player = player