shaka-project / shaka-player-embedded

Shaka Player in a C++ Framework
Apache License 2.0
239 stars 62 forks source link

Get content size before starting download #167

Open OmarPedraza opened 3 years ago

OmarPedraza commented 3 years ago

Hi there, Another enhancement for ShakaPlayerStorageClient would be returning content size before starting the download for checking if device has enough space for it.

Are you already checking that internally?

I've tried to get the size by using this code but it returns different values during the whole download (tending to be more stable at the end).

extension DownloadManager: ShakaPlayerStorageClient {
    func onStorageProgress(_ progress: Double, with content: ShakaStoredContent) {
        print("size: \(content.size / progress)")
    }
}

Do you have any other idea before doing HEAD requests for getting file sizes?

TheModMaker commented 3 years ago

We don't have anything now; we just download it and hope it fits. This will be non-trivial to add since it will require big changes to Shaka Player. I've filed google/shaka-player#2900 to add the feature on that side. We can use byte ranges in the manifest to avoid HEAD requests; but if the manifest says whole segments, we'll need to make a HEAD request.