码迷,mamicode.com
首页 > 系统相关 > 详细

Shell之MP3播放器

时间:2019-05-13 14:04:38      阅读:186      评论:0      收藏:0      [点我收藏+]

标签:view   rap   size   finish   load   res   http   down   statistic   

以下的程序实现一个简单的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


Shell之MP3播放器

标签:view   rap   size   finish   load   res   http   down   statistic   

原文地址:https://www.cnblogs.com/xfgnongmin/p/10856047.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
分享档案
周排行
mamicode.com排行更多图片
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!