avaudioplayer

Setting iOS MPMusicPlayerController volume relative to AVAudioPlayer

纵然是瞬间 提交于 2019-12-08 04:35:51
问题 I have an app that plays background music using MPMusicPlayerController and foreground sounds using AVAudioPlayer. I want to control the relative volume so that MPMusicPlayerController is much lower, but setting the volumne changes the overall system volume as if using the buttons on the side of the phone. Is there way to lower the volumne of MPMusicPlayerController without lowering the system volume? MPMusicPlayerController *musicPlayer = [MPMusicPlayerController applicationMusicPlayer];

AVAudioPlayer will not play when device is locked

本小妞迷上赌 提交于 2019-12-08 04:26:33
问题 I am using AVAudioPlayer in my application. When I select a song it plays, but my problem is, it is not playing when the device gets locked. 回答1: You need to read Executing Code in the Background in Apple's documentation. If you set the UIBackgroundModes key in you app's Info.plist to audio , audio will keep playing while backgrounded. See the sections Declaring the Background Tasks You Support and Playing Background Audio in the aforementioned documentation. 回答2: All we need to make music

AVAudioRecorder not saving recording

为君一笑 提交于 2019-12-08 04:03:52
问题 I am making an iOS game. One of the things I need to do is to allow the user to make a quick little audio recording. This all works, but the recording is only temporarily saved. So when the user closes the app and reopens it, the recording should be able to play again, but it doesn't, it gets deleted when I close the app. I don't understand what I am doing wrong. Below is my code: I setup the AVAudioRecorder in the ViewDidLoad method like this: // Setup audio recorder to save file. NSArray

AVAudioPlayer not playing sounds simultaneously

∥☆過路亽.° 提交于 2019-12-08 02:14:46
问题 I am trying to play a couple of sounds files at the same time for the AVAudioPlayer. I read a thread explaining how to do it @ AVAudioPlayer Help: Playing multiple sounds simultaneously, stopping them all at once, and working around Automatic Reference Counting . It seems to be a weird issue as I when i try to only play one file at a time (when self.options.on is ON), it works, but when I try creating multiple instances (the else statements) and play them nothing plays. I checked to see if

How to change audio recording settings to 16Khz and 16 bit when we record audio?

十年热恋 提交于 2019-12-08 01:56:55
问题 I have the settings shown below. I want change audio recording settings to 16Khz and 16 bit when we record audio. NSArray *dirPaths; NSString *docsDir; dirPaths = NSSearchPathForDirectoriesInDomains( NSDocumentDirectory, NSUserDomainMask, YES); docsDir = [dirPaths objectAtIndex:0]; NSString *soundFilePath = [docsDir stringByAppendingPathComponent:@"sound.wav"]; NSURL *soundFileURL = [NSURL fileURLWithPath:soundFilePath]; NSDictionary *recordSettings = [NSDictionary

IOS can I use AVAudioPlayer on the appDelegate?

流过昼夜 提交于 2019-12-07 17:32:07
问题 I have a TabBarController with two tabs and I want to play music on both tabs. Right now I have my code on the main appDelegate NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"My Song" ofType:@"m4a"]]; // My Song.m4a NSError *error; self.audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:url error:&error]; if (error) { NSLog(@"Error in audioPlayer: %@", [error localizedDescription]); } else { //audioPlayer.delegate = self; [audioPlayer prepareToPlay]; }

iPhone - start multiple instances of AVAudioPlayer simultaneously

一个人想着一个人 提交于 2019-12-07 08:43:01
问题 I am using multiple instances of AVAudioPlayer to play multiple audio files simultaneously. I run a loop to start playing the audio files (prepareToPlay is called beforehand and the loop only makes a call to the play method) But invariably, one of the players does not play in sync. How can I ensure that all the 4 players start playing audio simultaneously? Thanks. 回答1: Unfortunately, you can't. AVAudioPlayer doesn't provide any mechanism for fine-grained control of start time. The currentTime

How to cross fade between AVAudioPlayers

浪子不回头ぞ 提交于 2019-12-07 08:28:52
问题 I want to use AVAudioPlayer and cross fade more than 2 mp3 files. I have 5 mp3 files and 5 pages "myScrollView" with UIScrollView class and pagingEnabled = YES. When user move page, I want to play each songs for each page with volume fade out for previous mp3 file and fade in for next mp3. Please help this problem. 回答1: This is not cross fading operation. But, this can fade-in/out one at a time with new thread using NSOperation and fade-in/out effects can be added to the thread in any order.

AudioPlayer iOS and m4a

别等时光非礼了梦想. 提交于 2019-12-07 07:53:06
问题 I've made an app that plays music using AVAudioPlayer. It either uploads or downloads songs, writes them to Core Data, then recalls them to play when selected. All of the fifteen songs that I've been testing with operate normally using both the iPhone Music Client and my own computer. However, three of them don't play back on the app. Specifically, I can upload these fifteen songs in any order, clear my Model.sqlite, download them again into the app, and find that three of them just don't

How to tell the MPNowPlayingInfoCenter wether or not the music is playing or paused?

断了今生、忘了曾经 提交于 2019-12-06 20:18:43
问题 I can't seem to make iOS show the correct play / pause button in the remote audio controls. I do receive the remote control events and set all values of the nowPlayingInfo dictionary. Everything works fine and I even see a cover photo on the lock screen. Except the pause/play button. It always looks like pause even if my AVAudioPlayer is playing. It sends a pause event regardless of playback state. How can I notify iOS that AVAudioPlayer is paused and that it should now show a play button in