Unfortunately this is most often a hardware failure (bad motor, worn gear, loose belt, etc in the ejection mechanism, faulty switch or sensor, or just an obstruction by a disc that is out of place)
There are a few things you can try:
First unplug power for at least an hour, then press and hold the power/on button while plugging back in, and keep holding for another 60 seconds. If it still doesn't open/close, repeat the process but with the eject button instead of power.
If it still does not open/close, pick the unit up and shake/tilt the player side to side gently, hopefully dislodging any debris stuck inside that could be preventing it from moving, then try to open/close again.
If none of these help, then there is an internal hardware defect, which will need to be repaired.
If it gets to that point, I can advise you on service options.