I've created an app for playing radio stream from URL, but it is not playing audio when app is on background. I checked audio and airplay in background modes in app settings but still it does not work. Do I need to add some permissions in appdelegate? Any ideas? Thank you in advance for your help. Here is my code:
import UIKit
import AVKit
class ViewController: UIViewController {
var player : AVPlayer!
var dict = NSDictionary()
@IBOutlet weak var ArtistLabel: UILabel!
@IBAction func playButtonPressed(_ sender: UIButton){
let url = "https://test.com/stream.mp3"
player = AVPlayer(url: URL(string: url)!)
player.volume = 1.0
player.rate = 1.0
player.play()
}
@IBAction func stopButtonStopped(sender: UIButton) {
player.pause()
}
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
overrideUserInterfaceStyle = .light
}
}