AVPlayer:无法播放()一个mpg视频

时间:2015-05-22 02:02:13

标签: swift avplayer

以下简单类不播放视频网址。我得到的是一个黑色的空屏幕。为什么?

import Foundation
import AVKit
import AVFoundation

class EditShowVideoViewController:AVPlayerViewController {
        override func viewDidLoad() {
            var error: NSError?
            if let urlString = gBlissMedium!.mediumURL {
                let url = NSURL(string: urlString)
                player = AVPlayer(URL:url)
            }
        }

        override func viewDidAppear(animated: Bool) {
            player.play()
        }
        override func supportedInterfaceOrientations() -> Int {
            return Int(UIInterfaceOrientationMask.AllButUpsideDown.rawValue)
        }

        override func prefersStatusBarHidden() -> Bool {
            return true
        }
    }  
  

(lldb)po urlString   “http://files.parsetfss.com/6b8388b7-14c6-431a-a795-2b33f9d47081/tfss-56cf2c67-111c-4724-8e63-3755fe1b85f7-hst_1.mpg

1 个答案:

答案 0 :(得分:1)

if let urlString = gBlissMedium!.mediumURL {
                let url = NSURL(string: urlString)
                player = AVPlayer(URL:url)
}

此处playerviewDidLoad本地定义,它应该是类的实例变量