avaudioplayer

Objective-C, Need help creating an AVAudioPlayer singleton

别等时光非礼了梦想. 提交于 2019-12-28 12:49:32
问题 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

AVAudioSession .defaultToSpeaker changes mic input

徘徊边缘 提交于 2019-12-28 06:33:08
问题 I have an app taps the microphone and also play sounds depending on mic input(don't have to be simultaneously tho) This code below works. But one problem is the output plays on the small top speaker and not the bottom real loud speakers. I could solve this problem strangely by putting the 3 lines below just before the player starts , Then I can hear the sound on speakers. But then the microphone stops listening ! Even after the player stops playing. Basically mic does not like when it is

Create a UISlider progress bar and timer (like iPod player) within app

余生长醉 提交于 2019-12-25 18:34:02
问题 I've searched Google and StackOverflow for two days and have yet to find a clear, concise answer. My goal is to create a slider/progress bar that allows the user to scrub to a different part of the song, with two labels on either side, one showing the elapsed time and the other, the time left on the song. I'm using DiracAudioPlayer, which also incorporates AVAudioPlayer functionality. Any help or direction to a tutorial is greatly appreciated. 回答1: Not sure if this is an issue with doing the

Swift - Have an audio repeat, but it plays in intervals?

我只是一个虾纸丫 提交于 2019-12-25 12:46:17
问题 In Swift , I play a song, it plays at the viewDidLoad. It is 16 seconds long, and it plays all 16 seconds. I want it to repeat forever. I made an NSTimer where every 16 seconds, it plays the song. But, it plays 16 seconds when the app loads, stops for 16 seconds, plays, etc. The line println("just doing some dandy debugging here.") does print every 16 seconds. How is this fixed? CODE: //these var's are created on the top of the file. var soundTimer: NSTimer = NSTimer() var audioPlayer2 =

How do I use the Swift sampler to play a tone then pause before playing the next?

烂漫一生 提交于 2019-12-25 07:25:43
问题 I have code to take a sequence of letters in a string and interpret them as notes. The code will then play the notes. The problem is that they all play at the same time. How do I play them each as a quarter note, essentially to play a note, wait for it to end, and then play the next note? @IBAction func playButton(sender: AnyObject) { fractalEngine.output = "adgadefe" var notes = Array(fractalEngine.output.characters) var counter = 0 while counter < notes.count { var note = notes[counter] if

AVAudioPlayer hiccups the app sometimes

五迷三道 提交于 2019-12-25 06:36:14
问题 I am working on a simple game and after every screen touch, an animation is happening on a small UIImageView and this happen very well and the app is running smoothly with CADisplayLink as the timer. I added an mp3 file to play after every touch with 1 second lengh as AVAudioPlayer imagine a sound like : Bip So the first time that I touch the screen first hiccup happens an the app freeze for less than a second that I can say it is ok coz it's the first time that the sound allocate memory. The

Adding silence to the end of a recorded audio file

喜欢而已 提交于 2019-12-25 04:59:07
问题 Currently I'm allowing user to record their own voice for a duration no longer than 30 seconds. Once they are finished recording their audio, I grab the duration of their audio. I run this quick math (SixtySeconds-TheirAudioDuraion) = TimeNeededToFill. Basically I need to end up with a precise 1-minute track in the end. Some portion of which is actual Audio, the remainder is Silent Audio. Im currently using AVAudioPlayer to do all of my audio recording. Is there a programatic way to

Generating a DTMF tone doesn't work - application crashes!

坚强是说给别人听的谎言 提交于 2019-12-25 01:32:38
问题 I want to generate a custom DTMF tone and play it on the iPhone. In order to do so, I have created and allocated a memory buffer with a custom tone (ptr). Now I want to create a NSData object, initialized with the memory buffer, and pass it to AVAudioPlayer using initWithData:error: instance method. I wrote the following code, but when I run my application, it crashes. #import "AudioPlayerViewController.h" #include <stdlib.h> #include <math.h> #define SIZE 10 #define LENGTH 65535 const int

AVAudioPlayer causes game lag

故事扮演 提交于 2019-12-25 01:25:49
问题 I have a simple game where you are in a rocket and you avoid planets that come down the screen. When I play a short sub second long sound my game jitters and lags whilst it plays it and then returns to normal. Does any one know why this might be? 回答1: AVAudioPlayer, while the sound plays on a different thread, will cause a long delay initializing itself on its current thread. My solution was to use AVAudioPlayer only for music, since the high level API made it useful for that, but even then

Is it posible to play iPod songs using AVAudioPlayer?

假装没事ソ 提交于 2019-12-24 19:03:22
问题 I have a question that, Is it possible to get and play the iPod library songs / playlist using AVAudioPlayer instead of using MPMusicPlayer? Thanks in advance, Chandra. 回答1: One way i tried with is just copy the song from iPod library to your app then you can play. When you close then you can delete also those songs. But makes your app heavy in terms of size. See my post. Another way i found is using AVPlayer of AVFoundation framework. This supports iPod library. For reference of AVPlayer you