It sounds more like the charger is going bad. It is extremely common for them to not charge while the device is on, and only when it is off, when the charger is starting to go. It is because they are not putting out enough power to both run it and charge the battery. So I would start there and replace the charger.