попробуйте:
func streamPlay(streamUrl : string){
let playerItem = AVPlayerItem( url:NSURL( string: streamUrl )! as URL )
player = AVPlayer(playerItem:playerItem)
player!.rate = 1.0;
//isplay is a bool variable that indicate your stream playing is in process or not(default value = false)
if isPlay{
player!.pause()
//playDemo is button that you use to stream play
playDemo!.setImage(UIImage(named: "playBtn"), for: UIControl.State.normal)
playDemo!.setTitle("Pause", for: UIControl.State.normal)
isPlay = false
}else{
player!.play()
playDemo!.setImage(UIImage(named: "media_pause"), for: UIControl.State.normal)
playDemo!.setTitle("play", for: UIControl.State.normal)
isPlay = true
}
}
по вашему мнениюDidLoad:
let url = "https://stage.careandcarers.com/file/get/0b710400-4454-4a46-9ed5-8a542f046ed8.m4a"
streamPlay(streamUrl : url)