avaudioplayer

how to playing audio in background mode when If i click on iphone button to “minimize” the app?

岁酱吖の 提交于 2020-01-03 15:23:08
问题 I'm work on new iphone audio application. When i open the app, the Audio was loaded and started. If i click on iphone button to "minimize" the app, the sound was stopped. I need the sound still playing in background mode. How i do this? Thank you 回答1: To play in the background, add an Array entry named "UIBackgroundModes" your .plist file, and add "audio" as array member. .plist entry: UIBackgroundModes Array Item0 String audio 回答2: Try to look at AVAudioSession also. AVAudioSession *session

AVAudioPlayer EXC_BAD_ACCESS

对着背影说爱祢 提交于 2020-01-03 08:41:37
问题 I am trying to pause the AVAudioPlayer if it is currently playing. When I debug my code and check AVAudioPlayer , I see it is allocated. When I try to access a method/property on it (i.e. myAudioPlayer isPlaying ), I get an EXC_BAD_ACCESS error. This happens if the AVAudioPlayer does not have a sound loaded. Is there a way I can do a check to see if it has loaded a sound? I tried accessing myAudioPlayer.data , but I still get the same error. 回答1: I guess you have to use prepareToPlay method

Where to place code for audio playback in a SwiftUI app [closed]

﹥>﹥吖頭↗ 提交于 2020-01-03 06:40:16
问题 Closed . This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 5 months ago . Where is the best place to put code for audio playback in a SwiftUI based app, i.e. not having UIViewController classes? The sound I want to play is initiated by a view, so I'm thinking of putting it into the corresponding view model class. But as a model class is about data

Sounds in UILocalNotification louder than AVAudioPlayer at max volume

旧时模样 提交于 2020-01-03 03:13:06
问题 For purposes of this question, imagine my app plays an audio clip every 10 seconds. This audio plays/mixes with the iPod music player on the device (using ducking), using AVAudioPlayer. When the app is sent to the background, I schedule UILocalNotification objects with the audio file referenced (and no text), so the sounds continue to play at 10 second intervals. What is bothering me is that the volume of the audio clips played as part of a notification on iOS 6 seem to be twice as loud as

How to send NSData over an OutputStream

筅森魡賤 提交于 2020-01-03 03:01:16
问题 You can view this project on github here: https://github.com/Lkember/MotoIntercom/ The class that is of importance is PhoneViewController.swift I have an AVAudioPCMBuffer. The buffer is then converted to NSData using this function: func audioBufferToNSData(PCMBuffer: AVAudioPCMBuffer) -> NSData { let channelCount = 1 let channels = UnsafeBufferPointer(start: PCMBuffer.floatChannelData, count: channelCount) let data = NSData(bytes: channels[0], length:Int(PCMBuffer.frameCapacity * PCMBuffer

How does audioPlayerDidFinishPlaying know which file is finished?

我的梦境 提交于 2020-01-03 00:54:48
问题 I am using AVAudioPlayer to play a 15 audio files. The audio files need to be played in sets of 5 with each set having three files. The three files within a set do not change. The order that the sets are played may change. I tried using a while loop with isPlaying like this: while ([backgroundSound isPlaying]) { NSLog(@"First while loop"); } backgroundSoundPath = [[NSBundle mainBundle] pathForResource:@"Set0File1" ofType:@"mp3"]; // *Music filename* backgroundSound =[[AVAudioPlayer alloc]

iOS - Attempting to play mp3 file fails

回眸只為那壹抹淺笑 提交于 2020-01-02 18:57:17
问题 I'm trying to playback and mp3 file I retrieve from my server from my app doing the following: - (IBAction)play:(UIButton *)sender { dispatch_queue_t downloadQueue = dispatch_queue_create("audio data downloader", NULL); dispatch_async(downloadQueue, ^{ NSURL *audioURL = [NSURL URLWithString:[NSString stringWithFormat:@"%@%@/%@.mp3", FONYK_FILES_URL, [self.voicenote valueForKeyPath:@"Fonyker.fonykid"], [self.voicenote valueForKeyPath:@"Voicenote.vnid"]]]; NSData *audioData = [NSData

OSStatus error 2003334207 while re-buiding the App from Xcode 6

我是研究僧i 提交于 2020-01-02 02:33:27
问题 I am using AVAudioPlayer to play recorded audio which is saved in Iphone's Document directory. When I first record an audio and then play, it works fine (Device is connected to the system and App is running through Xcode). But when I Stop the running App through Xcode and again run the App through Xcode, I am getting Error Error Domain=NSOSStatusErrorDomain Code=2003334207 "The operation couldn’t be completed. (OSStatus error 2003334207.)" File Location: file:///var/mobile/Containers/Data

Do an action when a sound has finished playing in AVAudioPlayer?

☆樱花仙子☆ 提交于 2020-01-02 00:15:10
问题 I am using the AVAudioPlayer framework, and I have several sounds that play one at a time. When a sound is finished playing, I want the application to do something. I tried to use audioPlayerDidFinishPlaying to do the action at the end of the first sound, but I couldn't use that for the second sound because I got a redefinition error. Can I use NSTimeInterval to get the duration of a sound? // ViewController.h #import <UIKit/UIKit.h> #import <AVFoundation/AVFoundation.h> #import <AVFoundation

Swift 2: AVAudioPlayers to play multiple sounds at once

你。 提交于 2020-01-01 12:15:24
问题 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: