使用定时脚本循环音频文件

looping audio file using timed script

我想播放一个音频文件,然后在音频文件播放完毕后等待 30 分钟,然后让它再次播放音频文件。我想多做几次。

我知道我只能制作一个大的音频文件,但文件会非常大,我需要通过电子邮件发送给其他人制作音频文件并使用某种类型的脚本来完成此操作更容易。

Example Loop: 
play audio file to the end then wait 30mins,
play audio file to the end then wait 30mins,
play audio file to the end then wait 30mins,
etc..

PS: 音频文件长度不限。

我知道 crontab

crontab -e
*/30 * * * * /path/to/your/command

但这不会等待音频文件播放完毕或让我能够说出它应该播放多少次 运行。

我正在使用 ubuntu 14.04

这很简单,或者我遗漏了什么。你需要的是:

NTIMES=5

count=0
while [ $count -lt $NTIMES ]
do
  mplayer the_sound_file
  sleep 1800                         # 1800 seconds == 30 min
  count=`expr $count + 1`
done

我使用了较旧的语法,因此这将 运行 用于任何类似 bourne 的 shell(不仅仅是 bash)。