Shell之MP3播放器
生活随笔
收集整理的這篇文章主要介紹了
Shell之MP3播放器
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
下面的程序?qū)崿F(xiàn)一個(gè)簡(jiǎn)單的mp3播放功能,可以設(shè)置路徑對(duì)所有mp3文件進(jìn)行搜索并順序播放。
#!/bin/sh# very simple example shell script for mp3 player
# 2014-5-6 by slwang#實(shí)現(xiàn)搜索所有mp3文件并順序播放歌曲path1=~/Music
path2=~/Downloads
temp_file=/tmp/temp_files$$
musicset=""
menu_choice=""
isnext="n"trap 'rm -f $temp_file && audacious -s' EXITset_menu_choice() {clearecho "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 1IFS="
"
find $path1 $path2 -name *.mp3 -print > $temp_filemusicset=$(cat $temp_file)#more $musicset > $temp_filefor music in $musicset
doecho "Beign to play $music"audacious -h $musicisnext="n"while [ "$isnext" = "n" ]doset_menu_choicecase $menu_choice inp) audacious -p;;u) audacious -u;;s) audacious -s;;n) isnext="y";;c) IFS=" "set $(wc -l $temp_file)lines=$1echo "total include $lines songs"echo "press return"IFS="
"read x;;l) more $temp_fileecho "press return" read x;;q) exit 0;;esacdone
doneIFS=" "
rm -f $temp_file
audacious -s
echo "finished"
exit 0
(轉(zhuǎn)載請(qǐng)注明作者和出處:http://blog.csdn.net/awakewind 未經(jīng)允許請(qǐng)勿用于商業(yè)用途)
(想與博主一起在技術(shù)上成長,請(qǐng)移步 knowthendo.cn)
總結(jié)
以上是生活随笔為你收集整理的Shell之MP3播放器的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: python降维之时间类型数据的处理_【
- 下一篇: 大神带飞————动态生成对象并绑定父对象