耳机网-耳机大家坛
标题:
解决HQPlayer Embedded试用版半小时自动停止问题的思路
[打印本页]
作者:
colin4k
时间:
2022-10-6 14:00
标题:
解决HQPlayer Embedded试用版半小时自动停止问题的思路
本帖最后由 colin4k 于 2022-10-6 16:18 编辑
分别对比了HQPlayer Desktop, HQPlayer OS 和HQPlayer Embedded之后,个人还是觉得基于Ubuntu安装HQPlayer Embedded的效果最好,主要是Desktop Win版开到DSD 512不太稳定,并且不支持UPNP,而OS版虽然支持UPNP却不支持N卡offload,只有Embedded既支持UPNP又默认打开CUDA。
只可惜翻遍了论坛也没有找到可用的HQPlayer Embedded学习版,突然想到,既然试用版的限制是没半小时自动停止,标志是查看hqplayerd的服务状态有"update status: Stopped"这句话,于是想到一个办法,就是写一个脚本,自动检测服务输出是否包含这句话,如果有则自动重启服务,测试了一下貌似可行,具体步骤如下,有兴趣的可以试一下:
1、新建一个starthq.sh文件,例如在/home/colin目录下创建该文件的命令是,
cd /home/colin
vi starthq.sh
复制代码
进入编辑界面后,按i键,进入编辑模式,粘贴以下脚本内容:
#!/bin/bash
m=$(/usr/bin/systemctl status hqplayerd|/usr/bin/grep 'update status: Stopped')
if [ "$m" ];then
/usr/bin/echo 'HQPlayer Embedded Stopped!'
/usr/bin/systemctl restart hqplayerd
fi
复制代码
然后按esc键,再输入:x,回车退出编辑模式
2、修改starthq.sh文件为可执行,输入以下命令
chmod 777 restarthq.sh
复制代码
3、建立crontab定时任务
输入以下命令进入crontab编辑模式(执行命令后需要输入当前用户的密码)
sudo crontab -u root -e
复制代码
进入编辑模式后,粘贴以下内容,意思是每分钟执行一次脚本进行检测,判断是否需要重启hqplayerd服务
*/1 * * * * /home/colin/restarthq.sh
复制代码
然后按esc键,再输入:x,回车退出编辑模式
4、执行以下命令观察crontab定时任务是否添加成功
sudo crontab -u root -l
复制代码
如果看到类似以下的输出就说明添加成功了
# Edit this file to introduce tasks to be run by cron.
#
# Each task to run has to be defined through a single line
# indicating with different fields when the task will be run
# and what command to run for the task
#
# To define the time you can provide concrete values for
# minute (m), hour (h), day of month (dom), month (mon),
# and day of week (dow) or use '*' in these fields (for 'any').
#
# Notice that tasks will be started based on the cron's system
# daemon's notion of time and timezones.
#
# Output of the crontab jobs (including errors) is sent through
# email to the user the crontab file belongs to (unless redirected).
#
# For example, you can run a backup of all your user accounts
# at 5 a.m every week with:
# 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/
#
# For more information see the manual pages of crontab(5) and cron(8)
#
# m h dom mon dow command
*/1 * * * * /home/colin/restarthq.sh
复制代码
5、执行以下命令刷新crontab服务
sudo /sbin/service cron reload
复制代码
6、最后观察hqplayerd服务的状态以确认脚本是否生效
执行以下命令:
sudo systemctl status hqplayerd
复制代码
如果有类似以下的输出:
10月 06 13:57:05 ColinZ390 hqplayerd[23143]: additional mime type: audio/L16;rate=352800
10月 06 13:57:05 ColinZ390 hqplayerd[23143]: additional mime type: audio/L16;rate=384000
10月 06 13:57:05 ColinZ390 hqplayerd[23143]: additional mime type: audio/L16;rate=705600
10月 06 13:57:05 ColinZ390 hqplayerd[23143]: additional mime type: audio/L16;rate=768000
10月 06 13:57:05 ColinZ390 hqplayerd[23143]: Enable UPnP Renderer functionality for interface: auto
10月 06 13:57:05 ColinZ390 hqplayerd[23143]: Adding interface 'eno1' for UPnP Renderer
10月 06 13:57:05 ColinZ390 hqplayerd[23143]: property updated; volume: 0.95
10月 06 13:57:05 ColinZ390 hqplayerd[23143]: clPlayerDaemon::OnNameLost() for 'org.mpris.MediaPlayer2.hqplayerd'
复制代码
注意看时间,对比一下就知道脚本是否正常运行了
作者:
万远
时间:
2022-10-6 16:06
呵呵,兄台的方法不失为折衷的好方法!堂堂大中国人才济济,群力群策总会找到不一样的出路的!
欢迎光临 耳机网-耳机大家坛 (http://erji.net/)
Powered by Discuz! X3.2