Merge branch '4524_cleanup'
[midnight-commander.git] / misc / ext.d / video.sh
blob9cba21020a2cf7ed38e13e9bb0ca431d9c33554a
1 #!/bin/sh
3 # $1 - action
4 # $2 - type of file
6 action=$1
7 filetype=$2
9 [ -n "${MC_XDG_OPEN}" ] || MC_XDG_OPEN="xdg-open"
11 do_view_action() {
12 filetype=$1
14 case "${filetype}" in
16 if which mplayer >/dev/null 2>&1; then
17 mplayer -identify -vo null -ao null -frames 0 "${MC_EXT_FILENAME}" 2>&1 | \
18 sed -n 's/^ID_//p'
19 elif which mpv_identify.sh >/dev/null 2>&1; then
20 mpv_identify.sh "${MC_EXT_FILENAME}"
21 else
22 echo "Please install either mplayer or mpv to get information for this file"
25 esac
28 do_open_action() {
29 filetype=$1
31 if which mpv >/dev/null 2>&1; then
32 PLAYER=mpv
33 elif which mplayer >/dev/null 2>&1; then
34 PLAYER=mplayer
35 else
36 echo "Please install either mplayer or mpv to play this file"
37 return
40 case "${filetype}" in
42 if [ -n "$DISPLAY" ]; then
43 ($PLAYER "${MC_EXT_FILENAME}" >/dev/null 2>&1 &)
44 else
45 $PLAYER -vo null "${MC_EXT_FILENAME}"
48 esac
51 case "${action}" in
52 view)
53 do_view_action "${filetype}"
55 open)
56 ("${MC_XDG_OPEN}" "${MC_EXT_FILENAME}" >/dev/null 2>&1) || \
57 do_open_action "${filetype}"
61 esac