Well, at least here in Finland it is legal but have never seen anyone do it. That would totally stupid and dangerous as well. Personally I don't really even see the point in it as listening to music is a method of relaxing for me..
We do have a law against speaking on the phone while driving though (speaking itself is allowed but you have to use a hands-free set while driving).
I fail to see how it's any worse than using the car radio but in the Uk there are a few catch all laws to look out for that the police can use if they don't like you. Firstly breach of the peace.. this can be virtualy anything and secondly dangerous driving. So if a police officer is having a bad day you could be caught under the second one. People have been fined for things as silly as eating a polo in a stationary traffic que so it's best not to risk it.
Even if it's not illegal, it's a very bad idea. Especially if you're wearing good isolating cans or IEMs. You wouldn't be able to hear what's going on around you plus it could be distracting if you get "in your own world" with a song.
The same topic came up a fews days ago w/ someone looking for iems for motor bike. Again, not a good idea. When driving/riding you need your senses 100%.