【发布时间】:2017-07-22 07:18:19
【问题描述】:
大家好,我正在开发一个直播广播应用程序。一切都很好,但我注意到,能量影响非常高。当我尝试上传这个应用程序时,苹果会拒绝吗?我使用后台模式在后台播放歌曲
视图控制器
import UIKit
import AVFoundation
class ViewController: UIViewController {
var player: AVPlayer = AVPlayer(url: STREAMING_URL! as URL)
override func viewDidLoad() {
super.viewDidLoad()
do {
try AVAudioSession.sharedInstance().setCategory(AVAudioSessionCategoryPlayback)
print("AVAudioSession Category Playback OK")
do {
try AVAudioSession.sharedInstance().setActive(true)
print("AVAudioSession is Active")
} catch {
print("Active error \(error.localizedDescription)")
}
} catch {
print("Category error \(error.localizedDescription)")
}
}
//Play
@IBAction func playBtnTapped(_ sender: Any) {
player.play()
}
//Pause
@IBAction func pauseBtnTapped(_ sender: Any) {
player.pause()
}
能源影响
如何减少这种能源影响?
【问题讨论】:
标签: ios swift swift3 avfoundation