Unfortunately if the application is pushed to the background the screen still appears to lock for me.
I've tried that method and related, but its hit-and-miss for detecting whether something is playing or paused. I'm currently using pidof alone just to find out if my player (mortplayer) is running, and I simply trigger a pause if it is and a toggle pause after i'm done to resume.
Using power amp or phantom control would work better but both cost some cash...