Events & Listeners Basics - Storm Android Player

Storm Android Player utilizes the classic Java event-listener model for API communication.

Attaching an Event Listener

Attaching an event listener is a straightforward task

                        
StormPlayerView stormPlayerView = findViewById(R.id.stormPlayerView);
stormPlayerView.setStormLibrary(stormLibrary);


stormPlayerView.addEventListener(new StormPlayerView.EventListener(){
    @Override
    public void onPlayClicked() {

    }
});
                    

We can listen to more than one event at a time.

                        
stormPlayerView.addEventListener(new StormPlayerView.EventListener(){
    @Override
    public void onPlayClicked() {

    }

    @Override
    public void onPauseClicked() {

    }

    @Override
    public void onEnterFullscreenClicked() {

    }

    @Override
    public void onExitFullscreenClicked() {

    }

    @Override
    public void onVideoClicked() {

    }
});
                    

A full list of library events can be found here.

Detaching an Event Listener

In order to detach (remove) an event listener just use:

                        
stormPlayerView.removeEventListener(listenerObject);
                    
Next Step

In the next step you'll learn more about available events in Player Events guide.

Support Needed?

Create a free ticket and our support team will provide you necessary assistance.