swift - How to access music files stored on the iOS device? -
my application having trouble locating files in music folder on ios device.
if files held below application data (in playpen), no problem. when go looking "music" folder, using following lines:
dest_dir = try! filemanager.default.url(for: .musicdirectory, in: .alldomainsmask, appropriatefor: nil, create: false) musicdir = dest_dir if uiapplication.shared.canopenurl(musicdir) { print("found music directory") }else { print("did not find music directory") }
when code executes canopenurl
, permissions complaint.
i tried accessing user directory (thinking navigate music).
any clues on how application can access files , playlists held under music system folder on ios device?
there no such thing "the music folder" in ios. access user's music library, use media player framework.
example (assuming have obtained necessary authorization user):
let query = mpmediaquery() let result = query.items
Comments
Post a Comment