SwiftAudio icon indicating copy to clipboard operation
SwiftAudio copied to clipboard

Not working with local file in Queue

Open aloveric opened this issue 4 years ago • 1 comments
trafficstars

Describe the bug When sourceType: .stream, it works. But not working with local file in Queue.

Code: var player = QueuedAudioPlayer() let filePath = "/Users/xxxx/1.m4a" let audioItem = DefaultAudioItem(audioUrl: filePath, sourceType: .file) try? self.player.add(item: audioItem, playWhenReady: true)

Smartphone:

  • Device: [ iPhoneXs ]
  • OS: [ iOS14.3]

aloveric avatar Jan 05 '21 07:01 aloveric

You should check if you have permission to read the m4a file. Normally, you can only access the folders and files in your app sandbox on iOS . You may have two choice:

  1. use UIFileSharingEnabled, expose your sandbox directory to user in iOS Files App, then copy file to that directory in Files app, here is an example
  2. Or, you can just ask user to pick files outside your app container , see providing_access_to_directories

I'm new to iOS development, so if the answer has some wrong , please let me know ,thank you !

asmpg avatar Jan 07 '21 05:01 asmpg