0

I am trying to play an audio in apple watch simulator but it keeps giving this error.

The operation couldn’t be completed. (OSStatus error 2003334207.)

Is it possible to play an audio with simulator? Audio url is fine. Here is my code.

self.player = try AVAudioPlayer(contentsOf: url as URL)
player?.prepareToPlay()
player?.volume = 10.0
player?.play()
Eric Aya
  • 69,473
  • 35
  • 181
  • 253
hinali lad
  • 73
  • 10

2 Answers2

0

It is not possible to play an audio with remote URL in apple watch. You need download it first and then play it. Now it's working fine and I can play the audio in simulator as well.

hinali lad
  • 73
  • 10
0
let asset  = AVURLAsset(url: url!, options: nil)
let item = AVPlayerItem(asset: asset)
self.player = AVPlayer(playerItem: item)
self.player.play()
self.player.volume = 10.0
Venus
  • 453
  • 2
  • 9
  • You can play audio with the code. It works well for mp3 file as well as m3u8 files. – Venus Feb 22 '22 at 04:44
  • does this work with a remote URL? Your answer should be updated to include some explanation about why it works and the code in the question doesn't – lewis Mar 03 '22 at 14:14
  • Yes, it works. Recent watchOS allows AVPlayer to play the audio files as well. – Venus Mar 04 '22 at 02:55