shaka-project / shaka-player-embedded

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

Offline track selection #166

Open OmarPedraza opened 3 years ago

OmarPedraza commented 3 years ago

Hello, Following the documentation for JavaScript, I'm trying to select for download the desired track depending on its bandwidth.

I've tried with the following code:

player?.configure("offline.trackSelectionCallback", with: "selectTrack")

    @objc func selectTrack(_ tracks: Any) {
        print(tracks)
    }

But ShakaPlayer object returns the following error:

[Error]: "Invalid config, wrong type for .offline.trackSelectionCallback"

Due to that, I tried with several changes in the configuration:

player?.configure("offline.trackSelectionCallback", with: "selectTrack()") player?.configure("offline.trackSelectionCallback", with: "selectTrack(_:)") player?.configure("offline.trackSelectionCallback", with: "selectTrack(:)")

Am I doing anything wrong? Is track selection not yet available for iOS?

TheModMaker commented 3 years ago

Embedded doesn't support the track-selection callback. In general, the configure method can only accept strings and numbers, not functions. And passing some selector won't work since the value is just forwarded to JavaScript. We could add this callback to the ShakaPlayerStorageClient object like the progress callback.

OmarPedraza commented 3 years ago

Thanks @TheModMaker, that would be awesome!

Any ETA about when it would be available?