This has been asked quite a few times. Unfortunately I don’t have a great answer because I have never really tried doing this myself. My best guess is to do something like this:
This however assumes that the audio equipment filters out frequencies over 100kHz. Without that filter it’s always going to sound awful. A simple RC filter could be added to the above circuit to fix the output though. I’m not very good at designing analog circuitry, so I would probably get it wrong if I tried.
Of course, if you can use SPDIF instead, I highly recommend it.
One other option is to buy things that already do this. A combination of a ground-loop isolator and an in-line volume adjuster should work for almost anything. There are also things you can buy which take a speaker channel as input and produce line-level outputs. (Usually meant for when you want to install an amplifier in your car, but your car stereo doesn’t have a line out.)