Maybe some kind of sync issue, again a hardware issue on the burner.
And, pre-recorded (commercial) CDs use other encoding protocols, not present on your own burned disks, that your burner may simple ignore, where your own CDs won't play.
Another tip that you could try would be to boot to your previous system (whatever that was) on your problem iMac, just to see if your music CDs still play (or not) on that same hardware, under your previous system. Maybe you still have a bootable backup on an external from your previous system.
[doublepost=1529286819][/doublepost]As stupid as it sounds - going to go with the "get a cleaning disk" and clean the drive lens. If you want to go cheap, do the lens cleaning cloth wrapped over business card concept for a slot loading drive.
Granted, new on this board - joined just for the purpose of posting this response, and I was as much a skeptic as anyone reading about the same problems in various Mac forums. Here's what happened today.
I have been having the same basic symptoms with my MacMini (Early 2009)'s drive...would read real CD's DVDs, wouldn't burn for crap anymore, and would register a burnt and functioning in other devices CD-R/RW or DVD-R/RW as an empty disk. Every disk tried works on an Apple external drive attached to my MBP or Mini and in a generic DVD R/RW I have in a home built box. Tons of Mac forum posts point to drive failure, firmware, etc., and a large percentage of them attach the change trigger from working to not working to the point of an OS X upgrade.
But a number of them also describe trying to clean the drive lens, some few with a cleaning disk but mostly with a lens cleaning cloth wrapped around a business card and worked back and forth in the slot. Those posts claim magic. I remained skeptical, and I wasn't quite ready to try that (aside from the fact that the only lens cleaning cloth i had was well worn past its time). So instead I packed up and went to my local Best Buy where I confirmed they had a cleaning disk for about $12 (online inventory chess are a good thing). It was the "Insignia" brand, which is the Best Buy store brand of stuff. Could have gone the Amazon route (Prime rocks) but wanted to try today (Sunday) as opposed to Tuesday.
I have never cleaned a CD/DVD device in my life, whether standalone music/movie player device or a computer attached device. Typically when non-functioning there is a tray grinding, or lens positioning grinding such that you know the drive is done. Then again - never had this problem either. Had been going on for a while, but I figured the drive was winding to end of life and I used it for what I knew still worked. Today I just got fed up with it's silliness and I needed a disk to work in the Mini, so I explored options.
So the cleaning disk has about 10 tiny brushes located in strategic spots embedded in the working side of the disk. The instructions indicated that it would have audio on the disk for what to do - and examining the working side of the disk yeah it looked as if there were audio tracks recorded there. So loaded it up. Nothing - after 30-45 seconds, the disk ejected. Finder never blinked. I tried again - why not.
This time it loaded into iTunes, registered, and showed 15 tracks. Played the "English" track, and followed the instructions. After ejecting it I checked the working side. Just after three of the brushes there were now heavy smudge marks, like grease or finger print residue but only directly after the brushes as if the brushes kinda sprayed it onto the disk after wiping it off somewhere else.
Loaded up a burned disk that only 2 hours early loaded as an "empty" disk, with Finder prompting me what I'd like to do. This time it mounts to my system and I can browse the files I knew were on it. Everything was perfectly accessible.
Loaded up 4 more disks that had issues in the past - all previously burnt that came up as empty. All now working perfectly.
Considering an OS X update as a trigger, each update could have firmware updates as well. And conceivably a different firmware might react differently to the signals from the laser if they aren't perfect - such as if the lens is dirty.
As I said - sounds like snake oil, and such was my expectation, but there you go. Because there are so many of these threads out there on this topic, after my experience I found the most recent one I could and decided to add my $.02 from my personal experience. Your mileage may vary.
Mine is a (used, eBay) Mac Mini (Early 2009), El Capitan 10.11.6, with 8GB RAM and 256GB SSD as post purchase upgrades.