Fixing sound loss problem with youtube on ubuntu

I got this info from this website: http://www.ivankristianto.com/os/ubuntu/tips-solving-ubuntu-sound-problem-without-restart/440/

Here are the condensed steps.
1. Open your shell and find all process that currently using sound with this command:
lsof | grep pcm

2. After you get all proceess with the proceess id, kill all that process with this command:
kill -9

3. Restart ALSA (Advanced Linux Sound Architecture) driver with this command:
sudo /etc/init.d/alsa-utils restart

I think this could be automated into a single script with one command.