Shell之MP3播放器

來源:互聯網
上載者:User

下面的程式實現一個簡單的mp3播放功能,可以設定路徑對所有mp3檔案進行搜尋並順序播放。

#!/bin/sh# very simple example shell script for mp3 player# 2014-5-6 by slwang#實現搜尋所有mp3檔案並順序播放歌曲path1=~/Musicpath2=~/Downloadstemp_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}clearecho "welcome to mp3 player"sleep 1IFS=""find $path1 $path2 -name *.mp3 -print > $temp_filemusicset=$(cat $temp_file)#more $musicset > $temp_filefor music in $musicsetdoecho "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;;esacdonedoneIFS=" "rm -f $temp_fileaudacious -secho "finished"exit 0

(轉載請註明作者和出處:http://blog.csdn.net/awakewind 未經允許請勿用於商業用途)


相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.