
// Create an AVURLAsset with an NSURL containing the path to the vIDeoAVURLAsset *asset = [AVURLAsset URLAssetWithURL:[NSURL URLWithString:_mp4] options:nil];// Create an AVPlayerItem using the assetAVPlayerItem *item = [AVPlayerItem playerItemWithAsset:asset];_player = [AVPlayer playerWithPlayerItem:item]; //if this line is commented out,I hear audio,else audio from Spotify is quickly killed...
由于这些视频只是gif,我想知道是否有一些方法取消分配音频会话.我不太了解这个.请帮助!
解决方法 结果答案很简单,经过一番谷歌搜索和文档阅读后…解决方案是
// audio sessionlet audioSession = AVAudioSession.sharedInstance()try! audioSession.setcategory(AVAudioSessioncategoryAmbIEnt,withOptions: AVAudioSessioncategoryOptions.MixWithOthers)
哎呀,只是意识到我在objC发布我的问题,并在Swift回答.很好,因为那是有时候的生活.
AudioSession是整个应用程序的单例,用于规划应用程序如何与系统和其他应用程序的其他声音混合!默认音频会话是
>播放启用,录制被禁用
>当用户将静音开关移到“静音”时,您的音频被静音
>当用户按睡眠/唤醒按钮锁定屏幕或自动锁定期限到期时,您的音频被静音
>当您的音频启动时,设备上的其他音频(音乐)将被静音.
categoryAmbIEnt告诉它不要做4
很好的文档!
https://developer.apple.com/library/ios/documentation/Audio/Conceptual/AudioSessionProgrammingGuide/ConfiguringanAudioSession/ConfiguringanAudioSession.html#//apple_ref/doc/uid/TP40007875-CH2-SW1
以上是内存溢出为你收集整理的ios – AVPlayer删除背景音乐全部内容,希望文章能够帮你解决ios – AVPlayer删除背景音乐所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)