【问题标题】:How to reduce Energy Impact in this Streaming Code如何减少此流代码中的能量影响
【发布时间】: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


    【解决方案1】:

    Apple 不会拒绝它。 AVPlayer 正在管理缓冲和缓存以重用您的流数据。

    【讨论】:

    • 感谢您的重播,您确定吗?
    • 是的,我过去制作了一些有声读物应用程序。但是我们正在处理缓冲时间并处理网络丢失情况。所以做那一些必要的事情,苹果不会拒绝它。
    猜你喜欢
    • 2020-02-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-03-19
    • 1970-01-01
    • 2012-12-18
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多