avaudioplayer

Entering background on iOS4 to play audio

荒凉一梦 提交于 2020-03-07 08:48:03
问题 The documentation is rather poorly written when talking about playing audio in the background. It gives the impression that all you have to do to continue playing the audio that you are currently playing is to just add a key/value pair to the info.plist file and wallah, it's magic. However, this is not the case. For instance, if I play an mp3 that is 2 minutes long, obviously the audio is long enough to be able to play after I hit the home button to send my app to the background. The thing is

Resume AVAudioPlayer after phone call not working

人盡茶涼 提交于 2020-02-03 07:32:30
问题 There are some seemingly similar questions already on SO, but after hours of searching and experimenting with my code, I have been unable to find a clear answer. The closest thing I could find was this answer which alludes to a "known bug" 4 years ago, but does not elaborate on how to address it. I have an audioPlayer class that is playing an audio file with AVAudioPlayer and listening for the AVAudioSessionDelegate methods beginInterruption and endInterruption . I know that endInterruption

MPRemoteCommandCenter pause/play button create more sharedInstance of AVAudioPlayer?

こ雲淡風輕ζ 提交于 2020-01-25 06:50:29
问题 My app is a music player using AVAudioPlayer with Singleton pattern and background mode. Things are going well, but after I add command center for locked screen control, one strange behavior I found. When I use the pause/play button in locked screen, sometimes it may create additional sharedInstance of audioPlay on background , because I found more than ones times duplicate printing, e.g. in my commandCenter.pauseCommand code. And audio is paused or resume playing but next click on both

how can i record a song which is playing with AVPlayer and an wav file at a same time?

梦想的初衷 提交于 2020-01-25 05:01:08
问题 I'm developing an App in which i have to record a song and a wav file at a same time.I'm playing song from iPod Music libraries and on a view controller i have placed a button on click of which an wav file starts but when i start recording using AVAudioRecorder,my wav file stop working. This is my ipod music library's code:- - (void) mediaPicker: (MPMediaPickerController *) mediaPicker didPickMediaItems: (MPMediaItemCollection *) collection { MPMediaItem *item = [[collection items]

Problem in playing & recording sound with two different players

对着背影说爱祢 提交于 2020-01-24 22:16:08
问题 I have implemented two AVAudioPlayer in my iPad project. I am playing sound with one player object and also simultaneously recording with the other player. First Scenario 1.Player1 is recording the words I am speaking. 2.Simultaneously player1 is also recording the music playing with player2. *This scenario is working fine if I am not plugging in any headset with microphone to my iPad. *But, if I plugged in the headset to my iPad & repeat the above scenario, the following points are observed:

How do you use AVAudioPlayer to play music while in the background?

倾然丶 夕夏残阳落幕 提交于 2020-01-24 09:40:26
问题 I currently use AVAudioPlayer to play music while in the foreground, but when I press the home button my application goes to the background and the music stops. I set the category for my AVAudioSession to AVAudioSessionCategoryPlayback and set active to YES. Additionally, I added the audio key to UIBackgroundModes in my Info.plist. Is there anything else I need to do to enable background music playback? 回答1: There's apparently a bug in the simulator - it doesn't work there, while it works

How do you use AVAudioPlayer to play music while in the background?

一曲冷凌霜 提交于 2020-01-24 09:40:09
问题 I currently use AVAudioPlayer to play music while in the foreground, but when I press the home button my application goes to the background and the music stops. I set the category for my AVAudioSession to AVAudioSessionCategoryPlayback and set active to YES. Additionally, I added the audio key to UIBackgroundModes in my Info.plist. Is there anything else I need to do to enable background music playback? 回答1: There's apparently a bug in the simulator - it doesn't work there, while it works

How to convert .opus file to .mp3/.m4a/.aac in iOS swift?

风格不统一 提交于 2020-01-23 15:51:06
问题 I want to play .opus file using AVAudioPlayer, since AVAudioPlayer doesn't support .opus file, I am trying to find a way to convert .opus to any other audio format so that I can play using AVAudioPlayer . Could anyone help me on this? Thank you 回答1: You could use libopus or libopusfile C libraries to dynamically decode Opus files to raw PCM audio and feed that to a memory buffer that AVAudioPlayer could decode. You would most likely need to prepend the memory buffer with AIFF/WAV/RIFF header

AVAudioPlayer cannot play music with a NSTimer in background

自作多情 提交于 2020-01-23 03:59:25
问题 I want to play music with an AVAudioPlayer using an NSTimer, but [player prepareToPlay] returns NO & doesn't play in the background. Can somebody give me some idea? Here's my code: - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { [NSTimer scheduledTimerWithTimeInterval:10 target:self selector:@selector(playMusic:) userInfo:nil repeats:NO]; [self.window makeKeyAndVisible]; return YES; } - (void)playMusic:(NSTimer *)timer{ [

Playing multiple audio files using AVAudioPlayer

泪湿孤枕 提交于 2020-01-17 06:36:20
问题 I created the 3 UIButtons on the Main StoryBoard. When I press "Button1" or "Button2" each plays an audio file ( "player 1" , "player 2".) and while the audio is playing the UIButton is set to selected . I would like "Button3" to implement multiple functions in a row. That means when I press "Button 3", "player 3" should be played first, after that "player 1" and after that "player 2". However, when I press "Button3", "player 1" and "player 2" are played at same time as there is no delay for