xcode - How to make UIButton play corresponding audio clip from selection in UITable? -


Text after "

I have two views in my storyboard, previously included in the array of an array of just one uitable word. When a cell is selected from my app in the second view, which contains a label (which gives the contents of its related "wordTitle", see below) and a button. I have an audio file of each entry in each UITable, in my collaborative file folder. I have a custom class named Word that has "Word Tight" Property, I have created many word objects in my Visual Controller.

  word = [[nsmutab and other] init]; // custom word class object word * wrd = [[word alloc]] init]; Wrd.wordTitle = @ "one"; [Words addObject: wrd]; Wrd = [[word alloc]] init]; Wrd.wordTitle = @ "Two"; [Words addObject: wrd]; // and similarly   

The label is being updated correctly in the second view when I select the cell in the UTTable. How do I go about setting the button so that when it is pressed into another scene the corresponding audio file is played?

After

This whole thing is now easy to use the new AV Foundation AvadiOiGen. Actually you will create an audio engine and an aviable player and load an audiophile in the player and play it. var Error: NSError? Let engine = AVAudioEngine () playerNode = AVAudioPlayerNode () / set the AudioFileVAR audio file URL: NSURL? Var audio file: AVAudioFile? Var audio format: AVAudioFormat?

Enter the audiplayernode for the engine

  go mainMixer = engine.main MixerNode engine.attachNode (playerNode) // wire it up engine.connect (playerNode To: MainMixer, format: audioFormat) // Gentlemen your engine engine.startAndReturnError (start & error)   

Normally the player will use something like you in a To load the audio file:

  function loadAudioFileInotPlayer () {audioFileUrl = NSURL (fileURLWithPath: "/ somepath / file name") audiofile = AVAudioFile (forReading: audioFileUrl, commonFormat: .PCMFormatFloat32, Interlaced : True, error: & amp; Error) audioFormat = audiofile .processingFormat} function play () {// player node load the audio file in playerNode.scheduleFile (audiofile, atTime: zero, completionHandler: zero)! playerNode.play () println ("Play was pressed")}   

You will need to create a string for the path in the audioFileUrl that indicates the file name that you want to assign to that specific file Want to load. Hope this will help you.

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -