avaudioplayer

FileManager cannot find audio file

三世轮回 提交于 2019-12-02 05:16:32
Helloo! My ultimate goal is to create a UITableViewController with recordings made in-app, using FileManager to traverse the /Documents/ directory and list all the recordings found there. The recording and playback are functioning just fine with one recording, with the following setup: // In VC#1 func setupRecorder(){ let audioSession:AVAudioSession = AVAudioSession.sharedInstance() do { try audioSession.setCategory(AVAudioSessionCategoryPlayAndRecord) } catch { print("Audio Setup Error: \(error)") } do { try audioSession.setActive(true) } catch { print("Audio Setup Error: \(error)") } let

Can't play file from documents in AVAudioPlayer

爱⌒轻易说出口 提交于 2019-12-02 04:49:45
I have a file on documents folder of app and I want to play it. if NSFileManager.defaultManager().fileExistsAtPath(pathString) { let url = NSURL(fileURLWithPath:pathString, isDirectory: false) do { let player = try AVAudioPlayer(contentsOfURL:url) player.prepareToPlay() player.play() } catch let error as NSException { print(error) } catch {} } There is a file on file system and I checked its existence. Also all lines in do block are executed. There is neither exception nor error and still no sound is played. What are possible problems and how can I solve them? You should make audioPlayer an

How to multiple play() in audioPlayerDidFinishPlaying method

北战南征 提交于 2019-12-02 04:44:33
When I press "yourButton" or "yourButton2" or "yourButton3" each plays an audio file and while the audio is playing the UIButton is set selected. I would like "yourButton4" to implement the method of the other UIButtons in a row. (At first, plays an audio file and set selected "yourButton" then "yourButton2" and "yourButton3") . However, when I press "yourButton4", "yourButton2" and "yourButton3" is played at same time as play() method Plays a sound asynchronously. let url1 = Bundle.main.bundleURL.appendingPathComponent("music1.mp3") let url2 = Bundle.main.bundleURL.appendingPathComponent(

iOS Sound not playing in Swift

给你一囗甜甜゛ 提交于 2019-12-02 04:28:30
I'm building a tableview in which each cell represents a sound that is played when the user taps that particular cell. In objective-C it worked fine, but now that Apple released Swift I decided to move over instantly, but for some reason the sound does not play. My code when the user taps the cell: func tableView(tableView: UITableView!, didSelectRowAtIndexPath indexPath: NSIndexPath!) { var currentItem = self.items[indexPath.row] var audioPath = NSString(string: NSBundle.mainBundle().pathForResource(currentItem.soundID, ofType: "mp3")) println(audioPath) var audioPlayer = AVAudioPlayer

how to retrieve audio file from parse swift

删除回忆录丶 提交于 2019-12-02 03:54:46
问题 I have successfully saved an Audio file to Parse but am struggling to download it again. I can't work out what the block should be to go with getDataInBackgroundWithBlock. And how to actually save the file. Any help much appreciated! let query = PFQuery(className: "wordRecordings") query.whereKey("wordName", equalTo: "\(joinedWord)") query.findObjectsInBackgroundWithBlock { (objects:[PFObject]?, error:NSError?) -> Void in if error == nil{ for object in objects! { let audioFile = object[

AVAudioPlayer working on Simulator but not on Real Device

为君一笑 提交于 2019-12-02 03:30:32
问题 While I play recorded Audio I get this error: fatal error: unexpectedly found nil while unwrapping an Optional value on this line of code: SoundPlayer = try AVAudioPlayer(contentsOfURL: getFileURL()) But it is working perfectly on Simulator except real device. ViewController.Swift: import UIKit import AVFoundation class ViewController: UIViewController, AVAudioPlayerDelegate, AVAudioRecorderDelegate { @IBOutlet var PlayBTN: UIButton! @IBOutlet var RecordBTN: UIButton! var soundRecorder :

How to play sound from tcp stream in java

倾然丶 夕夏残阳落幕 提交于 2019-12-02 02:59:20
There is another app that writes raw wav file on this socket. The client starts and begins listening to the song which is currently playing. Socket clientSocket = new Socket("localhost", 9595); AudioInputStream stream = AudioSystem.getAudioInputStream(clientSocket.getInputStream()); I get javax.sound.sampled.UnsupportedAudioFileException: could not get audio input stream from input stream Doc about AudioSystem.getAudioInputStream: "Obtains an audio input stream from the provided input stream. The stream must point to valid audio file data." How to play sound from a TCP stream? Considering the

AVAudioPlayer working on Simulator but not on Real Device

落爺英雄遲暮 提交于 2019-12-02 02:17:15
While I play recorded Audio I get this error: fatal error: unexpectedly found nil while unwrapping an Optional value on this line of code: SoundPlayer = try AVAudioPlayer(contentsOfURL: getFileURL()) But it is working perfectly on Simulator except real device. ViewController.Swift: import UIKit import AVFoundation class ViewController: UIViewController, AVAudioPlayerDelegate, AVAudioRecorderDelegate { @IBOutlet var PlayBTN: UIButton! @IBOutlet var RecordBTN: UIButton! var soundRecorder : AVAudioRecorder! var SoundPlayer : AVAudioPlayer! var fileName = "audioFile.m4a" override func viewDidLoad(

how to retrieve audio file from parse swift

孤街浪徒 提交于 2019-12-02 01:51:29
I have successfully saved an Audio file to Parse but am struggling to download it again. I can't work out what the block should be to go with getDataInBackgroundWithBlock. And how to actually save the file. Any help much appreciated! let query = PFQuery(className: "wordRecordings") query.whereKey("wordName", equalTo: "\(joinedWord)") query.findObjectsInBackgroundWithBlock { (objects:[PFObject]?, error:NSError?) -> Void in if error == nil{ for object in objects! { let audioFile = object["audioFile"] as! PFFile audioFile.getDataInBackgroundWithBlock{ (audioFile: NSData, error:NSError?) -> Void

iPhone4S with iOS6 AVAudioPlayer is working, but no sound

让人想犯罪 __ 提交于 2019-12-02 01:33:42
问题 I created a simple audio app which plays a mp3 file. It works with no problem on Simulator(iOS 5 and 6) and iPod3GS (with iOS 5.1). But when I tried on my iPhone4S(iOS 6), it seems to work but doesn't sound anything. "[audioPlayer duration]" gives me right value, and even "audioPlayerDidFinishPlaying" message of delegate shows the right finishing of play after duration time. My iPhone4S works with no problem in other sound apps like Music, Video or Podcast. Only it can't sound with my own