Accessing URL from AVPlayer object?

后端 未结 4 1612
独厮守ぢ
独厮守ぢ 2020-12-28 11:49

Is there a way to access the URL from an AVPlayer object that has been initialized with a URL, as in:

NSURL *url = [NSURL URLWithString: @\"http://www.exampl         


        
4条回答
  •  一个人的身影
    2020-12-28 12:21

    Solution for Swift 3

    func getVideoUrl() -> URL? {
        let asset = self.player?.currentItem?.asset
        if asset == nil {
            return nil
        }
        if let urlAsset = asset as? AVURLAsset {
            return urlAsset.url
        }
        return nil
    }
    

提交回复
热议问题