avaudioplayer

How do I start playing audio when in silent mode & locked in iOS 6?

☆樱花仙子☆ 提交于 2019-12-17 04:15:24
问题 End-user process Open app Switch on 'Silent Mode'. Press 'Lock-button' App can still START playing a sound after hours have passed, not playing any audio in the interim. Apps that do this A lot of alarm apps have manage to do this & I dont think they are using silent audio to keep the app running as they do not sound if you actually exit the app with home. Alarm Clock Pro My Clock Wave Alarm Alarmed iHome ... ...Are they keeping a loop running after being locked some how or it a notification

Playing a sound with AVAudioPlayer

喜夏-厌秋 提交于 2019-12-17 02:44:09
问题 I'm trying to play a sound with AVAudioPlayer but it won't work. Edit 1: Still doesn't work. Edit 2 : This code works. My device was in silent mode. import UIKit import AVFoundation class ViewController: UIViewController { var audioPlayer = AVAudioPlayer() override func viewDidLoad() { super.viewDidLoad() var alertSound = NSURL(fileURLWithPath: NSBundle.mainBundle().pathForResource("button-09", ofType: "wav")) println(alertSound) var error:NSError? audioPlayer = AVAudioPlayer(contentsOfURL:

“Cannot convert value of type 'AVAudioPlayer.Type' to expected argument type”

时光总嘲笑我的痴心妄想 提交于 2019-12-14 03:04:16
问题 I'm having trouble with the function audioPlayerDidFinish playing. I have added the AVAudioPlayerDelegate to my view controller class and defined the function. When I call the function I get the error "Cannot convert value of type 'AVAudioPlayer.Type' to expected argument type" What am I doing wrong? Let me know if I need to add more code for you to see. func buttonPressed() { if currentSound == sound { currentSound = "None" activateBlankCircle() audioPlayer.stop() } else { currentSound =

Playing Sound On Button (AV Audio Player) returning nil string parameter

﹥>﹥吖頭↗ 提交于 2019-12-14 02:43:13
问题 I am attempting to play a sound on button press. Previously, I used Audiotoolbox which worked just fine with the same file type. However, i need to change to using AvAudioPlayer becuase it doesn't use the ringer volume. So last week I developed an understanding of using the audio player to play a sound on click. I had it working a treat on my over app using the exact same code. However, this app despite trying countless time will not work with AVFoundation/AudioPlayer. I have tried adding new

Play multiple sounds (one by one) with AVAudioPlayer

谁说我不能喝 提交于 2019-12-14 02:38:41
问题 I am using AVAudioPlayer to make an MP3 player. I have multiple MP3 sounds and would like to play these sounds one by one. Following is the logic of my app: ///// For playing 1st sound mp3Player = [[AVAudioPlayer alloc] initWithContentsOfURL:url1 error:nil]; [mp3Player prepareToPlay]; [mp3Player play]; ///// For playing 2nd sound mp3Player = nil; mp3Player = [[AVAudioPlayer alloc] initWithContentsOfURL:url2 error:nil]; [mp3Player prepareToPlay]; [mp3Player play]; ///// For playing 3rd sound

Handling interruptions in Sprite Kit - can't get sound effects via [SKAction playSoundFileNamed: to work after interruption

删除回忆录丶 提交于 2019-12-14 02:02:33
问题 Handling interruptions in Sprite Kit - can't get sound effects via [SKAction playSoundFileNamed: to work after interruption (like a phone call) Was able to get background music to restart after interruption by adding AVAudioPlayerDelegate to my GameScene.h then adding to my GameScene.m -(void)audioPlayerBeginInterruption:(AVAudioPlayer *)player { [_backgroundAudioPlayer pause]; } -(void)audioPlayerEndInterruption:(AVAudioPlayer *)player { [_backgroundAudioPlayer prepareToPlay]; [

stopping an AVAudioPlayer

落花浮王杯 提交于 2019-12-13 18:01:14
问题 here is my code NSString *soundFilePath = [[NSBundle mainBundle] pathForResource:@"95" ofType:@"wav"]; NSError *activationError = nil; NSError *audioPlayerInitError = nil; [[AVAudioSession sharedInstance] setActive: YES error:&activationError]; NSURL *newURL = [NSURL fileURLWithPath:soundFilePath]; musicPlayer1 = [[AVAudioPlayer alloc] initWithContentsOfURL:newURL error:&audioPlayerInitError]; if (musicPlayer1) { [musicPlayer1 stop]; [musicPlayer1 release]; musicPlayer1 = nil; } else {

How can I use AVAudioPlayer to play audio faster *and* higher pitched?

随声附和 提交于 2019-12-13 12:01:56
问题 Statement of Problem: I have a collection of sound effects in my app stored as .m4a files (AAC format, 48 KHz, 16-bit) that I want to play at a variety of speeds and pitches, without having to pre-generate all the variants as separate files. Although the .rate property of an AVAudioPlayer object can alter playback speed, it always maintains the original pitch, which is not what I want. Instead, I simply want to play the sound sample faster or slower and have the pitch go up or down to match —

How to play an mp3 file in Xcode from time t1 to t2 with AVAudioPlayer

女生的网名这么多〃 提交于 2019-12-13 09:09:20
问题 I wonder if there is a more elegant way to play a mp3 file with AVAudioPlayer Class, from t1 to t2 time without using NSTimers? 回答1: AVAudioPlayer has a method playAtTime: which takes care of t1 , however there's no easy way to stop playing at a specific time ( t2 ). As of iOS8 AVFoundation has new api's such as AVAudioEngine and AVAudioPlayerNode . You may find implementing AVAudioPlayerNode instead is more suited for your requirements as it has a method named - scheduleSegment:startingFrame

What is the smoothest audio API for looping iPhone sounds

浪子不回头ぞ 提交于 2019-12-13 08:39:26
问题 I am trying to loop a 2 second sound continuously that I am using in my touchesMoved method and want to make it play continuosly and not stutter or stop because the user stopped moving their finger and also maybe fade the sound into itself smoothly. I have tried system sounds and AVAudioPlayer 回答1: i've alreay offered you to use OpenAL in your previous question 来源: https://stackoverflow.com/questions/1938274/what-is-the-smoothest-audio-api-for-looping-iphone-sounds