I do it all the time on my commute, in a city were I've lived for years. When I started biking I swore it off for safety, but after a few weeks I became knowledgeable of the roads and started to listen to music. I noticed I relied more on my sight than hearing. As a result, I have a habit of periodically looking over my shoulder, which has probably preventing many accidents. 1/3rd of my daily commute is above 20mph, where my hearing is pretty drowned out from wind anyway.
Technically, its
illegal in my state (NY) to have both ears listening to music while bicycling. But cops in my city don't really care and I consider it fairly safe.