OSDN Git Service

add sfplayer script
authorMichael Chen <omxcodec@gmail.com>
Mon, 22 Oct 2012 03:22:43 +0000 (11:22 +0800)
committerMichael Chen <omxcodec@gmail.com>
Mon, 22 Oct 2012 03:22:43 +0000 (11:22 +0800)
tools/sfplayer [new file with mode: 0755]

diff --git a/tools/sfplayer b/tools/sfplayer
new file mode 100755 (executable)
index 0000000..5689822
--- /dev/null
@@ -0,0 +1,49 @@
+#!/system/bin/bash
+
+# ref :http://www.ibm.com/developerworks/cn/linux/l-bash-parameters.html
+
+#dir="/data/test"
+#file="pdahd.720X480.mp4"
+
+showopts () {
+  while getopts ":d:" optname
+    do
+      case "$optname" in
+        "d")
+          echo "Option $optname has value $OPTARG"
+         dir=$OPTARG
+          ;;
+        "?")
+          echo "Unknown option $OPTARG"
+          ;;
+        ":")
+          echo "No argument value for option $OPTARG"
+          ;;
+        *)
+        # Should not occur
+          echo "Unknown error while processing options"
+          ;;
+      esac
+    done
+  return $OPTIND
+}
+
+showargs () {
+  for p in "$@"
+    do
+      echo "$p"
+    done
+}
+
+optinfo=$(showopts "$@")
+argstart=$?
+arginfo=$(showargs "${@:$argstart}")
+echo "Arguments are:"
+echo "$arginfo"
+echo "Options are:"
+echo "$optinfo"
+
+file=$arginfo
+
+#am start -a android.intent.action.VIEW -d file://$dir/$file -t video/*
+am start -a android.intent.action.VIEW -d file://$file -t video/*