avaudioplayer

Play audio file in a sequence usign swift

谁说胖子不能爱 提交于 2019-12-12 01:40:46
问题 I have two functions. First one loops list of names for audio to be played, and the second one is the actual player function. The problem is that it plays only the last one. It does not play one by one waiting till the next is finished. How it possible to perform in a sequence? I tried to add: dispatch_after(DISPATCH_TIME_NOW, dispatch_get_main_queue(), { }) ... still does not work. Any possible solution. Thank you in advance! func startGame(){ audioPlay("NowListen") for i in 0...self

How do I play multiple files in AVAudioplayer

醉酒当歌 提交于 2019-12-12 01:35:34
问题 I have some songs in a plist and want to play them one after the other using AVAudioplayer. But when the first song ends it stops. How do I start the player with next song? I have tried a loop which counts to next number in the plist but it does not work. The player stops after first round. This should be simple but how? This is parts of my code. Is it is possible to use a loop as I do? NSString *soundsPath = [[NSBundle mainBundle] pathForResource:@"soundslist" ofType:@"plist"]; soundsList =

can I use AVAudioPlayer to make an equalizer player?

天涯浪子 提交于 2019-12-12 01:29:01
问题 I want to make an equalizer for music player,which can do some EQ setting like bass and treble,and I want to change the music effect by setting the frequency. 250Hz , 1000Hz , 16000Hz . (void)setEQ:(@"250Hz"); (void)setEQ:(@"1000Hz z"); (void)setEQ:(@"16000Hz"); But I can not find any API of AVAudioPlayer to set frequency.Can anyone help me? I will be very grateful. 回答1: i think AVAudioplayer is not support for Equalizer Effect, for this you need to apply bands for all audio units but by

AvAudioPlayer setting delegate to nil releases the delegate object?

送分小仙女□ 提交于 2019-12-12 01:15:17
问题 @implementation MyClass -(id) init { NSString *path0 = [ [NSBundle mainBundle] pathForResource:@"myfile" ofType:@"m4a" ]; mSound = [[AVAudioPlayer alloc]initWithContentsOfURL:[NSURL fileURLWithPath:path0] error:NULL]; mSound.delegate = self; } -(void) release { mSound.delegate = nil; //<- this line causes MyClass release function to be called recursively [ mSound release ]; //<- removing the line above makes this line do the same, i.e. calls myclass release recursively } It seems that

how to play music using AVAudioPlayer when screen os locked

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-11 20:11:55
问题 i need to play a simple sound using AVAudioPlayer when screen is locked .How can I do that please help 回答1: This was answered here before. As the thing suggests you need to set your audio session as in this example UInt32 category = kAudioSessionCategory_MediaPlayback; OSStatus result = AudioSessionSetProperty(kAudioSessionProperty_AudioCategory, sizeof(category), &category); if (result){ DebugLog(@"ERROR SETTING AUDIO CATEGORY!\n"); } result = AudioSessionSetActive(true); if (result) {

Why does the AVAudioPlayer stop method not work when switching views

*爱你&永不变心* 提交于 2019-12-11 17:42:35
问题 I have an iphone app that displays images and plays audio selected from a main menu. The user clicks on a button to select the image/audio combo they want. The code to switch the views with animation works fine. All of the code to display the image, play, pause, scrub, and stop the audio while in the new view works fine too. However, when the users clicks the Main Menu button I want the playing audio to stop. I am using viewWillDisappear:(BOOL)animated to call the stop method: -(void

AVAudioPlayer using array to queue audio files - Swift

若如初见. 提交于 2019-12-11 16:58:35
问题 I am looking for a way to simply play audio files one after another. AVAudioPlayer using an array seems to be the best solution. In fact, I was able to play the first element of the array using Sneak's recommendations found on this page : Here. But I don't understand where and how to write the second call to AVAudioPlayer in order to play the second file? The "audioPlayerDidFinishPlaying" function is not reacting. Why? Thanks for watching. import Cocoa import AVFoundation var action =

Play m4a file from document Directory

北城余情 提交于 2019-12-11 16:48:21
问题 I would to play an m4a file but I'm getting an error in the console and the file won't play. Console prints: The operation couldn’t be completed. (OSStatus error 2003334207.) let url = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)[0] print("File Location: ",url.path) if(FileManager.default.fileExists(atPath: url.path)) { do { audioPlayer = try AVAudioPlayer(contentsOf: url) guard let player = audioPlayer else { return } player.prepareToPlay() } catch let error { print

Using AVAudioPlayer with Dynamic URL in Swift 3 causing Thread Errors

我们两清 提交于 2019-12-11 16:47:50
问题 I am new to Swift and making an audio app using AVAudioPlayer . I am using a remote URL mp3 file for the audio, and this works when it's static. For my use case, I want to pull a URL for an mp3 file from a JSON array and then pass it into the AVAudioPlayer to run. If I move the AVAudioPlayer block into the ViewDidLoad and make the mp3 file a static URL, it will run fine. Then, when I move this code into my block that extracts an mp3 url from JSON, I can print the URL successfully. But when I

AVAudioPlayer leaks?

夙愿已清 提交于 2019-12-11 15:35:10
问题 I've got a problem and don't know how to handle it. Tyring to build an app with sound and animation. It gives me a level 1 and then level 2 memory warning. I've tried build and analyze and i got all these potential leaks. If I release theAudio the sound won't play. Any hints? Here is a part of the code and the leakes I've got - (IBAction)playsound2 { NSString *path = [[NSBundle mainBundle] pathForResource:@"cat" ofType:@"mp3"]; AVAudioPlayer* theAudio = [[AVAudioPlayer alloc]