swift - Not able to play a mp3 in iOS -


document directory url

file:///var/mobile/containers/data/application/895de1a3-5d2e-462b-8d13-518b7cafc6c7/documents/146791.mp3 

code using play url

do {        print(url)         audioplayer = try avaudioplayer.init(contentsof: url, filetypehint: avfiletypempeglayer3)        guard let player = audioplayer else { return }         player.preparetoplay()        player.play()     } catch let error {         print(error.localizeddescription)     } 

error getting

the operation couldn’t completed. (osstatus error 1685348671.)

swift 3

do {             let player = try avaudioplayer(contentsof: url!)              player.volume = 0.6             player.preparetoplay()             player.play()          }         catch {             print("file not found")         } 

Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -