当视频使用AVPLayer播放时,它将停止背景音乐ios [英] When Video plays using AVPLayer, it stops background music ios

查看:76
本文介绍了当视频使用AVPLayer播放时,它将停止背景音乐ios的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用AVPlayer播放视频,它停止了正在后台播放的iPhone音乐.请帮助我解决

I am playing video using AVPlayer, it stops iPhone's music which is on going in background. Please help me to resolve

let item1 = AVPlayerItem.init(URL: NSURL(string:path))
player = AVPlayer(playerItem: item1)
layer?.player = player;
player?.play()

推荐答案

我的电影是动画;他们没有声音.要让其他声音继续播放,请在Swift中:

My movies are for animations; they have no sound. To let other sound continue playing, in Swift:

    // None of our movies should interrupt system music playback.
    _ = try? AVAudioSession.sharedInstance().setCategory(AVAudioSession.Category.playback, mode: .default, options: .mixWithOthers)

感谢马库斯·亚当斯(Marcus Adams)的原始答案.

Thanks to Marcus Adams for the original answer.

这篇关于当视频使用AVPLayer播放时,它将停止背景音乐ios的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆