Even after making it global, the API controls don't work, only the iframe player control works.
I figured it out by making the JS - import for events instead of main and modified the code to intialize at layout startup and cleanup on layout end. Works as intended.