#!/bin/bash

if [ $# -eq 0 ]; then
  echo "Usage: $0 [options] <file|uri>"
  exit 1;
fi

# get all options, which we forward to gst-launch
opts=""
while [ $# -gt 0 ]
do
  case $1
  in
    -*)
      opts="$opts $1"
      shift
    ;;
    *)
      name="$1"
      shift
    ;;
  esac
done

# does the file exist
if [ -r "$name" ]; then
  # check for beginning '/'
  if [ "${name:0:1}" == "/" ]; then
    location="file://$name"
  else
    location="file://$PWD/$name"
  fi
else
  location="$name"
fi

gst-launch $opts playbin uri="$location"

