I'm trying to play an audio file in my SwiftUI app and first through something was wrong with the URL or file.
But even with this URL, it still gives me the following error:
What am I missing.
This is in a playground on Xcode 11.6
But even with this URL, it still gives me the following error:
Code Block Error Domain=NSCocoaErrorDomain Code=262 "The file couldn’t be opened because the specified URL type isn’t supported."
What am I missing.
This is in a playground on Xcode 11.6
Code Block import UIKit import AVKit if let url = URL(string:"https://audio-ssl.itunes.apple.com/apple-assets-us-std-000001/AudioPreview18/v4/9c/db/54/9cdb54b3-5c52-3063-b1ad-abe42955edb5/mzaf_520282131402737225.plus.aac.p.m4a") { var audioPlayer:AVAudioPlayer? do { let isReachable = try url.checkResourceIsReachable() print(isReachable) audioPlayer = try AVAudioPlayer(contentsOf: url) } catch { print(error) audioPlayer = nil } }