I successfully enabled my app to be able to play audio and video in background after the screen is locked. However, for better user experience I want to show play and pause
I found the answer to my question. I need to implement the code in my question in AppDelegate to receive events instead of implementing in ViewController.