Why does audio stop playing when switching to a virtual terminal?

Solution 1:

Not using Ubuntu, I'm using Fedora but pretty sure the same will work on Ubuntu.

cd /dev/snd
chmod o+rw *

But try first to add the user you log in as to the group audio.

I seem to remember that there are some files or processes that change group ID when you switch virtual consoles.

Solution 2:

Try

usermod -a -G audio youruser

From: https://www.reddit.com/r/linux/comments/1ckvhd/keeping_music_playing_across_multiple_terminal/

Or see: https://unix.stackexchange.com/questions/211885/switching-between-shells-stops-the-music-that-is-currently-playing/550547