box / box-ios-sdk

iOS SDK for the Box Content API
https://developer.box.com
Apache License 2.0
122 stars 113 forks source link

how to get streaming video URL from Box via ios BoxSDK 5.6.0 #929

Closed PJStation closed 3 months ago

PJStation commented 3 months ago

how to get streaming video URL from Box via ios BoxSDK 5.6.0

mwwoda commented 3 months ago

Hi @PJStation If you want to get URL and e.g. embed it on your page you can use getEmbedLink function. Alternatively, you could look into shared links if they fit your use case.

PJStation commented 3 months ago

Hi @PJStation If you want to get URL and e.g. embed it on your page you can use getEmbedLink function. Alternatively, you could look into shared links if they fit your use case.

getEmbedLink Link cannot be played shared links rerturn failure

mwwoda commented 3 months ago

Could you provide more details about what you are trying to achieve? Perhaps you could also provide an sample code (example project) so we can see what's the issue.

PJStation commented 3 months ago

Could you provide more details about what you are trying to achieve? Perhaps you could also provide an sample code (example project) so we can see what's the issue.

//get a mp4 file
client.files.getEmbedLink(forFile: file.id) { result in
    switch result {
    case let .success(expiringEmbedLink):
        var options = [String : Any]()
        options["AVURLAssetHTTPHeaderFieldsKey"] = ["Authorization": "Bearer \(expiringEmbedLink.token!.accessToken!)"]
        let asset = AVURLAsset(url: expiringEmbedLink.url!,options: options)

        if asset.isPlayable {
            print("isPlayable")
        } else {
            print("not playable")
        }

        break
    case let .failure(error):
        break
    }

}

isPlayable always false

congminh1254 commented 3 months ago

Hi @PJStation

Can you try with this url scheme: https://api.box.com/2.0/files/:file_id:/content and attach with your access token in the header.

image

Let me know if it's working.

Best, Minh

PJStation commented 3 months ago

https://api.box.com/2.0/files/:file_id:/content Thanks,it's working!