First try both a NVRAM/PRAM reset, then an SMC reset.
- Shut down your Mac.
- Locate the following keys on the keyboard: Command (⌘), Option, P, and R. You will need to hold these keys down simultaneously in step 4.
- Turn on the computer.
- Press and hold the Command-Option-P-R keys before the gray screen appears.
- Hold the keys down until the computer restarts and you hear the startup sound for the second time.
- Release the keys.
After resetting NVRAM or PRAM, you may need to reconfigure your settings for speaker volume, screen resolution, startup disk selection, and time zone information.
Resetting the SMC for Mac Pro, Intel-based iMac, Intel-based Mac mini, or Intel-based Xserve
- Shut down the computer.
- Unplug the computer's power cord.
- Wait fifteen seconds.
- Attach the computer's power cord.
- Wait five seconds, then press the power button to turn on the computer.
If this doesn't work,
Optical drives have two laser lenses. One for CDs and one for DVDs.
The DVD lens maybe dirty or dusty.
You can try a commercial retail dry brush CD/DVD lens cleaning disc.
This may revive the DVD read/write part of drive.
I no purchase method to clean out the optical drive is to take credit card wrapped in a micro fiber cleaning cloth, power down the iMac, and carefully run the cloth cover credit card carefully back and forth a couple of times in the optical disc slot the carefully pull out the credit card.
This may, also, revive the drive, too!