Android SDK (Core)
...
Integrate External Player
Integrating ExoPlayer
Migration Guide: Updating Your Codebase
7 min
the external exoplayer is now deprecated we strongly encourage you to switch to our custom player, nwplayer please consult the migration section for detailed instructions on how to migrate from external exoplayer to nwplayer we continuously strive to improve the developer experience and ensure our sdk remains flexible, efficient, and easy to integrate we have updated the mechanism for integrating your custom exoplayer instance as part of this effort previously, we used a channel to handle the communication between your application and the sdk now, we have transitioned to using completabledeferred , which offers a simpler and more robust solution for this use case migration steps if you are currently using the channel based approach, here is how to migrate to the new completabledeferred implementation old implementation (using channel ) expplayback expinitializeplayer collect { responsechannel > responsechannel trysend(generateexoplayer()) responsechannel close() } new implementation (using completabledeferred ) expplayback expinitializeplayer collect { deferred > deferred complete(generateexoplayer()) } below, we will explain why this change was made, how it benefits you, and how to migrate your existing implementation why completabledeferred is better than channel when dealing with a single object (like an exoplayer instance) that needs to be passed temporarily between your code and the sdk, completabledeferred is a more suitable choice than channel here’s why purpose channel designed to stream multiple values over time completabledeferred designed for a single value that needs to be produced asynchronously complexity channel requires explicit closing after sending the value ( close() ) completabledeferred automatically resolves after a single value is provided ( complete() ) resource management channel needs to be manually closed to avoid resource leaks completabledeferred no need for manual cleanup; it’s a lightweight, one time operation error handling channel errors must be handled explicitly (e g , trysend and checking for failures) completabledeferred errors are simpler to handle via the complete function’s return value use case fit channel overkill for single value communication completabledeferred perfectly suited for single value, one time communication benefits of using completabledeferred simplicity completabledeferred is designed for one time communication, making it easier to use and understand no need to manage the lifecycle of a channel (e g , opening, closing, or handling backpressure) safety it ensures that only one value is sent, eliminating the risk of accidentally sending multiple values or forgetting to close the channel the complete function provides a clear success/failure indication, making error handling straightforward performance completabledeferred is lightweight and optimized for single value communication, reducing unnecessary overhead key changes replace channel with completabledeferred use deferred complete() instead of responsechannel trysend() remove the need to close the channel manually ( responsechannel close() ) optionally, add logging to track success or failure why this change matters by migrating to completabledeferred , we have streamlined the integration process, making it easier for you to inject your custom exoplayer instance into the sdk this change reduces boilerplate code, minimizes the risk of errors, and ensures a more efficient communication mechanism