I'm having a sound problem

While listening to any video or something, the sound suddenly goes away. The sound comes back when I wait for a while and restart, or when I take it to the lock screen and log back in, the sound comes back. How can I solve this? Also, this problem doesn’t happen when I’m using Windows.