avaudioplayer

UIImagePickerController AVAudioPlayer

末鹿安然 提交于 2019-12-08 20:33:28
问题 When I open a UIImagePickerController , I can display the device's camera input stream. But when I play an AVAudioPlayer with [player play] then the camera stops working. How can I deal with that? 回答1: you can't because UIIMagePickerController is controlling the audio, you will need to use low level AVFoundation in order to do that. checkout AVCam sample code how to record a movie and add the view as subview , that way you will stay in control of the audio and will be able to play audio. 来源:

Sounds in UILocalNotification louder than AVAudioPlayer at max volume

人走茶凉 提交于 2019-12-08 14:32:22
For purposes of this question, imagine my app plays an audio clip every 10 seconds. This audio plays/mixes with the iPod music player on the device (using ducking), using AVAudioPlayer. When the app is sent to the background, I schedule UILocalNotification objects with the audio file referenced (and no text), so the sounds continue to play at 10 second intervals. What is bothering me is that the volume of the audio clips played as part of a notification on iOS 6 seem to be twice as loud as the audio when I play in my app (and I'm setting the volume to 1.0f, which the docs say is max). So every

AudioQueueStart posting message to kill mediaserverd

*爱你&永不变心* 提交于 2019-12-08 14:08:56
问题 I have a piano application. It's working fine, with a little error. If I play several keys at the same time very fast, the sounds disappears for a couple of seconds, and receive the following message in the console AudioQueueStart posting message to kill mediaserverd Here is the relevant code: -(IBAction)playNoteFromKeyTouch:(id) sender{ [NSThread detachNewThreadSelector:@selector(playNote:) toTarget:self withObject:[NSString stringWithFormat:@"Piano.mf.%@",[sender currentTitle]]]; } -(void

How to play 2 sounds simultaneously

这一生的挚爱 提交于 2019-12-08 12:54:40
问题 I have to play 2 sounds in my app...one for background and one for when user clicks any button.....Not i have only one sound for background and too many sounds for that button click.....all sounds are in mp3 format.... I am using AVAudioPlayer to play these sounds... My questions are 1- Can i play these 2 mp3 sounds at same time Or should i convert that background sound to any other format.... 2- I am using AVAudioPlayer to play these sounds.....so can i use 2 instances of AVAudioPlayer in

using slider change the volume in AVAudioPlayer in iphone sdk

十年热恋 提交于 2019-12-08 11:42:20
问题 I am using this code NSURL *url = [NSURL fileURLWithPath:[NSString stringWithFormat:@"%@/audiofile.mp3", [[NSBundle mainBundle] resourcePath]]]; NSError *error; player = [[AVAudioPlayer alloc] initWithContentsOfURL:url error:&error]; player.numberOfLoops = -1; if (player == nil) NSLog(@"%@",[error description]); else [player play]; but i want to change the volume so how can i get the volume detail? 回答1: Set up your UISlider. Register it to receive the ValueChanged events in IB or

How to unduck AVAudioSession

最后都变了- 提交于 2019-12-08 09:48:23
问题 kAudioSessionProperty_OtherMixableAudioShouldDuck is used For audio session categories that allow mixing of iPod audio with application audio, specifies whether iPod audio should be reduced in level when your application produces sound. This property has a value of FALSE (0) by default. Set it to a nonzero value to turn on ducking. How can we unduck this? Is there any property? Thanks in advance, Chandra. 回答1: I had this same question and had trouble getting it to work consistently. I spent a

unexpectedly found nil while unwrapping an Optional value with AVAudioPlayer

耗尽温柔 提交于 2019-12-08 09:38:16
问题 So this code runs fine on the iOS Simulators, but not on my iPad Mini var sound = NSURL(fileURLWithPath:"/Users/Dan/Documents/XCode Code/Colors- Tabbed?/Colors- Tabbed?/Sweg.aiff") var audioPlayer = AVAudioPlayer() audioPlayer = AVAudioPlayer(contentsOfURL: sound, error: &error) var error: NSError? I get the error "unexpectedly found nil while unwrapping an Optional value" on the last line. 回答1: It looks like AVAudioPlayer hasn't been audited yet. It returns an implicitly unwrapped optional,

Record And Play Voice in Separate Class (Swift3)

纵饮孤独 提交于 2019-12-08 08:56:11
问题 I used many codes that was for record an play the voice, but most of them are not in swift3 and they don't work in my app. This code works, but I want to create a separate class from the viewcontroller that do recording an playing voices. Also the mentioned github code is complex an I'm searching for a simplified code. Update: After recording, when I check existence of the recorded file, the file doesn't exist, and it raises EXC_BAD_ACCESS error on appDelegate. What's wrong? Any suggestions

AVAudioPlayer not releasing memory

流过昼夜 提交于 2019-12-08 07:31:07
问题 I initialize an ivar AVAudioPlayer variable, play and the try to release its memory. After the release line, it doesn't set to 0x0. After the nil line it doesn't change to 0x0. Does AVAudioPlayer require something special to release its memory? audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath: [[NSBundle mainBundle] pathForResource: @"mysound" ofType: @"aif" inDirectory:@"/"]] error: &err]; audioPlayer.numberOfLoops = 0; audioPlayer.volume = .5; [audioPlayer

Playing sequence of sounds in background with AVAudioPlayer

血红的双手。 提交于 2019-12-08 05:34:21
问题 I want to play sequence of sounds with AVAudioPlayer . All are ok in foreground, but in background I have issues. After scheduling next sound it plays in background, but initialisation of sound after next fails. How to resolve this issue? In fact, I have sequence of sounds and sequence of starting moments. When user touch button application starts play sounds. I use the following code: - (void)soundScheduleNext { NSURL * url = ...; // get url of next sound file if (soundPlayer == nil)