avaudioplayer

save the audio file in the background

做~自己de王妃 提交于 2019-12-01 23:01:59
I have an app that changes the pitch of the audio when the pitch button is selected, now i am using installTapOnBus to save the file but this method gets invocated after i press the pitch button therefore only part of the audio is saved, i want to save the whole audio no matter when the pitch button is selected, is there any way This method is used to play the audio -(void)playAudio { NSError *err = nil; audioEngine = [[AVAudioEngine alloc] init]; AudioFileplayer = [[AVAudioPlayerNode alloc] init]; pitch = [[AVAudioUnitTimePitch alloc] init]; reverb = [[AVAudioUnitReverb alloc] init];

Play sound continuously onTouch()

旧城冷巷雨未停 提交于 2019-12-01 21:39:19
I want to play a gun shot sound continuously by onTouch. I am doing this for automatic gun sounds. So i have problem with there is delay in sound looping. which does not give real automatic gun sound effect. My main point is there should no delay when sound is playing again and again. My code is. public boolean onTouch(View v, MotionEvent event) { // TODO Auto-generated method stub if (event.getAction() == MotionEvent.ACTION_DOWN) { mediaPlayer = MediaPlayer.create(RipleFire.this, sounds[position]); // if (mediaPlayer != null && mediaPlayer.isPlaying()) { // mediaPlayer.stop(); // } try {

Looping Audio in Xcode

点点圈 提交于 2019-12-01 20:40:29
Im playing a sound in my app that I would like to loop. My research into this hasnt quite sorted my issue. my code .m CFBundleRef mainBundle = CFBundleGetMainBundle(); CFURLRef soundFileURLRef; soundFileURLRef = CFBundleCopyResourceURL(mainBundle, (CFStringRef) @"ar4", CFSTR ("wav"), NULL); UInt32 soundID; AudioServicesCreateSystemSoundID (soundFileURLRef, &soundID); AudioServicesPlaySystemSound (soundID); I think I need to put something like this in numberOfLoops = -1; But unsure how to implement in my code as I get undeclared error for numberOfLoops. Some advice would be very much

AVPlayer Volume Control

我们两清 提交于 2019-12-01 16:50:38
I want to create a button that mutes the audio from an AVPlayer. Why can´t I use .volume with AVPlayer, only with AVAudioPlayer? Is there another way to change the volume? e.g music.volume = 0.0; Thanks for your answers. Starting in iOS 7, simply call: myAvPlayer.volume = 0; Otherwise, you'll have to use the annoying setAudioMix solution. I'm detecting support for this in my app as follows: if ([mPlayer respondsToSelector:@selector(setVolume:)]) { mPlayer.volume = 0.0; } else { NSArray *audioTracks = mPlayerItem.asset.tracks; // Mute all the audio tracks NSMutableArray *allAudioParams =

OSStatus error 2003334207 when using AVAudioPlayer

こ雲淡風輕ζ 提交于 2019-12-01 15:20:46
问题 I am trying to play an MP3 file (works when played via VLC/iTunes) when a button is pressed. Here is my code: var audioPlayer: AVAudioPlayer! @IBAction func playEpisode(sender: AnyObject) { println("now playing") let indexPath = NSIndexPath(forRow: sender.tag, inSection: 0) let data: CDEpisode = fetchedResultsController.objectAtIndexPath(indexPath!) as! CDEpisode var err: NSError? let url = NSURL(string: data.localPath) println("The url is \(url)") audioPlayer = AVAudioPlayer(contentsOfURL:

AVAudioPlayer doesn't start playing in background

房东的猫 提交于 2019-12-01 14:24:40
I am using AVAudioPlayer and NSFileHandle to do audio streaming. The basic idea is that I save the streaming audio data to the device with file system and then use AVAudioPlayer to playback the file just saved. AVAudioPlayer can still play that file even the streaming is in progress. I have a UIButton to start streaming/downloading. When the downloaded data is accumulated to a specific amount of Bytes, AVAudioPlayer will play (the "play" method of AVAudioPlayer is triggered) automatically. My question is: I tap the button to start streaming/downloading, then press iPhone's home button very

Fetch All Audio & Video files in ios

一个人想着一个人 提交于 2019-12-01 13:44:01
I want to fetch all audio files and also video files from device into the app. so that i can listed their names into the different UITableViews. Is there any way in ios, so that i can fetch them. Vineet Singh Have a look at this ,specially on the section " Getting Media Items Programmatically ". If the media item picker doesn’t provide the control you want, you can use the database access classes from this API. These classes are designed to let you create arbitrarily complex queries. You could, for example, retrieve all the songs in a particular genre whose titles include a particular word or

AVAudioPlayer doesn't start playing in background

╄→гoц情女王★ 提交于 2019-12-01 12:56:22
问题 I am using AVAudioPlayer and NSFileHandle to do audio streaming. The basic idea is that I save the streaming audio data to the device with file system and then use AVAudioPlayer to playback the file just saved. AVAudioPlayer can still play that file even the streaming is in progress. I have a UIButton to start streaming/downloading. When the downloaded data is accumulated to a specific amount of Bytes, AVAudioPlayer will play (the "play" method of AVAudioPlayer is triggered) automatically. My

Audio Information of Current Track iOS Swift

人盡茶涼 提交于 2019-12-01 12:30:42
Let's say a track is playing (through any app), and I want to get the song information, such as the name. It shows up on your screen when you lock the phone, along with the album cover. How can I get that information using swift? Here is example function to get audio Info: import MediaPlayer var url:NSURL! let audioInfo = MPNowPlayingInfoCenter.defaultCenter() var nowPlayingInfo:[NSObject:AnyObject] = [:] func fetchMP3Info() { let playerItem = AVPlayerItem(URL: url) //this will be your audio source println(url.path!) let metadataList = playerItem.asset.metadata as! [AVMetadataItem] for item in

AVAudioPlayer and performance issue in SpriteKit game

梦想与她 提交于 2019-12-01 12:29:08
I have problem with AVAudioPlayer and playing the short sounds in my spritekit game. I have quite dynamic game scene and when the user tap into particular element I want to play simple "beep" sound, but I notice that performing sound using AVAudioPlayer cause significant performance issue. My audio files are in .mp3 format. Also I have tried SKAction method (playSoundFileNamed) to perform sound and everything looks almost the same, I noticed the same performance issue. My question is what is the best practice to perform sound in SpriteKit. PS: I tried to find WWDC Adventure spritekit sample