I have set up a testing script to play videos on VLC-3.0.12 (Manjaro) using crontab (cronie-1.5.7). The file in question looks like this:
#!/bin/bash
## YES, I'M RICKROLLING MYSELF FOR TESTING
[[ "$HOME" != "/home/drjeff16" ]] && exit 1
[[ -n "$(pgrep vlc)" ]] && exit 1
# SINCE CRON DOES NOT SET THE EXISTING X11 ENV VARS, SET THE DISPLAY MANUALLY
DISPLAY=:0.0
if [[ "$isCron" == "0" ]] ; then                                # IF RUNNING FROM REGULAR TERMINAL ENVIRONMENT
  echo '[[ -n "$(pgrep vlc)" ]] && killall vlc' | /usr/bin/at now + 5 minutes
  nhp vlc "$HOME"/Videos/Music/Never-Gonna-Give-You-Up.mp4      # 'nhp' IS 'nohup <command> &!' AS AN EXPORTED
                                                                # FUNCTION TO AVOID APPS HIJACKING MY TERMINAL
  exit 0
elif [[ "$isCron" == "1" ]] ; then                              # ELSE IF RUNNING FROM CRONTAB ($isCron IS 1 ON CRON ENV)
  echo '[[ -n "$(pgrep vlc)" ]] && killall vlc' | /usr/bin/at now + 5 minutes
  vlc "$HOME"/Videos/Music/Never-Gonna-Give-You-Up.mp4
  exit 0
fi
exit 1
Executing this script from my normal environment does not cause any issues. However, when running it from crontab, VLC does run and display video, but no audio comes out anywhere.
While reading the manual entry for VLC man vlc, I came across the $OSSAUDIO_DEV variable in the ENVIRONMENT VARIABLES section:
.
.
OSSAUDIO_DEV
              The default audio output device, used by the OSSv4 output plugin.
.
.
My question is whether I need to set the $OSSAUDIO_DEV variable manually on my crontab environment, or if another variable that has to do with ALSA, Pulseaudio, or my dbus session has to be declared manually in my crontab file:
# *    *    *   *    *  Command_to_execute
# |    |    |    |   |       
# |    |    |    |    Day of the Week ( 0 - 6 ) ( Sunday = 0 )
# |    |    |    |
# |    |    |    Month ( 1 - 12 )
# |    |    |
# |    |    Day of Month ( 1 - 31 )
# |    |
# |    Hour ( 0 - 23 )
# |
# Min ( 0 - 59 )
SHELL=/bin/bash
HOME=/home/drjeff16
DISPLAY=:0.0
.
.
.
EDITOR="$(cat $HOME/.editor)"
isCron=1
.
.
.