Tag: audio

同时录制和播放audio

任何一个帮助我录制和播放audio同时在iphone中。

iOS背景audio没有播放

我有一个使用CoreBluetooth背景模式的应用程序。 当某个事件发生时,我需要发出警报声。 在前台一切工作正常,所有的蓝牙function在后台工作正常。 我也有它工作的地方在后台安排UILocalNotification的声音报警,但是我不喜欢缺乏这些音量控制,所以想用AVAudioPlayer播放报警声音。 我已将背景模式audio添加到我的.plist文件,但无法正确播放声音。 我正在使用一个单独的类来报警,并像这样初始化声音: NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:soundName ofType:@"caf"]]; player = [[AVAudioPlayer alloc] initWithContentsOfURL:url error:nil]; player.numberOfLoops = -1; [player setVolume:1.0]; 我开始这样的声音: -(void)startAlert { playing = YES; [player play]; if (vibrate) [self vibratePattern]; } 并将其用于振动: -(void)vibratePattern { if (vibrate && playing) { AudioServicesPlaySystemSound(kSystemSoundID_Vibrate); [self performSelector:@selector(vibratePattern) withObject:nil afterDelay:0.75]; } } 振动在后台工作正常,但没有声音。 如果我使用Systemsound播放这样的声音,它播放良好(但没有音量控制): […]

Sprite Kit和播放声音导致应用程序终止

使用ARC 只是我碰到一个问题 – 我有一个SKScene,在其中使用SKAction类方法播放声音 [SKAction playSoundFileNamed:@"sound.wav" waitForCompletion:NO]; 现在,当我尝试去背景,无论声音结束,显然iOS终止我的应用程序,由于gpus_ReturnNotPermittedKillClient 。 现在,只有当我评论这行,而不是运行iOS的后台运行(当然,暂停,但没有终止)的行动。 我究竟做错了什么? 编辑 :iOS不会终止应用程序,如果行不运行 – 说,如果它是在一个if statement没有运行的if statement (soundOn == YES)或类似的东西,当布尔是false

如何检测iPhone是在静音模式

我正在开发一个应用程序。 在那我想通过编码检测“是否在静音模式iPhone?”。 我正在使用Objective-C的cocoa来开发它。 如果有人知道,请回复。

用AVAudioPlayer播放声音

我试图用AVAudioPlayer播放声音,但它不会工作。 编辑1:仍然不起作用。 编辑2 :此代码的作品。 我的设备处于静音模式。 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: alertSound, error: &error) audioPlayer.prepareToPlay() audioPlayer.play() }

如何播放背景Swift中的audio?

正如你所看到的,我正在播放一个audio广播。 但是,当我按主页button,并退出应用程序stream停止或我听不到。 如何在后台继续stream式传输并从locking屏幕上收听? ViewController.Swift import UIKit import AVFoundation import MediaPlayer import GoogleMobileAds class ViewController: UIViewController, GADInterstitialDelegate { @IBOutlet weak var exitMapButton: UIButton! @IBOutlet weak var radarMap: UIWebView! var interstitial: GADInterstitial! func createAndLoadInterstitial() -> GADInterstitial { var interstitial = GADInterstitial(adUnitID: "ca-app-pub-5378899862041789/2782958552") interstitial.delegate = self interstitial.loadRequest(GADRequest()) return interstitial } func getAd(){ if (self.interstitial.isReady) { self.interstitial.presentFromRootViewController(self) self.interstitial = […]

如何处理iOS设备被locking或其他应用程序时播放的背景audio?

使用OpenFrameworks为iOSdevise生成音乐系统,我需要提供一种模式,用户可以在此模式下聆听应用程序产生的音乐: 该设备被locking 用户使用另一个应用程序 一些像BLOOM或闹钟这样的应用程序就是这样工作的,并build议用户使用一个开关来启用/禁用此function。 任何提示呢?