avaudioplayer

Audio file doesn't play in iPhone 5

人走茶凉 提交于 2019-12-12 17:28:45
问题 I use a code for playing a .caf audio file, the same code works good in an iPhone 4s and an iPad 2 but doesn't play at all in a iPhone 5... this is the code: -(IBAction)checkSound:(id)sender { NSURL *url = [NSURL fileURLWithPath:[NSString stringWithFormat:@"%@/Lunatic.caf", [[NSBundle mainBundle] resourcePath]]]; NSLog(@"%@",url); NSError *error; self.audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:url error:&error]; self.audioPlayer.numberOfLoops = 0; self.audioPlayer.volume = 1;

Swift: SwiftySound Initialization Error if more than 49 sound files loaded

自作多情 提交于 2019-12-12 17:28:12
问题 I am trying to create a simple Soundboard in Swift with a Collection View, each button representing a sound that can be played. The structure is as follows (I know, it is probably not the smartest way to do it, but it worked earlier until I added some more sounds): I have a SoundFiles.swift with the SoundFiles class, which I declared static let shared = SoundFiles() It contains two arrays let soundfiles: [String] = ["example_bla"] let soundnames: [String] = ["example bla"] as well as var

Play audio with AVAudioPlayer inside NSObject class

青春壹個敷衍的年華 提交于 2019-12-12 16:28:25
问题 To organize things , I decided to create a class called SoundPlayer where will run all audio files from my app. (This would avoid having many duplicate codes) SoundPlayer.h #import <Foundation/Foundation.h> #import <AVFoundation/AVFoundation.h> #include <AudioToolbox/AudioToolbox.h> @interface SoundPlayer : NSObject <AVAudioPlayerDelegate> @property (strong,nonatomic) AVAudioPlayer *backgroundMusicPlayer; -(void)PlaySound:(NSString*)name extension:(NSString*)ext loops:(int)val; @end

iOS7 robotic/garbled in speaker mode on iPhone5s

限于喜欢 提交于 2019-12-12 15:26:07
问题 We have a VOIP application, that records and plays audio. As such, we are using PlayAndRecord (kAudioSessionCategory_PlayAndRecord) audio session category. So far, we have used it successfully with iPhone 4/4s/5 with both iOS 6 and iOS 7 where call audio and tones played clearly and were audible. However, with iPhone 5s, we observed that both the call audio and tones sound robotic/garbled in speaker mode. When using earpiece/bluetooth/headset, sound is clear and audible. iOS Version used with

Detecting Current Item in AVQueuePlayer and Knowing when it Changes?

岁酱吖の 提交于 2019-12-12 13:50:10
问题 I currently have an AVQueuePlayer playing a few .aif files in sequence. As it goes through each audio I want to perform an action related to that specific sound (for example changing an imageview's uiimage). My problem is setting the NSNotification correctly. I've set it to notify me when the queue finished with the last object, but I'm having trouble receiving an a notification for each current item. Here is what I have: //Setting Up My Queue List yellowVoice = [[AVPlayerItem alloc]

Swift - Stop avaudioplayer

情到浓时终转凉″ 提交于 2019-12-12 10:14:00
问题 I am trying to build a soundboard into an app and have figured out an efficient way of using tags to control playing the sounds. However I am now trying to integrate a pause button that can be used with the .stop() method on the AVAudioPlayer however I get an error with my current code: EXC_BAD_ACCESS This is what I am using at the moment, any ideas? import UIKit import AVFoundation let soundFilenames = ["sound","sound2","sound3"] var audioPlayers = [AVAudioPlayer]() class

Playing multiple sounds at once?

这一生的挚爱 提交于 2019-12-12 09:01:49
问题 I have 6 sounds on one view. However I want it so that I can play more than one at once, So you tap sound 1 (sound 1 is playing) then sound 2 plays. while sound 1 is still playing. But at the moment I press sound 1 (sound 1 plays), press sound 2 (sound 2 plays, but sound 1 stops) Here is the code for the audio part. - (IBAction)oneSound:(id)sender; { NSString *path = [[NSBundle mainBundle] pathForResource:@"1" ofType:@"wav"]; if (theAudio) [theAudio release]; theAudio = [[AVAudioPlayer alloc]

Add sound to play at time from NSDatePicker [duplicate]

て烟熏妆下的殇ゞ 提交于 2019-12-12 06:59:54
问题 This question already has answers here : How to get audio to play at time from NSDatePicker? (2 answers) Closed 4 years ago . I'm creating a project which requires the user to be able to set a sound to play at a specific time and I'm currently doing that with local notification. I would like to change that to use AVAudioPlayer , and I was wondering, what would be the best approach? The objects I've got at the moment are a NSDatePicker and a stringFromDate string. My aim is to create an alarm

AVAudioPlayer UIButton - second touch stop current audio play

99封情书 提交于 2019-12-12 06:58:44
问题 I have a UIButton that when touched plays an audio file. At the moment touching the button twice in succession plays the audio file twice instead of stopping it. I'm looking to have the second click stop the audio file and not play a second instance. any suggestions would be very much appreciated. thanks -(IBAction) buttonNoisePlay { NSString *pathsoundFile = [[NSBundle mainBundle] pathForResource:@"noise" ofType:@"mp4"]; sound = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL

Mute and UnMute in Objective-C on iOS

笑着哭i 提交于 2019-12-12 04:43:16
问题 Hi guys ive been trying to find a way to mute and unmute (that is play audio) via Objective-C in-code, regardless of whether the app is in mute mode or not (physical mute toggled) I see Instagram does that, where you can press the mute icon even if your phone is mute, and it will play video audio. 回答1: You want to look at audio session categories With this code you can play audio when the Ring/Silent switch to silent. NSError *setCategoryError = nil; BOOL success = [[AVAudioSession