如果设备自动睡眠/自动锁定,有没有办法让Airplay继续运行? [英] Is there a way to keep Airplay running if the device auto-sleeps/auto-locks?

查看:177
本文介绍了如果设备自动睡眠/自动锁定,有没有办法让Airplay继续运行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当通过Airplay将视频从iPhone(或任何iOS设备)流式传输到电视时,只要设备因不活动而进入睡眠状态,流就会停止。目前,我禁用了睡眠定时器,以便设备不会自动睡眠,但有更好的解决方案吗?

When streaming a video from an iPhone (or any iOS device) to a TV via Airplay, the stream stops as soon as the device goes to sleep from inactivity. At the moment, I disabled the sleep timer so that the device does not automatically sleep, but is there a better solution to this?

设置 AVPlayer.externalPlaybackActive 足以让操作系统知道在屏幕关闭时继续播放?如果没有,即使设备关闭其屏幕,还有另一种方法可以保持Airplay运行吗?

Is setting AVPlayer.externalPlaybackActive enough to allow the OS to know to keep playing when the screen is off? If not, is there an alternate way to keep Airplay running even if the device turns off its screen?

推荐答案

继续播放播放,将应用播放音频添加到 AppName-info.plist

To continue airplay playback, add "App plays audio" to the "Required background modes" in the AppName-info.plist

并将音频会话设置为:

    [[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback error:nil];
[[AVAudioSession sharedInstance] setActive: YES error: nil];

这篇关于如果设备自动睡眠/自动锁定,有没有办法让Airplay继续运行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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