How to use driver.stopScreenRecording from ITestResult using TestNG

I am using appium to record screen of iOS simulator only on failure. I was to do this as part of ITestResult.

How can i use the driver from Test class to use in Listener class?

found the solution:
steps:

In the listener: Create the driver
In the listener: Push the driver into the ITestContext
In the test class: Take the driver from the ITestContext and use it
In the listener: Close the browser/driver