In vlc, go to the Preferences
(CTRL+P) screen, then on the left there is a button named Interface
which shows a Look and feel
group of options, containing a checkbox Pause playback when minimized
: check it!
It will automatically play/pause when you switch from/to the workspace. Better, if you have a dual screen, even if you work on the other screen it will continue to play the video until you switch the workspace where vlc is.
In other words, it will play the video only when vlc is visible, as soon as vlc is hidden the video is paused.