What external sensor could detect if a cd-tray had opened?
Use a permanent magnet and a reed switch. 

Fix the magnet on the moving part and put the reed switch on the fixed part. Then monitor the reed switch with the microcontroller.