暂停后台mplayer的脚本

http://forum.ubuntu.org.cn/viewtopic.php?f=21&t=155992

暂停

代码:
#!/bin/sh
#mplayer pause
if [ -e /tmp/player.fifo ];then
if [ "`ps aux |grep ' mplayer '|grep -v grep|grep "/tmp/player.fifo"|wc
-l`" != 0 ];then
echo pause > /tmp/player.fifo
fi
fi
exit

单曲循环播放
代码:
#!/bin/sh
#killall mplayer;
#echo "`ps aux |grep mplayer |grep -v grep|awk {'print $2'}`"
#sleep 1
if [ "`ps aux |grep ' mplayer '|grep -v grep|wc -l`" != 0 ];then
kill -9 `ps aux |grep ' mplayer '|grep -v grep|awk {'print $2'}`
fi

if [ "`ps aux |grep ' mpg123 ' |grep -v grep|wc -l`" != 0 ];then
kill -9 `ps aux |grep ' mpg123 '|grep -v grep|awk {'print $2'}`
fi

if [ "`ps aux |grep ' ogg123 '|grep -v grep|wc -l`" != 0 ];then
kill -9 `ps aux |grep ' ogg123 '|grep -v grep|awk {'print $2'}`
fi
#killall flac123 beep-media-player audacious;
#
if [ -z $1 ]; then exit;fi;
#建立管道:
if ! [ -e /tmp/player.fifo ];then
mkfifo /tmp/player.fifo
fi
#sleep 1
case "$1" in
*.ogg|*.OGG)
exec mplayer "$1" -loop 0 -input file=/tmp/player.fifo;;
#exec ogg123 -z "$1";;
#exec ogg123 "$1";;
# *ogg)
#exec ogg123 -z@ "$1";;
*.mp3|*.MP3)
exec mplayer "$1" -loop 0 -input file=/tmp/player.fifo;;
#exec mpg123 -Z "$1";;
*.m4a)
exec mplayer "$1" -loop 0 -input file=/tmp/player.fifo;;
#exec mpg123 "$1";;
#*mp3
#exec mpg123 -Z@ "$1";;
#exec audacious "$1";;
#*flac|*FLAC
#exec mplayer "$1";;
#exec flac123 "$1";;
#*.avi
#exec aviplay "$1";;
#exec totem "$1";;
*.wma)
exec mplayer "$1" -loop 0 -input file=/tmp/player.fifo;;
*.mlist)
exec mplayer -playlist "$1" -input file=/tmp/player.fifo;;
*)
exec mplayer "$1" -loop 0 -input file=/tmp/player.fifo;;
esac
exit


歌曲随机播放
代码:
#!/bin/bash
#kill players
killall mplayer mpg123;
if [ "`ps aux |grep ' mplayer '|grep -v grep|wc -l`" != 0 ];then
kill -9 `ps aux |grep ' mplayer '|grep -v grep|awk {'print $2'}`
fi
#clean
if [ -s /tmp/mlist ]; then
rm /tmp/mlist
fi

#make play list
dr=`pwd`
#dr=`dirname "$1"`
#cd "$dr"
#st=${1##*//}
st="`echo "$1"|sed 's//[[/g;s//]]/g'`"
echo "$st"
list="`ls "$dr"|grep -v ".jpg"|grep -v ".srt"|grep -v "padding_file"`"
a="`echo "$list"|grep -n "$st"|sed -n 1p|awk -F : '{print $1}'`"
b="`echo "$list"|wc -l`"
#error manage
c=$#
if [ -z $a ];then a=1;c=0;fi
#######
for((i=$a;i<=$b;i++))do
if [ $c = 0 ];then
song="`echo "$list"|sed -n $i,$(($i))p`"
echo "$dr/$song" >>/tmp/mlist
elif [ $c = 1 ];then
song="`echo "$list"|sed -n $i,$(($i))p`"
echo "$dr/$song" >>/tmp/mlist
else
song="`echo "$list"|sed -n $i,$(($i))p`"
song1="`echo "$song"|sed 's//[[/g;s//]]/g'`"
need_list="`echo "$*"|grep "$song1"|wc -l`"
if [ $need_list = 1 ];then
echo "$dr/$song" >>/tmp/mlist
fi
fi
done
#建立管道:
if ! [ -e /tmp/player.fifo ];then
mkfifo /tmp/player.fifo
fi
#play with list
if [ -s /tmp/mlist ]; then
#if [ $c = 0 ];then
#mplayer -playlist /tmp/mlist
if [ $c = 1 ];then
mplayer -loop 0 -playlist /tmp/mlist -shuffle -input file=/tmp/player.fifo
else
mplayer -loop 0 -playlist /tmp/mlist -shuffle -input file=/tmp/player.fifo
fi
#clean
rm /tmp/mlist
fi

exit

歌曲循环播放
代码:
#!/bin/bash
#kill players
killall mplayer mpg123;
if [ "`ps aux |grep ' mplayer '|grep -v grep|wc -l`" != 0 ];then
kill -9 `ps aux |grep ' mplayer '|grep -v grep|awk {'print $2'}`
fi
#clean
if [ -s /tmp/mlist ]; then
rm /tmp/mlist
fi

#make play list
dr=`pwd`
#dr=`dirname "$1"`
#cd "$dr"
#st=${1##*//}
st="`echo "$1"|sed 's//[[/g;s//]]/g'`"
echo "$st"
list="`ls "$dr"|grep -v ".jpg"|grep -v ".srt"|grep -v "padding_file"`"
a="`echo "$list"|grep -n "$st"|sed -n 1p|awk -F : '{print $1}'`"
b="`echo "$list"|wc -l`"
#error manage
c=$#
if [ -z $a ];then a=1;c=0;fi
#######
for((i=$a;i<=$b;i++))do
if [ $c = 0 ];then
song="`echo "$list"|sed -n $i,$(($i))p`"
echo "$dr/$song" >>/tmp/mlist
elif [ $c = 1 ];then
song="`echo "$list"|sed -n $i,$(($i))p`"
echo "$dr/$song" >>/tmp/mlist
else
song="`echo "$list"|sed -n $i,$(($i))p`"
song1="`echo "$song"|sed 's//[[/g;s//]]/g'`"
need_list="`echo "$*"|grep "$song1"|wc -l`"
if [ $need_list = 1 ];then
echo "$dr/$song" >>/tmp/mlist
fi
fi
done
#建立管道:
if ! [ -e /tmp/player.fifo ];then
mkfifo /tmp/player.fifo
fi
#play with list
if [ -s /tmp/mlist ]; then
#if [ $c = 0 ];then
#mplayer -playlist /tmp/mlist
if [ $c = 1 ];then
mplayer -playlist /tmp/mlist -input file=/tmp/player.fifo
else
mplayer -playlist /tmp/mlist -loop 0 -input file=/tmp/player.fifo
fi
#clean
rm /tmp/mlist
fi

exit

停止
代码:
#!/bin/sh
killall blackscreen mpg123 ogg123 my_apt-get adsl_pppoe;
#killall mplayer;
#echo "`ps aux |grep mplayer |grep -v grep|awk {'print $2'}`"

#sleep 1
if [ "`ps aux |grep ' mplayer '|grep -v grep|grep -v "/tmp/player.fifo"|wc
-l`" != 0 ];then
kill -9 `ps aux |grep ' mplayer '|grep -v grep|grep -v
"/tmp/player.fifo"|awk {'print $2'}`
fi

if [ "`ps aux |grep ' mpg123 ' |grep -v grep|wc -l`" != 0 ];then
kill -9 `ps aux |grep ' mpg123 '|grep -v grep|awk {'print $2'}`
fi

if [ "`ps aux |grep ' ogg123 '|grep -v grep|wc -l`" != 0 ];then
kill -9 `ps aux |grep ' ogg123 '|grep -v grep|awk {'print $2'}`
fi
#killall flac123 beep-media-player audacious;
#
if [ "`ps aux |grep ' mplayer '|grep -v grep|grep "/tmp/player.fifo"|wc
-l`" != 0 ];then
if(zenity --question --text="全部停止?")then
echo quit > /tmp/player.fifo
sleep 0.1
kill -9 `ps aux |grep ' mplayer '|grep -v grep|awk {'print $2'}`
fi
fi
exit

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值