avaudioplayer

App crashes with AVAudioSession privateBeginInterruption

[亡魂溺海] 提交于 2019-12-01 08:08:59
I'm testing my app on device (a soundboard) and it crashes with a EXC_BAD_ACCESS , I have use Breakpoints and the error came from [AVAudioSession privateBeginInterruption] The crash happens following this pattern: The app is launched, we see the main menu A main menu button is pressed and a soundboard view is loaded (push), some buttons are pressed here and sounds are played. Return to main menu ( [self.navigationController popViewControllerAnimated:YES]; ) App enters background When app enters foreground and the menu button of the soundboard is pressed the app crashes. I have no idea what is

App crashes with AVAudioSession privateBeginInterruption

风格不统一 提交于 2019-12-01 06:32:06
问题 I'm testing my app on device (a soundboard) and it crashes with a EXC_BAD_ACCESS , I have use Breakpoints and the error came from [AVAudioSession privateBeginInterruption] The crash happens following this pattern: The app is launched, we see the main menu A main menu button is pressed and a soundboard view is loaded (push), some buttons are pressed here and sounds are played. Return to main menu ( [self.navigationController popViewControllerAnimated:YES]; ) App enters background When app

AVAudioPlayer - Drop in Framerate

﹥>﹥吖頭↗ 提交于 2019-12-01 05:38:42
问题 I have a quick question: I am loading a mp3 file into a NSData object and then I play it using the AVAudioPlayer in my game. Every second or so, the frame rate drops and you can see a stuttering on the screen. It is not a major slowdown, but clearly noticeable and disrupting to the gameplay. Not playing the music track with the AVAudioPlayer shows no slow down at all. How can I prevent this from happening? Thank you. Florian 回答1: For future reference, here is the solution: Setting the audio

AVPlayer Rotate View makes cannot tap to the screen

早过忘川 提交于 2019-12-01 05:26:23
问题 I used AVPlayer for movie player in my app. I explained the problem with diagrams. When I click Play button in movie view controller(Portrait mode),then goes to movie details view. When I tap on the screen , the navigation bar and movie player bar appear. If you tap again the screen, it will disappear. This goes well when the device is in Portrait mode. But, I changed my code to Landscape mode when I click on play button, it will automatically change to Landscape mode in movie details view.

How to play an audio if we pass NSData?

此生再无相见时 提交于 2019-12-01 05:16:46
I converted this path (file://localhost/var/mobile/Applications/8F81BA4C-7C6F-4496-BDA7-30C45478D758/Documents/sound.wav) which is an audio file i.e, recorded. I am converting this path to NSData. NSData is : Example : <00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 64617461 1cf50200 32003200 e2ffe2ff 3cff3cff 08fe08fe 44fe44fe 04fe04fe e6fde6fd 95fd95fd 96fe96fe b9feb9fe .....................................................................................................

Record and play audio simultaneously in iOS

♀尐吖头ヾ 提交于 2019-12-01 03:33:22
I am trying to play the recorded content simultaneously while recording. Currently I am using AVAudioRecorder for recording and AVAudioPlayer for playing. When I was trying to play the content simultaneously nothing is playing. Please find the pseudo code for what I am doing. If I do the same stuff after stop the recording everything works fine. AVAudioRecorder *recorder; //Initializing the recorder properly. [recorder record]; NSError *error=nil; NSUrl recordingPathUrl; //Contains the recording path. AVAudioPlayer *audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:recordingPathUrl

How do I get my sound to play when a remote notification is received?

我的未来我决定 提交于 2019-11-30 23:52:47
I'm trying to automatically play a sound file (that is not part of my app bundle and is not a notification sound) upon receiving a remote notification. I want this to happen whether the app is in the foreground or background when the notification is received. I'm using the Amazing Audio Engine as a wrapper around the core audio libraries. In my App Delegate's didReceiveRemoteNotification I create an Audio Controller and add AEAudioFilePlayer to it like so: NSURL *file = [NSURL fileURLWithPath:sourceFilePath]; AEAudioFilePlayer *notificationPlayer = [AEAudioFilePlayer audioFilePlayerWithURL

AudioToolBox leak in iOS6?

人盡茶涼 提交于 2019-11-30 22:53:36
When I use AudioToolBox for playing music, memory leaks heavily. AVAudioPlayer *newMusicPlayer = [[AVAudioPlayer alloc] initWithData:data error:&error]; I use this code to play music. In iOS5 and iOS4, it works properly. But in iOS6, if data's size is 5M, all of the 5M leaked. And I can't see leak info in Instruments. Is there anybody have the same problem? Any suggestion will be grateful. All my audio code here(Using ARC): @implementation ViewController { AVAudioPlayer *_player; } - (void)play { if (_player) { [_player stop]; _player = nil; } NSString *path = [NSHomeDirectory()

iPhone: NSData representation of Audio file for Editing

╄→гoц情女王★ 提交于 2019-11-30 22:40:57
I have been scratching my head since long now but not getting around to this. I haven't found a single example for Audio editing! I want to insert new Audio file in between somewhere in original Audio file, save it as new converted audio files. For this I have written following code. I got this idea from here . NSString *file1 = [[NSBundle mainBundle] pathForResource:@"file1" ofType:@"caf"]; // Using PCM format NSString *file2 = [[NSBundle mainBundle] pathForResource:@"file2" ofType:@"caf"]; NSData *file1Data = [[NSData alloc] initWithContentsOfFile:file1]; NSData *file2Data = [[NSData alloc]

Play background music in app?

南笙酒味 提交于 2019-11-30 18:13:21
I want the user to be able to open the app and have music start playing. I want the user to be able to go any view controller and return back to the initial one without the music stopping. I want it to loop indefinitely. I have tried to put in the viewDidLoad method of the initial view controller for it to start playing. What happens is, the user leaves the initial view controller and when they come back, the music starts playing again, overlapping the original copy. To remedy this, I put an if statement checking if the sound is already to playing to not launch another copy and the viewDidLoad