草庐IT

AVAudiosession

全部标签

ios - 使用 beginReceivingRemoteControlEvents

我看到人们在管理AudioSession时使用:[[UIApplicationsharedApplication]beginReceivingRemoteControlEvents];来处理远程控制事件。我的问题:此代码是否只能在UIViewController类或AppDelegate类中使用?因为我看到互联网上的每个人都在两个类(class)之一中使用它。我可以在不是UIViewController或AppDelegate子类的类中使用它吗? 最佳答案 对于只想在特定状态下处理远程控制事件的应用程序——例如,准备好播放媒体,而不

ios - 使用 MPMoviePlayerController 播放视频时如何静音/取消静音?

我已经创建了自己的自定义控件以与MPMoviePlayerController一起使用。到目前为止,除了静音按钮控件外,一切正常。在创建MPMoviePlayerController实例之前,我已经使用以下代码配置了AVAudioSession。NSError*modeError=nil;[self.audioSessionsetMode:AVAudioSessionModeMoviePlaybackerror:&modeError];if(modeError!=nil){NSLog(@"ErrorsettingmodeforAVAudioSession:%@",modeError);

ios - 使用 MPMoviePlayerController 播放视频时如何静音/取消静音?

我已经创建了自己的自定义控件以与MPMoviePlayerController一起使用。到目前为止,除了静音按钮控件外,一切正常。在创建MPMoviePlayerController实例之前,我已经使用以下代码配置了AVAudioSession。NSError*modeError=nil;[self.audioSessionsetMode:AVAudioSessionModeMoviePlaybackerror:&modeError];if(modeError!=nil){NSLog(@"ErrorsettingmodeforAVAudioSession:%@",modeError);

iOS - AVAudioPlayer 在后台时不会继续播放下一首歌曲

所以我有一个应用可以播放一堆歌曲,同时用户可以翻阅漫画书。我使用AVAudioPlayer并将其设置为按设定顺序播放歌曲。因此,当一首歌曲结束时,将播放下一首歌曲。当应用程序打开时,这可以完美运行。当应用程序处于后台时会出现问题。我将应用设置为在后台播放,效果很好。因此,当用户按下主屏幕时,音乐会继续播放。当歌曲结束时出现问题,假设像打开应用程序时一样播放下一首歌曲。相反什么也没有发生。根据我的NSLog语句,正在调用正确的方法但没有任何反应。这是我的代码:-(void)audioPlayerDidFinishPlaying:(AVAudioPlayer*)playersuccessf

iOS - AVAudioPlayer 在后台时不会继续播放下一首歌曲

所以我有一个应用可以播放一堆歌曲,同时用户可以翻阅漫画书。我使用AVAudioPlayer并将其设置为按设定顺序播放歌曲。因此,当一首歌曲结束时,将播放下一首歌曲。当应用程序打开时,这可以完美运行。当应用程序处于后台时会出现问题。我将应用设置为在后台播放,效果很好。因此,当用户按下主屏幕时,音乐会继续播放。当歌曲结束时出现问题,假设像打开应用程序时一样播放下一首歌曲。相反什么也没有发生。根据我的NSLog语句,正在调用正确的方法但没有任何反应。这是我的代码:-(void)audioPlayerDidFinishPlaying:(AVAudioPlayer*)playersuccessf

ios - 后台播放音乐 : AVAudioSessionInterruptionNotification not fired

我的应用在后台运行良好。暂停和播放也运行良好,即使我的应用在后台使用为AVAudioSessionInterruptionNotification注册的方法。问题到达场景的步骤:启动我的应用程序->从我的应用程序开始播放背景音乐启动苹果的音乐应用程序并播放。AVAudioSessionInterruptionNotification已触发。当我暂停音乐应用程序或终止音乐应用程序时。AVAudioSessionInterruptionNotification不会被触发代码:我在appdelegate中这样做。didfinishlaunchingNSError*sessionError=n

ios - 后台播放音乐 : AVAudioSessionInterruptionNotification not fired

我的应用在后台运行良好。暂停和播放也运行良好,即使我的应用在后台使用为AVAudioSessionInterruptionNotification注册的方法。问题到达场景的步骤:启动我的应用程序->从我的应用程序开始播放背景音乐启动苹果的音乐应用程序并播放。AVAudioSessionInterruptionNotification已触发。当我暂停音乐应用程序或终止音乐应用程序时。AVAudioSessionInterruptionNotification不会被触发代码:我在appdelegate中这样做。didfinishlaunchingNSError*sessionError=n

ios - 在 iOS 9 上以静音模式播放声音

在iOS9(Xcode7、Swift2.0)中,我尝试使用以下代码在静音模式下播放声音:try!AVAudioSession.sharedInstance().setCategory(AVAudioSessionCategoryPlayback,withOptions:.MixWithOthers)try!AVAudioSession.sharedInstance().setActive(true)AudioServicesPlayAlertSound(1005)根据其他答案和Apple的文档,我认为这应该可行,但在静音模式下它不会在iOS9上播放声音。它确实在不处于静音模式时播放它。

ios - 在 iOS 9 上以静音模式播放声音

在iOS9(Xcode7、Swift2.0)中,我尝试使用以下代码在静音模式下播放声音:try!AVAudioSession.sharedInstance().setCategory(AVAudioSessionCategoryPlayback,withOptions:.MixWithOthers)try!AVAudioSession.sharedInstance().setActive(true)AudioServicesPlayAlertSound(1005)根据其他答案和Apple的文档,我认为这应该可行,但在静音模式下它不会在iOS9上播放声音。它确实在不处于静音模式时播放它。

iOS - 后台 AVAudioSession 路由更改通知

尽管有很多关于该主题的帖子(AVPlayer&AVAudioSession、SettingtheAVAudioSessioncategoryinAppDelegate.m、AvAudioSessionwon'tworkiniOS7?),但我无法在iOS7中解决这个特定问题:-我想在后台接收AVAudioSession路由更改通知-我的应用程序在任何时候都不播放任何音乐,并且不应干扰其他应用程序播放声音设置:-在p-listUIBackgroundModes中启用音频-在主Controller中://AUDIOAVAudioSession*audioSession=[AVAudioSes