video.sh 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #!/bin/sh
  2. # $1 - action
  3. # $2 - type of file
  4. action=$1
  5. filetype=$2
  6. [ -n "${MC_XDG_OPEN}" ] || MC_XDG_OPEN="xdg-open"
  7. do_view_action() {
  8. filetype=$1
  9. case "${filetype}" in
  10. *)
  11. if which mplayer >/dev/null 2>&1; then
  12. mplayer -identify -vo null -ao null -frames 0 "${MC_EXT_FILENAME}" 2>&1 | \
  13. sed -n 's/^ID_//p'
  14. elif which mpv_identify.sh >/dev/null 2>&1; then
  15. mpv_identify.sh "${MC_EXT_FILENAME}"
  16. else
  17. echo "Please install either mplayer or mpv to get information for this file"
  18. fi
  19. ;;
  20. esac
  21. }
  22. do_open_action() {
  23. filetype=$1
  24. if which mpv >/dev/null 2>&1; then
  25. PLAYER=mpv
  26. elif which mplayer >/dev/null 2>&1; then
  27. PLAYER=mplayer
  28. else
  29. echo "Please install either mplayer or mpv to play this file"
  30. return
  31. fi
  32. case "${filetype}" in
  33. *)
  34. if [ -n "$DISPLAY" ]; then
  35. ($PLAYER "${MC_EXT_FILENAME}" >/dev/null 2>&1 &)
  36. else
  37. $PLAYER -vo null "${MC_EXT_FILENAME}"
  38. fi
  39. ;;
  40. esac
  41. }
  42. case "${action}" in
  43. view)
  44. do_view_action "${filetype}"
  45. ;;
  46. open)
  47. ("${MC_XDG_OPEN}" "${MC_EXT_FILENAME}" >/dev/null 2>&1) || \
  48. do_open_action "${filetype}"
  49. ;;
  50. *)
  51. ;;
  52. esac