examples/mplayer.sh.example
author nathan
Sat, 24 Oct 2009 11:20:45 +0800
branchtrunk
changeset 31 566c0f412764
parent 0 474a1293c3c0
permissions -rw-r--r--
set environment variable with DVB device number
nathan@0
     1
#!/bin/bash
nathan@0
     2
#
nathan@0
     3
# This script is called from VDR to start MPlayer
nathan@0
     4
#
nathan@0
     5
# argument 1: the file to play
nathan@0
     6
# argument 2: (optional) the phrase SLAVE if SlaveMode is enabled
nathan@0
     7
# argument 3: (optional) the phrase AID x to select audio stream x
nathan@0
     8
nathan@0
     9
# where to find mplayer
nathan@0
    10
MPLAYER="mplayer"
nathan@0
    11
nathan@0
    12
# mplayer options, -vc will be added below
nathan@0
    13
# add "-lircconf <lircrc>" to enable LIRC support
nathan@0
    14
OPTS="-vo mpegpes"
nathan@31
    15
if [ "aa$DVB_DEVICE" != "aa" ]; then
nathan@31
    16
  OPTS="-vo mpegpes:card=$DVB_DEVICE -ao mpegpes:card=$DVB_DEVICE"
nathan@31
    17
fi
nathan@0
    18
nathan@0
    19
# mplayer options for SlaveMode
nathan@0
    20
SLAVE="-slave -quiet -nolirc"
nathan@0
    21
nathan@0
    22
#####################
nathan@0
    23
nathan@0
    24
FILE=$1
nathan@0
    25
case "$FILE" in
nathan@0
    26
*.pls | *.m3u)
nathan@0
    27
  popt="-playlist"
nathan@0
    28
  first=`grep -v -m1 "^#" $FILE`
nathan@0
    29
  type=`file "$first"`
nathan@0
    30
  ;;
nathan@0
    31
*)
nathan@0
    32
  type=`file "$FILE"`
nathan@0
    33
  ;;
nathan@0
    34
esac
nathan@0
    35
nathan@0
    36
while shift; do
nathan@0
    37
  if [ "$1" = "SLAVE" ]; then
nathan@0
    38
    sopt=$SLAVE
nathan@0
    39
  elif [ "$1" = "AID" ]; then
nathan@0
    40
    aopt="-aid $2"
nathan@0
    41
    shift
nathan@0
    42
  fi
nathan@0
    43
done
nathan@0
    44
nathan@0
    45
case "$type" in
nathan@0
    46
*AVI*)
nathan@0
    47
  VC="ffdivx"
nathan@0
    48
  ;;
nathan@0
    49
*MPEG*)
nathan@0
    50
  VC="mpegpes"
nathan@0
    51
  ;;
nathan@0
    52
*)
nathan@0
    53
  echo "Unknown video file format $type"
nathan@0
    54
  echo "Edit mplayer.sh to support this file type"
nathan@0
    55
  exit 1
nathan@0
    56
  ;;
nathan@0
    57
esac
nathan@0
    58
nathan@0
    59
exec $MPLAYER $OPTS -vc $VC $sopt $aopt $popt "$FILE"
nathan@0
    60