avaudioplayer

Swift 2: AVAudioPlayers to play multiple sounds at once

谁说胖子不能爱 提交于 2020-01-01 12:15:09
问题 So hey I've been searching around, trying to find a way to solve this, but there's basically no solutions to this yet. I desperately need a way to instantiate and play a sound whenever I want, without it cutting out any other sounds. I know that AVAudioPlayer can only play one sound at a time, so I'm trying to figure out how to make a dynamic array of AVAudioPlayers that I can add to any time I need to play a sound. My current code, that I got from a different answer on this site, is this:

AVAudioPlayer Play audio on music plays on the sound box of phone calls

一笑奈何 提交于 2019-12-31 07:32:48
问题 I have a simple code using AVAudioPlayer, to play a .caf audio: AppDelegate.h AVAudioPlayer *_audioPlayer; AppDelegate.m - (void)playAudio{ NSArray *dirPaths; NSString *docsDir; dirPaths = NSSearchPathForDirectoriesInDomains( NSDocumentDirectory, NSUserDomainMask, YES); docsDir = dirPaths[0]; NSString *soundFilePath = [docsDir stringByAppendingPathComponent:audiosrc]; NSURL *soundFileURL = [NSURL fileURLWithPath:soundFilePath]; _audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL

iOS Sound not playing in Swift

走远了吗. 提交于 2019-12-31 04:51:29
问题 I'm building a tableview in which each cell represents a sound that is played when the user taps that particular cell. In objective-C it worked fine, but now that Apple released Swift I decided to move over instantly, but for some reason the sound does not play. My code when the user taps the cell: func tableView(tableView: UITableView!, didSelectRowAtIndexPath indexPath: NSIndexPath!) { var currentItem = self.items[indexPath.row] var audioPath = NSString(string: NSBundle.mainBundle()

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

爷,独闯天下 提交于 2019-12-30 11:21:38
问题 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

“Cannot find executable for CFBundle/CFPlugIn” error

徘徊边缘 提交于 2019-12-30 06:08:17
问题 Cannot find executable for CFBundle/CFPlugIn 0x432bfa0 (not loaded) Cannot find function pointer NewPlugIn for factory C5A4CE5B-0BB8-11D8-9D75-0003939615B6 in CFBundle/CFPlugIn 0x432bfa0 (not loaded) That's the error I get when I try to run this code: NSString *path = [[NSBundle mainBundle] pathForResource:[arraySubFarts objectAtIndex:indexPath.row] ofType:@"mp3"]; NSURL *file = [[NSURL alloc] initFileURLWithPath:path]; AVAudioPlayer *player = [[AVAudioPlayer alloc] initWithContentsOfURL:file

AVAudioPlayer is not playing in Background when iPhone is locked

若如初见. 提交于 2019-12-30 05:22:10
问题 Actually i fetching the songs from Documents Directory . I referred this Link:- http://www.raywenderlich.com/29948/backgrounding-for-ios , But it will play the songs from bundle only. but i want to play the songs from documents Directory. I tried Background modes in the Plist Application Does not in background = No in Plist In Appdelegate didFinishLaunchingWithOptions:- NSError *setCategoryErr = nil; NSError *activationErr = nil; [[AVAudioSession sharedInstance] setCategory:

Playing video with AVPlayer and recording sound with AVAudioRecorder simultaneously

扶醉桌前 提交于 2019-12-30 00:39:37
问题 I was googling this problem for many days but I didn't find a solution for my simple problem. I'm trying to play a video while recording sound. Recording sound works fine without the video. And the video works fine without the recording. As soon as I put both together, the recording throws values which do not react on sound and the video is not playing anymore. By the way this happens only on my device (iPhone 4 / iOS5). In the simulator everything works fine. This is a reduced version of my

iPhone ios4 - Replacing iPod dock icon whilst playing background audio stream

给你一囗甜甜゛ 提交于 2019-12-29 14:56:55
问题 I've figured out how I can get audio playing in the background on ios4, however I've noticed that some apps also replace the iPod dock icon with their own app icon. (Last.fm & Spotify for example). They are also able to use the dock media controls to pause and resume their streams. Does anyone know how to do this? Thanks 回答1: It's easy you have to respond to the Remote Control Events. This also lets you control your app with the headset. In lets say viewDidLoad call: [[UIApplication

AVAssetReader kills playback (in AVAudioPlayer)

柔情痞子 提交于 2019-12-29 06:24:25
问题 I am using AVAssetReader to read ipod library asset audio data and render a waveform image. this takes place using code I have described in my answer to this question this sometimes takes place while audio is being played by an instance of AVAudioPlayer. regardless of wether the audio being played is the same asset that is being read, the moment i hit [reader startReading]; the audio being played "fades out". (as if the AVAudioPlayer has somehow been told to stop playback). This is odd, as I

Objective-C, Need help creating an AVAudioPlayer singleton

六眼飞鱼酱① 提交于 2019-12-28 12:49:34
问题 I'm working on a soundboard app, that has several pages of buttons to play sound effects with a stop button on every page should the user wish to manually interrupt the clip. I'm using avaudioplayer in each view to play the sound upon pressing the button for that clip. It works fine until the view is changed. If a user jumps to a new page the sound keeps playing and the stop button stops working even if they return to the original view. Pressing a sound button no longer interrupts the running