#! /bin/zsh
export OMX_KEYS_FILE=~/public_html/conf/.omx-keys
# omx volume
export OMX_MUS_MOD=-1900
export OMX_SND_MOD=-2600
export OMX_VID_MOD=-2600
export OMX_MUT_MOD=-10000
omx-mute () {
    local -a vids
    vids=($@)
    local v
    for v in $vids; do
        sudo omxplayer $(omx-common-options) --vol $OMX_MUT_MOD $v
        sleep 3
    done
}
omx-common-options () {
    # data
    local font_size=35
    # options string
    local common_options="--adev local \
--align center \
--blank \
--font-size $font_size \
--key-config $OMX_KEYS_FILE \
--vol $OMX_SND_MOD"
    # done
    echo $common_options
}
omx-common () {
    local common_options
    common_options=$(omx-common-options)
    eval "sudo omxplayer $common_options $1"
}
play-loop-many () {
    local -a files
    files=($@)
    local common_options
    common_options=$(omx-common-options)
    local done=1
    while (( $done )); do
        for f in $files; do
            eval "sudo omxplayer $common_options $f | \grep 'Stopped' > /dev/null"
            done=$?
            (( ! $done )) && break
        done
    done
}
play-loop () {
    sudo omxplayer $(omx-common-options) --loop $@
}