如何检查声卡上的声音是否停止播放
我创建了一个 KornShell (ksh) 脚本,通过搜索歌曲名称 + 艺术家姓名并点击第一个链接(歌曲名称和艺术家列表存储在文件中)来播放 YouTube 上的歌曲列表。
我想改变我当前的方法,让用户在终端上输入一些值(读取 x < /dev/tty)来播放下一首歌曲。我希望脚本在第一首歌曲停止播放后立即切换到下一首歌曲。虽然我知道该方法可能有一些警告(如果歌曲仍在播放时另一个声音开始和停止怎么办)-这仍然可以满足我的基本要求。关于如何通过 shell 轮询声卡有什么想法吗?
I have created a KornShell (ksh) script that plays a list of songs on youtube by searching the song name + the artist name and hitting the first link (the list of song names and artists are stored in a file).
I would like to change my current approach of having the user enter some value (read x < /dev/tty) on the terminal to play the next song. I want the script to simply switch over to the next song as soon as the first one stops playing. While I am aware that the approach may have caveats (what if another sound starts and stops while the song is still playing) - this would still meet my basic requirements. Any ideas on how to poll the sound card through shell?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
奇怪的问题。为什么不只是在播放时循环就不会失败(用 bash 来说):
如果必须的话,您可以随时使用
fuser
或lsof
检查占用声音设备文件的 pid。Strange question. Why not just loop while playing doesn't fail (in bash-speak):
If you must you can always check with
fuser
orlsof
for pids occupying sound device file.