Every time I close the app (not quit it) or turn off the screen the music stops. is their something I am missing?
My code.
I have a file called MediaPlayer.swift
inside it I have the following
//
//  MusicPlayer.swift
//  DRN1
//
//  Created by Russell Harrower on 25/11/19.
//  Copyright © 2019 Russell Harrower. All rights reserved.
//
import Foundation
import AVFoundation
class MusicPlayer {
    static let shared = MusicPlayer()
    var player: AVPlayer?
    func startBackgroundMusic() {
        let urlString = "http://stream.radiomedia.com.au:8003/stream"
        guard let url = URL.init(string: urlString)
            else {
                return
        }
        let playerItem = AVPlayerItem.init(url: url)
        player = AVPlayer.init(playerItem: playerItem)
        player!.play()
    }
}
I am calling that from my FirstViewController.swift
override func viewDidLoad() {
          MusicPlayer.shared.startBackgroundMusic()
          // Do any additional setup after loading the view.
          self.artist.textAlignment = .center
          self.song.textAlignment = .center
          scheduledTimerWithTimeInterval()
          self.nowplaying()
      }
I have the following ticked.
here a demo of it currently https://www.youtube.com/watch?v=REtKHUR13k0

