Shell之MP3播放器
以下的程序实现一个简单的mp3播放功能。能够设置路径对全部mp3文件进行搜索并顺序播放。
#!/bin/sh
# very simple example shell script for mp3 player
# 2014-5-6 by slwang
#实现搜索全部mp3文件并顺序播放歌曲
path1=~/Music
path2=~/Downloads
temp_file=/tmp/temp_files$$
musicset=""
menu_choice=""
isnext="n"
trap 'rm -f $temp_file && audacious -s' EXIT
set_menu_choice() {
clear
echo "mp3 player menu :-"
echo " p) play"
echo " u) pause"
echo " s) stop"
echo " n) next"
echo " c) count"
echo " l) list"
echo " q) quit"
echo "please input: \c"
read menu_choice
}
clear
echo "welcome to mp3 player"
sleep 1
IFS="
"
find $path1 $path2 -name *.mp3 -print > $temp_file
musicset=$(cat $temp_file)
#more $musicset > $temp_file
for music in $musicset
do
echo "Beign to play $music"
audacious -h $music
isnext="n"
while [ "$isnext" = "n" ]
do
set_menu_choice
case $menu_choice in
p) audacious -p
;;
u) audacious -u
;;
s) audacious -s
;;
n) isnext="y"
;;
c) IFS=" "
set $(wc -l $temp_file)
lines=$1
echo "total include $lines songs"
echo "press return"
IFS="
"
read x
;;
l) more $temp_file
echo "press return"
read x
;;
q) exit 0
;;
esac
done
done
IFS=" "
rm -f $temp_file
audacious -s
echo "finished"
exit 0
(转载请注明作者和出处:http://blog.csdn.net/awakewind 未经同意请勿用于商业用途)
(想与博主一起在技术上成长,请移步
knowthendo.cn)
posted on 2019-05-13 13:03 xfgnongmin 阅读(352) 评论(0) 编辑 收藏 举报