Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Play back the recorded audio? #1

Open
KevinWSteele opened this issue Apr 27, 2018 · 2 comments
Open

Play back the recorded audio? #1

KevinWSteele opened this issue Apr 27, 2018 · 2 comments

Comments

@KevinWSteele
Copy link

KevinWSteele commented Apr 27, 2018

Hi! Thanks so much for the example, tomisacat. However, I'm trying to play back the recorded sound from using this app. When I write code to search for the audio file that was used to record the sound, it looks like the audio file does not exist - even after recording.

Any idea how to access the recorded file?

@tomisacat
Copy link
Owner

Hi! Check the location to find whether the file exist. The file located in app sandbox like /path/to/the/app/tmp/audio.wav

@KevinWSteele
Copy link
Author

KevinWSteele commented May 22, 2018

Ok, thanks - apparently I was getting slightly different files, partly based on whether I did:
let myUrl = URL(fileURLWithPath: path)
or
let myURL = URL(string: path)!;

As long as I'm consistent and keep making sure the program is using the right file, the file does exist after recording.

However, I still can't get the recorded file to play back. I let the recording go for a few seconds and I can see that the audioQueueInputCallback method is getting called a lot. Then, I stop the recording.

However, when I try to play back the recorded file with AudioQueuePlayer ( after recording and passing the correct file into the player), there is just no sound. It looks like like audioQueueOutputCallback gets called quickly three times and then there is an error message about finding nil while unwrapping an Optional value on this line:
var status = AudioFileReadPacketData(info.pointee.mAudioFile!,

My function, which I call from the view controller after recording the file is:

func playSound() {
        let path = (NSTemporaryDirectory() as NSString).appendingPathComponent("audio.wav")
        print(path)
        let myURL = URL(string: path)!
        
        let myPlayer = AudioQueuePlayer(url: myURL)
        myPlayer?.play();
   }

Repository owner deleted a comment from devarya Feb 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants