Is it possible to play music in the cockpit?
Depending on the equipment in the aircraft, the answer may very well be yes. A lot of modern headsets in civilian aircraft (particularly those with active noise reduction) have bluetooth capability that allows music streaming. Some more modern audio panels even have music inputs now. I even flew in an Archer that had a CD player on the panel and wired into the audio panel.  

If you are lucky enough to have an automatic direction finder (ADF) eating up useful load in your aircraft you may be able to tune into AM radio stations. This may have contributed to the crash of Varig Flight 254. 

While you are legally allowed to do this (at least in small planes) the sterile cockpit rules that most if not all air carriers have prevent professional pilots from doing so, as @Carlo Felicione points out in the comments