avaudioplayer

Xcode stops on prepareToPlay

落花浮王杯 提交于 2019-12-03 07:48:30
问题 Using AVAudioPlayer to add sound to a working application, it stops / hangs on prepareToPlay. Note it also stops / hangs on play. Hitting "Continue program execution" several times makes the application resume. This problem only occurs when running the program in the simulator. Using Xcode 4.6 Code Snippets: ViewController.h #import <UIKit/UIKit.h> #import <AVFoundation/AVFoundation.h> @interface ViewController : UIViewController <AVAudioPlayerDelegate> @end ViewController.m #import

What are the system sound ids for the new keyboard clicks in iOS 10?

筅森魡賤 提交于 2019-12-03 06:59:09
General I'm developing a third party keyboard and am currently trying to mimic the new keyboard clicks that Apple introduced in iOS 10b4. Current Situation The regular click sound can be played using AudioServicesPlaySystemSound(1104) but I can't seem to find the System Sound IDs for the two new other sounds. I've found the location of their .caf equivalents but those are way too loud to use, even after adjusting their volume using AVAudioPlayer . Question Is it possible to obtain the system sound ids of the new click sounds? Extra If anyone wants the .caf file paths for personal use, here

Audio playing while app in background iOS

牧云@^-^@ 提交于 2019-12-03 06:55:47
I have an app mostly based around Core Bluetooth. When something specific happens, the app is woken up using Core Bluetooth background modes and it fires off an alarm, however I can't get the alarm working when the app is not in the foreground. I have an Alarm Singleton class which initialises AVAudioPlayer like this: NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:soundName ofType:@"caf"]]; self.player = [[AVAudioPlayer alloc] initWithContentsOfURL:url error:nil]; [[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback error:nil]; [

Swift 3 sound play

瘦欲@ 提交于 2019-12-03 05:54:48
问题 Ok I have looked into this and have tried many different ways to play a sound when a button is clicked. How would I play a sound when a button is clicked in swift 3? I have my sound in a folder named Sounds and the name is ClickSound.mp3 回答1: User below this function //MARK:- PLAY SOUND func playSound() { let url = Bundle.main.url(forResource: "ClickSound", withExtension: "mp3")! do { player = try AVAudioPlayer(contentsOf: url) guard let player = player else { return } player.prepareToPlay()

AVAudioPlayer stop a sound and play it from the beginning

China☆狼群 提交于 2019-12-03 05:29:07
I used the AVAudioPlayer to play a 10 sec wav file and it works fine. Now I what to stop the wav at the 4th sec and then play it again from the very 1st sec. Here is the code I tried: NSString *ahhhPath = [[NSBundle mainBundle] pathForResource:@"Ahhh" ofType:@"wav"]; AVAudioPlayer *ahhhhhSound =[[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:ahhhPath] error:NULL]; [ahhhhhSound stop]; [ahhhhhSound play]; What I get is, the wav stops at the 4th sec but when I run the [XXX play] again, the wav continues to play the 5th sec instead of playing from the beginning. How could I get

Using Apple's new AudioEngine to change Pitch of AudioPlayer sound

大兔子大兔子 提交于 2019-12-03 05:13:30
问题 I am currently trying to get Apple's new audio engine working with my current audio setup. Specifically, I am trying to change the pitch with Audio Engine, which apparently is possible according to this post. I have also looked into other pitch changing solutions including Dirac and ObjectAL, but unfortunately both seem to be pretty messed up in terms of working with Swift, which I am using. My question is how do I change the pitch of an audio file using Apple's new audio engine. I am able to

AVAudioPlayer via Speakers

倖福魔咒の 提交于 2019-12-03 04:42:16
I got the following code: - (id)init { if (self = [super init]) { UInt32 sessionCategory = kAudioSessionCategory_MediaPlayback; AudioSessionSetProperty(kAudioSessionProperty_AudioCategory, sizeof(sessionCategory), &sessionCategory); UInt32 audioRouteOverride = kAudioSessionOverrideAudioRoute_Speaker; AudioSessionSetProperty (kAudioSessionProperty_OverrideAudioRoute,sizeof (audioRouteOverride),&audioRouteOverride); [[AVAudioSession sharedInstance] setDelegate:self]; [[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayAndRecord error:nil]; [[AVAudioSession sharedInstance]

iOS 7 : simple audio controls with AVAudioPlayer?

别等时光非礼了梦想. 提交于 2019-12-03 03:57:10
问题 I just begun to code iOS apps with xCode and it's not very easy nor intuitive to find how things work. I'm very new into this and my app goes on very slowly ^^. Anyway, I'm now trying things on iOS7, at least. I managed to create dynamic tables with customs cells and dynamic height but now I don't find any solution to my problem... Maybe I didn't search at the right place... anyway. I have an audio playing, thanks to these lines: NSString *path = [[NSBundle mainBundle] pathForResource:@"song"

AVAudioRecorder - Proper MPEG4 AAC Recording Settings

江枫思渺然 提交于 2019-12-03 03:15:00
I've got a live app with an estimated 15% of users reporting that the record feature is not working. This isn't happening on our test devices, but the reports show that the problem is that prepareToRecord is returning NO. I've had trouble finding sample settings for AAC format. Are any of my settings off? App requires iOS5 and uses ARC. AVAudioSession *audioSession = [AVAudioSession sharedInstance]; [audioSession setCategory:AVAudioSessionCategoryRecord error:nil]; NSDictionary *recordSettings = [NSDictionary dictionaryWithObjectsAndKeys: [NSNumber numberWithInt:kAudioFormatMPEG4AAC],

How to customize MPVolumeView?

橙三吉。 提交于 2019-12-03 02:48:04
问题 I have tried many methods to implement a regular UISlider and control the device volume, but it's all Native-C functions which results in many untraceable bugs. I tried the MPVolumeView it works like charm, it even controls the device volume even after you close the app, just like the iPod app. My question is, is there anyway to customize the MPVolumeView with specific colors and images, just like UISlider ? NOTE: I want a legal method without using private undocumented APIs. UPDATE As per