Swift- audio implementation crash: "EXC_BAD_INSTRUCTION" -


i trying put audio app , put in following code , placed mp3 audio file in assets folder, , crashed with: "exc_bad_instruction(code=exc_1386_invop, subcode=0x0)"

i use on i'm doing wrong/ need put audio file. code:

import uikit import avfoundation  class viewcontroller: uiviewcontroller {     var audioplayer = avaudioplayer()          override func viewdidload() {         super.viewdidload()     // additional setup after loading view, typically nib.     scrollview.scrollenabled = true     scrollview.contentsize = cgsize(width:473, height: 112)     changer = 0     tapview.hidden = true     yoohooview.hidden = true     var alertsound = nsurl(fileurlwithpath: nsbundle.mainbundle().pathforresource("untitled", oftype: "mp3")!) //crashes here         println(alertsound)          // removed deprecated use of avaudiosessiondelegate protocol         avaudiosession.sharedinstance().setcategory(avaudiosessioncategoryplayback, error: nil)         avaudiosession.sharedinstance().setactive(true, error: nil)          var error:nserror?         audioplayer = avaudioplayer(contentsofurl: alertsound, error: &error)         audioplayer.preparetoplay()         audioplayer.play()  } 

class viewcontroller: uiviewcontroller {  var audioplayer = avaudioplayer()  @iboutlet weak var svscrollview: uiscrollview!  override func viewdidload() {     super.viewdidload()     svscrollview.scrollenabled = true     svscrollview.contentsize = cgsize(width:473, height: 112)     var alertsound = nsurl(fileurlwithpath: nsbundle.mainbundle().pathforresource("mymusic", oftype: "mp3")!)     println(alertsound)     avaudiosession.sharedinstance().setcategory(avaudiosessioncategoryplayback, error: nil)     avaudiosession.sharedinstance().setactive(true, error: nil)     var error:nserror?     audioplayer = avaudioplayer(contentsofurl: alertsound, error: &error)     audioplayer.preparetoplay()     audioplayer.play() }  } 

i tried above code. . . , it's fine work me . . . please try . . .


Comments

Popular posts from this blog

php - Submit Form Data without Reloading page -

linux - Rails running on virtual machine in Windows -