Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我创建了一个 KornShell (ksh) 脚本,通过搜索歌曲名称 + 艺术家姓名并点击第一个链接(歌曲名称和艺术家列表存储在一个文件中)来播放 youtube 上的歌曲列表。
我想改变我目前让用户在终端上输入一些值(读取 x < /dev/tty)来播放下一首歌曲的方法。我希望脚本在第一首歌曲停止播放后立即切换到下一首歌曲。虽然我知道这种方法可能有一些警告(如果在歌曲仍在播放时另一个声音开始和停止怎么办) - 这仍然符合我的基本要求。关于如何通过外壳轮询声卡的任何想法?
奇怪的问题。为什么不只是循环播放不会失败(在bash-speak):
while [ $? -eq 0 ]; do smth; other; ... mplayer $file; done
如果必须,您可以随时检查占用声音设备文件的 pid fuser。lsof
fuser
lsof