If you’re using an HDMI TV to display your Raspberry Pi or Raspberry Pi 2, you may have trouble with the audio playing through the TV.
This happens when the monitor is configured to send it’s audio through DMT mode instead of HDMI.
To force your Raspberry Pi audio through the HDMI TV audio, try running the following command(s).
Hit control + o to save the file and then control + x to exit.
Reboot your Raspberry Pi and try again to see if your audio now works via HDMI.
Further sources: