I bought a stand-alone CD player with a motorized tray that stopped working after a couple of years. I also had a boombox (portable stereo) with a CD tray with a lid that you could raise and lower with your hand. That had no mechanical problems, but after a while the laser stopped reading the CD. I'm wondering what's better when it comes to quality? What should I look for when I search for a new CD player if the most important thing to me is that it lasts a long time before breaking?
There are no rules to follow when buying for longevity in a CD player. To begin with, longevity is not what CD players are all about. They are still, even thirty years after their introdcuction, being altered and refined. There's no market for the new if the old continues to work.
A cheap player will have cheap parts and will be designed to work within the limits of those cheap parts. That means more error correction will be included in the systems. While error correction makes a player more amenable to playing dics with scratches and dirt or while bouncing along on your hip at the gym, error correction also makes for far less sound quality. But, you might say, it is designed to a less restrictive quality of service and, therefore, will be more capable of making the most of the worst situation. The chances it will play a disc that can't be read by a higher quality machine operating to tighter tolerances of acceptable performance are generally pretty good. That said, eventually parts wear out and less restrictive tolerances can easily translate into there is lots of slop in the mechanics and electronics of cheap audio gear.
Higher quality players will operate at those tighter tolerances but will eventually suffer from any deviation from those tolerances. While you'll enjoy better sound quality during the duration of its playable lifetime, a higher quality player might give up on reading discs sooner than a cheaper player would.
Then there are the very much higher quality players which are composed of parts which are meant to perform well and last for a reasonable amount of time while doing far above yoeman's work. Most respectable dealers will have access to and might even have stock to demonstrate if you inquire about such players. But don't be surprised if the dealer first asks to see your credit card account balance before proceeding.
What normally wears out on a player will be the transport. At this time and due to the switch to DVD and BluRay players, there are only a few mid priced transports being made available to all CD player manufacturers. They choose which transport suits their needs and budget and go with a particular unit as an OEM part. You'll find the same basic transport in numerous models from various manufacturers of CD players. Only the very top lines will select the very top line transports and charge accordingly. You could, I suppose, do some research and determine which transports are being used in which players and then research the reliability and longevity of that transport. However, you should also recognize the fact that things break and parts which encounter friction will eventually wear out. That is reason enough for any manaufacturer, even those selling very high priced components, to have a service department. Here you might determine just how familiar you are with Mr. Murphy and his lousy law.
Finally, you should expect not much different from a digital player than you did from an analog source. If you bought a turntable and cartridge, sooner or later you would need to replace worn out parts. A significant difference in digital players is the technology has generally moved ahead in sufficient amounts to make repair of a five year old CD player not economically worthwhile. I suspect a repair center could replace the transport in your players and they would achieve a certain amount of longevity at the expense of repairs. Unfortunately, what most service techs will explain to you will be the rules of a disposable audio market where replacement is the more financially prudent choice. Our modern society throws away enormous amounts of electronic gear rather than repair it. It makes for cheap initial prices and a decimated Earth at the end of the unit's useable lifespan. If by "longevity" you might mean not throwing a component into the landfill, then I would suggest you explore either repairing the old unit or, at the very least, recycling the unit in a responsible manner.