# Listening to player events You can listen to various playback and player related events directly with the API. ## Obtain API handle To use the API, you need to have a handle to the `FlowplayerView` that implements the `Flowplayer` interface. Refer to [the player initialization documentation](/docs/wowza-flowplayer/android-sdk/legacy/create-instance/#add-a-player-to-an-activity) on how to create a player instance. ## Create event listener To make your player listen to playback/player events, you need to create a class that will implement the `EventListener` interface of the respective event. Then you create an instance of this class and pass it to the player: ```js flowplayerView.addEventListener(new MyEventListener()) ``` Available events and their listener interfaces: * `AdBreakCompleteEvent` - `OnAdBreakCompleteListener` * `AdBreakStartEvent` - `OnAdBreakStartListener` * `AdClickEvent`- `OnAdClickListener` * `AdCompleteEvent` - `OnAdCompleteListener` * `AdErrorEvent`- `OnAdErrorListener` * `AdPauseEvent`- `OnAdPauseListener` * `AdResumeEvent`- `OnAdResumeListener` * `AdSkipEvent` - `OnAdSkipListener` * `AdStartEvent` - `OnAdStartListener` * `BufferEvent` - `OnBufferListener` * `CompletEvent`- `OnCompleteListener` * `ErrorEvent` - `OnErrorListener` * `FullscreenEvent`- `OnFullscreenListener` * `IdleEvent`- `OnIdleListener` * `MuteEvent`- `OnMuteListener` * `PauseEvent` - `OnPauseListener` * `PlayEvent`- `OnPlayListener` * `SpeedEvent` - `OnSpeedListener` * `VolumeEvent` - `OnVolumeListener` Refer to the [API documentation](https://docs.flowplayer.com/user/static/sdks/android/api/javadoc/index.html) for a full reference. ## Example: looping player In this example we are [inheriting our Activity from FlowplayerFragment](/docs/wowza-flowplayer/android-sdk/legacy/create-instance/#option-2-add-flowplayerfragment-or-flowplayersupportfragment). The activity will then listen to the `OnCompleteEvent` and seek the player back to the beginning of the video and resume playback. ```js class MyActivity : FlowplayerFragment, OnCompleteListener { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) // Obtain playerFragment (from XML or programmatically) // Check the "Creating player instance documentation" for more information getPlayerFragment().getPlayer().addEventListener(this) } override fun onComplete(event: CompleteEvent) { // We want to listen to the complete event and seek to beginning to loop the content val player = getPlayerFragment().getPlayer() player.seek(0) // Seek to beginning player.play() // Resume playback } } ```