avaudioplayer

AVAudioSession reactivation issue

戏子无情 提交于 2019-12-06 06:51:03
I am getting the following error: [0x19bf89310] AVAudioSession.mm:646: -[AVAudioSession setActive:withOptions:error:]: Deactivating an audio session that has running I/O. All I/O should be stopped or paused prior to deactivating the audio session. I have read through this post: iOS8 AVAudioSession setActive error however the solution there did not solve my problem. which is: small application (game) audio background music handled in AudioHelper.swift additional 'blip' sounds played with SKActino.playSoundFile reproduction start game (background music starts to play) close game (music stops)

MonoTouch: Playing sound

血红的双手。 提交于 2019-12-06 06:48:25
问题 I am trying to play a short sound when user taps on the specific button. But the problem is that I always receive Object reference not set to an instance object . means Null! I first tried MonoTouch.AudioToolBox.SystemSound. MonoTouch.AudioToolbox.AudioSession.Initialize(); MonoTouch.AudioToolbox.AudioSession.Category = MonoTouch.AudioToolbox.AudioSessionCategory.MediaPlayback; MonoTouch.AudioToolbox.AudioSession.SetActive(true); var t = MonoTouch.AudioToolbox.SystemSound.FromFile("click.mp3"

How to record video and play audio at the same time (swift tutorial)

喜你入骨 提交于 2019-12-06 05:57:37
问题 So you want to record a video and play music from the user's library at the same time ? Look no further. Below is the answer. 回答1: For the audio playback you will use AVAudioPlayer . All you have to do is to declare the AVAudioPlayer as a global variable (I named it audioPlayer ) and implement the code below. Use this in after the user chose the song he/she wants to play: func mediaPicker(mediaPicker: MPMediaPickerController, didPickMediaItems mediaItemCollection: MPMediaItemCollection) { let

iPhone - AVAudioPlayer - convert decibel level into percent

旧巷老猫 提交于 2019-12-06 05:31:22
问题 I like to update an existing iPhone application which is using AudioQueue for playing audio files. The levels (peakPowerForChannel, averagePowerForChannel) were linear form 0.0f to 1.0f. Now I like to use the simpler class AVAudioPlayer which works fine, the only issue is that the levels which are now in decibel, not linear from -120.0f to 0.0f. Has anyone a formula to convert it back to the linear values between 0.0f and 1.0f? Thanks Tom 回答1: Several Apple examples use the following formula

Resuming execution of code after interruption while app is in background

*爱你&永不变心* 提交于 2019-12-06 05:31:06
问题 I have spent days researching on SO and other websites for the answer to this but without any luck. Essentially, the challenge I've set for myself is to create an alarm clock app for iOS that will sound no matter where the user may be (foreground or background). This I have already accomplished by using an AVAudioPlayer instance and starting to play an empty sound file when the user sets the alarm in order for the app to keep running in the background. When it is time for the alarm to go off

Swift - How can I convert Saved Audio file conversations to Text?

人走茶凉 提交于 2019-12-06 05:11:03
问题 I work on speech recognition. I solve the text-to-speech and speech-to-text with IOS frameworks. But now i want to convert saved audio file conversations to text. How can i solve this ? Thank you for all replies. 回答1: I have worked on same things which are working for me. I have audio file in my project bundle which. So I have written following code to convert audio to text. let audioURL = Bundle.main.url(forResource: "Song", withExtension: "mov") let recognizer = SFSpeechRecognizer(locale:

IOS can I use AVAudioPlayer on the appDelegate?

早过忘川 提交于 2019-12-06 01:44:01
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]; } but I'm getting the error Program received signal: "SIGABRT" on UIApplicationMain Is there a better way

Cannot Control Volume of AVAudioPlayer via Hardware Buttons when AudioSessionActive is NO

巧了我就是萌 提交于 2019-12-06 00:45:40
I'm building a turn-by-turn navigation app that plays periodic, short clips of sound. Sound should play regardless of whether the screen is locked, should mix with other music playing, and should make other music duck when this audio plays. Apple discusses the turn-by-turn use case in detail in the "WWDC 2010 session 412 Audio Development for iPhone OS part 1" video at minute 29:20. The implementation works great, but there is one problem - when the app is running, pressing the hardware volume controls adjust the ringer volume, not the app volume. If you want to change the app volume, you must

Force audio file playback through iPhone loud speaker using Swift

主宰稳场 提交于 2019-12-06 00:37:55
问题 I have an App that records and then plays back an audio file. Currently the audio playback is playing through the earpiece speaker. Could someone tell me how Swift would handle coding this to force the audio out the loud speaker instead? Below is a one of the instances I'm using to play the audio file: @IBAction func playAudioVader(sender: UIButton) { playAudioWithVariablePitch(-1000) } func playAudioWithVariablePitch(pitch: Float){ audioPlayer.stop() audioEngine.stop() audioEngine.reset()

iPhone SDK: Play a single WAV from a button

霸气de小男生 提交于 2019-12-06 00:26:28
I am currently trying out this code: NSString *path = [[NSBundle mainBundle] pathForResource:@"dream" ofType:@"m4a"]; AVAudioPlayer* theAudio=[[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:path] error:NULL]; theAudio.delegate = self; [theAudio play]; However, the SDK says that the ViewController does not implement the AVAudioPlayer Delegate. Any body any ideas on how to play a WAV (or M4a) using the 2.2 SDK? You need to add <AVAudioPlayerDelegate> to the end of your controller's class declaration, along these lines: @interface MyViewController : UIViewController