Detect headphone buttons

Hello, I need to somehow detect headphone button events on IOS and ANDROID, like volume up / down, play/pause.

if there are some package or solution to do this ?

I don’t want play music or something just want to detect when headphone volume buttons clicked or play/pause.