shaka-project / shaka-player-embedded

Shaka Player in a C++ Framework
Apache License 2.0
238 stars 63 forks source link

Must call setClient to initialize the object #61

Closed muganda closed 4 years ago

muganda commented 4 years ago

I am having trouble integrating the player into my project. override func viewWillAppear(_ animated: Bool) { super.viewWillAppear(animated) // Make a Shaka Player view. let player = ShakaPlayerView() player.frame = self.view.bounds self.view.addSubview(player) player.load("https://storage.googleapis.com/shaka-demo-assets/angel-one/dash.mpd", with: { (error: ShakaPlayerError?) in if (error != nil) { print(error?.message) } }) player.play() }

Here is my trace log. Terminating app due to uncaught exception 'NSGenericException', reason: 'Must call setClient to initialize the object' *** First throw call stack: ( 0 CoreFoundation 0x000000010b27b6fb __exceptionPreprocess + 331 1 libobjc.A.dylib 0x000000010a3ecac5 objc_exception_throw + 48 2 CoreFoundation 0x000000010b27b555 +[NSException raise:format:] + 197 3 ShakaPlayerEmbedded 0x0000000108e427e8 -[ShakaPlayerView checkInitialized] + 104 4 ShakaPlayerEmbedded 0x0000000108e46fdf -[ShakaPlayerView load:withStartTime:andBlock:] + 111

What could I be doing wrong?

TheModMaker commented 4 years ago

You need to call player.setClient(client) or use one of the withClient versions of init. Because there can be errors thrown during initialization, we now wait to initialize the object until we have a client object so the app can see the errors that are thrown. So you need to give us a client object before we will initialize it. You can pass nil if you really want to ignore errors, but it is suggested to pass an object. We still have the old init methods to support loading from Storyboards or other frameworks (since the UIView has those init methods). I still need to update the tutorial and regenerate the docs.

muganda commented 4 years ago

This actually works. Many thanks for the tip.