ios - Cannot Play "m4a" in swift 2. -


i new swift. trying run audio file using avfoundation in swift 2. codes run file format "mp3" xcode crashes "m4a". whats mistake? using xcode 7.3.1.

class viewcontroller: uiviewcontroller {

 var myaudioplayer = avaudioplayer()  override func viewdidload() {     super.viewdidload()     // additional setup after loading view, typically nib.       let myfilepathstring = nsbundle.mainbundle().pathforresource("par30", oftype:"m4a")      if let myfilepathstring = myfilepathstring     {         let myfilepathurl = nsurl(fileurlwithpath: myfilepathstring)           do{              try myaudioplayer = avaudioplayer(contentsofurl: myfilepathurl)              //myaudioplayer.play()          }catch         {             print("error")         }     } }   @ibaction func play(sender: anyobject) {      myaudioplayer.play()  }   @ibaction func stop(sender: anyobject) {      myaudioplayer.stop()     myaudioplayer.currenttime = 0   } 

}


Comments

Popular posts from this blog

sequelize.js - Sequelize group by with association includes id -

android - Robolectric "INTERNET permission is required" -

java - Android raising EPERM (Operation not permitted) when attempting to send UDP packet after network connection -