shaka-project / shaka-player-embedded

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

Can not call load with start time #57

Open Megubit opened 4 years ago

Megubit commented 4 years ago

If I understand correctly, ShakaPlayerClient onPlayerError is optional, and it will be called if there is no andBlock given to the player load.

If there is no andBlock: [self.player load:self.assetURI withStartTime:startTime]; xCode gives an error No visible @interface for 'ShakaPlayerView' declares the selector 'load:withStartTime:' That's from the sample project, and in this case the andBlock is mandatory, which means the optional onPlayerError will never be called as we have to give the callback.

Now I'm not sure what's the difference in the way I'm doing the implementation (maybe because of Qt), as I'm making it based on the sample project, but in my code it generates a warning [self.player load:url withStartTime:startTime ]; Instance method '-load:withStartTime:' not found (return type defaults to 'id') and it let's me compile and run it. Causing an error will trigger the onPlayerError as expected, with the correct response. However, the stream will always be set to the end, even if startTime is set to 0.

Calling it like this [self.player load:url ]; will also trigger a warning Instance method '-load:' not found (return type defaults to 'id') but the stream will start from the beginning.

TheModMaker commented 4 years ago

That is slightly incorrect. The onPlayerError is called for non-Promise errors. The load, unload, etc methods have to pass the block, which acts like the Promise in JavaScript. Once the block is called, the Promise is resolved. The onPlayerError is called for asynchronous errors, like decoding errors. The block is given errors from the Promise like HTTP_ERROR from the manifest.

Megubit commented 4 years ago

I must have understood it wrong then. Got confused with the weird way it worked for me. I thought the andBlock was optional based on the description of onPlayerError.

So, every time I play a different stream, I have to set the andBlock, maybe it would be better if the errors are always caught by onPlayerError. In my opinion, it seems unnecessary to always set andBlock when switching streams, since the error handling should be the same throughout the life cycle of the app.