从json抓取一个URL并播放视频。 (SWIFT / tvos)

时间:2017-03-08 09:42:01

标签: json swift parsing tvos

我想在我的URL文件中抓取一个JSON,我已成功完成并正确解析它。

我无法让AVPlayer来处理解析网址,任何帮助都会感激不尽!谢谢!

import UIKit
import AVKit

class TrailerVC: UIViewController {

//calling var from different cell where it has the data    
var film: FilmCell! 

//film.filmvideoFile stores the url.

    override func viewDidLoad() {
        super.viewDidLoad()

        let videoURL = URL(string: "\(film.filmvideoFile)" )
        let player = AVPlayer(url: videoURL!)
        let playerLayer = AVPlayerLayer(player: player)
        playerLayer.frame = view.bounds
        view.layer.addSublayer(playerLayer)
        player.play()
    }

}

0 个答案:

没有答案