Home > front end >  Is it possible to open audio picker in swift
Is it possible to open audio picker in swift

Time:11-25

I need to pick an audio from the iOS device, and then play the audio.But I could not find any library to pick the audio file from the phone storage(something like a UIImagePicker for Images). Is there any library which will help me choose audio files from an iOS device and play the music

CodePudding user response:

This code allows user to pick audio files.

import MobileCoreServices

let pickerController = UIDocumentPickerViewController(documentTypes: ["public.audio"], in: .import)
pickerController.delegate = self
pickerController.modalPresentationStyle = .fullScreen
self.present(pickerController, animated: true, completion: nil)
  • Related