#!/bin/bash
SOURCE="$0"
source /usr/lib/elive-tools/functions
EL_REPORTS="1"
el_make_environment
. gettext.sh
TEXTDOMAIN="elive-tools"
export TEXTDOMAIN



main(){
    # pre {{{
    local file

    if ! el_dependencies_check "mkchromecast" ; then
        el_dependencies_install "mkchromecast"
    fi

    local message_chromecast_playing
    message_chromecast_playing="$( printf "$( eval_gettext "Video Playing in your Chromecast Screen" )" "" )"
    local message_stop_playback
    message_stop_playback="$( printf "$( eval_gettext "Stop Playback" )" "" )"

    # }}}

    # send video to chromecast
    if ((is_interactive)) ; then
        ( mkchromecast --video -i "$@" & )
    else
        ( mkchromecast --video -i "$@" 1>/dev/null 2>&1 & )
    fi
    sleep 3

    # show a notification where to stop the player
    result="$( el_notify wait chromecast Chromecast "$message_chromecast_playing" --action=stop="$message_stop_playback" )"

    if [[ "$result" = "stop" ]] ; then
        killall mkchromecast 2>/dev/null || killall -9 mkchromecast 2>/dev/null
    fi



}

#
#  MAIN
#
main "$@"

# vim: set foldmethod=marker :
