avaudioplayer

memory leak in AudioToolbox library AVAudioPlayer

孤人 提交于 2019-12-01 12:15:57
Is there a memory lead issue with the AVAudioPlayer object? I'm getting a memory leak when using AVAudioPlayer in the simulator. It doesn't matter how I created the AVAudioPlayer. I've used initWithContentsOfURL and InitWithData . Below is a snippet of the code. Full project @ Github https://github.com/docchang/MemoryLeakAVAudioPlayer NSError *error; NSURL *playerURL = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"Bell" ofType:@"m4a"]]; self.playerWithURL = [[AVAudioPlayer alloc] initWithContentsOfURL:playerURL error:&error]; if (!playerWithURL) { NSLog(@"no %@.%@: %@",@

memory leak in AudioToolbox library AVAudioPlayer

浪尽此生 提交于 2019-12-01 11:30:34
问题 Is there a memory lead issue with the AVAudioPlayer object? I'm getting a memory leak when using AVAudioPlayer in the simulator. It doesn't matter how I created the AVAudioPlayer. I've used initWithContentsOfURL and InitWithData . Below is a snippet of the code. Full project @ Github https://github.com/docchang/MemoryLeakAVAudioPlayer NSError *error; NSURL *playerURL = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"Bell" ofType:@"m4a"]]; self.playerWithURL = [[AVAudioPlayer

AVAudioPlayer - must you create a property for it to work? (Xcode)

断了今生、忘了曾经 提交于 2019-12-01 11:29:06
This is the code I'm using now, and it's not working (nothing happens when I press the button that calls this method). Previously, I had a property for audioPlayer and it worked (all the audioPlayers below were self.audioPlayer obviously). The problem was that when I tried to play the sound twice, it would end the first sound playing. This is no good because I'm making a soundboard and want sounds to be able to overlap. I thought I could just make audioPlayer a local variable instead of a property and all would be ok but now the sound doesn't work at all and I can't figure out why. In all

Unable to Implement Forward Action in AVAudioplayer

主宰稳场 提交于 2019-12-01 10:46:09
I am using AVAudioplayer to play some audio files. I have some controls like forward and rewind. Rewind is working properly but forward is not. - (void)rewind { AVAudioPlayer *player = _rewTimer.userInfo; player.currentTime-= SKIP_TIME; [_rewTimer invalidate]; _rewTimer=nil; [self updateCurrentTime]; } - (void)ffwd { AVAudioPlayer *player = _ffwTimer.userInfo; player.currentTime-= SKIP_TIME; [player setCurrentTime:cTime]; [_ffwTimer invalidate]; _ffwTimer=nil; [self updateCurrentTime]; } As soon as I click on forward button, the audio file just begins playing from the start. I have followed

How to play the same sound overlapping with AVAudioPlayer?

我与影子孤独终老i 提交于 2019-12-01 10:41:55
This code plays the sound when the button is tapped but cancels the previous if it is pressed again. I do not want this to happen I want the same sound to overlap when repeatedly pressed. I believe it might be due to using the same AVAudioPlayer as I have looked on the internet but I am new to swift and want to know how to create a new AVAudioPlayer everytime the method runs so the sounds overlap. func playSound(sound:String){ // Set the sound file name & extension let soundPath = NSURL(fileURLWithPath:NSBundle.mainBundle().pathForResource(sound, ofType: "mp3")!) do { //Preperation try

About AMR audio file playing issue on different devices

╄→尐↘猪︶ㄣ 提交于 2019-12-01 10:35:21
问题 I have got a quite strange problem here. I am developing an IM software and need to play audio files recorded by another client on Android. The same audio file I've got can be played with AVAudioPlayer on 3GS(IOS 4.2.1) device and simulator 4.2. But when I tried by play it on iPhone4(iOS 4.3.3), the function "play" always return NO. I also tried with two iPhone devices, the audio files recorded by iPhone client can be played on both 3GS and iPhone4. So I asked the Android developers about the

Audio playback does not start

元气小坏坏 提交于 2019-12-01 10:28:57
NSError *err; // Initialize audio player audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:url error:&err]; audioPlayer.delegate = self; [audioPlayer play]; With the code above, I'm trying to initialize playback of a .mp3 file, however the playback does not start at all. There is no sound. What am I doing wrong? I have inspected 'err' and there is nothing there. Edit: After adding AVAudioSession, I'm getting the following error from AVAudioPlayer The operation couldn’t be completed. (OSStatus error -43.) Apparently AVAudioPlayer does not support streaming via. HTTP as I was trying to

Audio playback does not start

∥☆過路亽.° 提交于 2019-12-01 09:27:51
问题 NSError *err; // Initialize audio player audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:url error:&err]; audioPlayer.delegate = self; [audioPlayer play]; With the code above, I'm trying to initialize playback of a .mp3 file, however the playback does not start at all. There is no sound. What am I doing wrong? I have inspected 'err' and there is nothing there. Edit: After adding AVAudioSession, I'm getting the following error from AVAudioPlayer The operation couldn’t be completed.

AVAudioPlayer is always nill and its isPlaying property is always false. The files are mixed while playing

狂风中的少年 提交于 2019-12-01 08:42:20
问题 I've been pulling out my hair past three days to fix this problem. I've checked lots of sample codes, read lots of tutorials, and googled and checked lots and lots of questions and answers on stackoverflow, but I still cannot fix the problem. There are several similar questions like this or this but they don't have any solutions either. So a little bit about my project: I have a NIKMasterViewController and a NIKDetailViewController . In the first one I have a list of audio files in a table

AVAudioPlayer - Drop in Framerate

廉价感情. 提交于 2019-12-01 08:15:02
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 For future reference, here is the solution: Setting the audio session category to kAudioSessionCategory_AmbientSound (to allow for iPod music to play simultaneously)