#!/bin/sh
# $Id: do-video,v 1.1 2001/04/25 18:48:39 rbasch Exp $

. /mit/mimeutils/share/scripts/utils.sh

subtype=

usage() {
  echo "Usage: do-video [-s subtype] [-t content-type] <file>" 1>&2
  exit 1
}

while getopts s:t: opt; do
  case "$opt" in
    s)
      subtype=`echo "$OPTARG" | tr 'A-Z' 'a-z'`
      ;;
    t)
      subtype=`echo "$OPTARG" | awk -F/ '{ print $2; }' | tr 'A-Z' 'a-z'`
      ;;
    \?)
      usage
      ;;
  esac
done
shift `expr "$OPTIND" - 1`

# First see if we can use mediaplayer
case "$subtype" in
  x-sgi-movie|quicktime|mpeg|x-msvideo)
    if [ -x /usr/sbin/mediaplayer ]; then
      exec /usr/sbin/mediaplayer -v -nofork "$1"
    fi
    ;;
esac

case "$subtype" in
  x-sgi-movie)
    becho "No viewer for video/x-sgi-movie on this platform."
    becho "Try an SGI workstation."
    ;;

  mpeg)
    # As of 2.70.6, xanim's MPEG support is flaky. (Does not deal with
    # B and P frames according to man page.) So use mpeg_play instead.
    exec /bin/athena/attachandrun graphics mpeg_play mpeg_play "$1"
    ;;

  *)
    exec /bin/athena/attachandrun graphics xanim xanim "$1"
    ;;

esac
