找回密码
 -注册-
查看: 6707|回复: 1
打印 上一主题 下一主题

解决HQPlayer Embedded试用版半小时自动停止问题的思路

[复制链接]
跳转到指定楼层
1
发表于 2022-10-6 14:00 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式 来自 广东佛山
本帖最后由 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目录下创建该文件的命令是,
  1. cd /home/colin
  2. vi starthq.sh
复制代码
进入编辑界面后,按i键,进入编辑模式,粘贴以下脚本内容:
  1. #!/bin/bash

  2. m=$(/usr/bin/systemctl status hqplayerd|/usr/bin/grep 'update status: Stopped')

  3. if [ "$m" ];then
  4.         /usr/bin/echo 'HQPlayer Embedded Stopped!'
  5.         /usr/bin/systemctl restart hqplayerd
  6. fi
复制代码
然后按esc键,再输入:x,回车退出编辑模式

2、修改starthq.sh文件为可执行,输入以下命令
  1. chmod 777 restarthq.sh
复制代码

3、建立crontab定时任务
输入以下命令进入crontab编辑模式(执行命令后需要输入当前用户的密码)
  1. sudo crontab -u root -e
复制代码
进入编辑模式后,粘贴以下内容,意思是每分钟执行一次脚本进行检测,判断是否需要重启hqplayerd服务

  1. */1 * * * * /home/colin/restarthq.sh
复制代码
然后按esc键,再输入:x,回车退出编辑模式

4、执行以下命令观察crontab定时任务是否添加成功
  1. sudo crontab -u root -l
复制代码
如果看到类似以下的输出就说明添加成功了
  1. # Edit this file to introduce tasks to be run by cron.
  2. #
  3. # Each task to run has to be defined through a single line
  4. # indicating with different fields when the task will be run
  5. # and what command to run for the task
  6. #
  7. # To define the time you can provide concrete values for
  8. # minute (m), hour (h), day of month (dom), month (mon),
  9. # and day of week (dow) or use '*' in these fields (for 'any').
  10. #
  11. # Notice that tasks will be started based on the cron's system
  12. # daemon's notion of time and timezones.
  13. #
  14. # Output of the crontab jobs (including errors) is sent through
  15. # email to the user the crontab file belongs to (unless redirected).
  16. #
  17. # For example, you can run a backup of all your user accounts
  18. # at 5 a.m every week with:
  19. # 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/
  20. #
  21. # For more information see the manual pages of crontab(5) and cron(8)
  22. #
  23. # m h  dom mon dow   command
  24. */1 * * * * /home/colin/restarthq.sh
复制代码
5、执行以下命令刷新crontab服务
  1. sudo /sbin/service cron reload
复制代码



6、最后观察hqplayerd服务的状态以确认脚本是否生效
执行以下命令:
  1. sudo systemctl status hqplayerd
复制代码
如果有类似以下的输出:
  1. 10月 06 13:57:05 ColinZ390 hqplayerd[23143]:         additional mime type: audio/L16;rate=352800
  2. 10月 06 13:57:05 ColinZ390 hqplayerd[23143]:         additional mime type: audio/L16;rate=384000
  3. 10月 06 13:57:05 ColinZ390 hqplayerd[23143]:         additional mime type: audio/L16;rate=705600
  4. 10月 06 13:57:05 ColinZ390 hqplayerd[23143]:         additional mime type: audio/L16;rate=768000
  5. 10月 06 13:57:05 ColinZ390 hqplayerd[23143]: Enable UPnP Renderer functionality for interface: auto
  6. 10月 06 13:57:05 ColinZ390 hqplayerd[23143]: Adding interface 'eno1' for UPnP Renderer
  7. 10月 06 13:57:05 ColinZ390 hqplayerd[23143]: property updated; volume: 0.95
  8. 10月 06 13:57:05 ColinZ390 hqplayerd[23143]: clPlayerDaemon::OnNameLost() for 'org.mpris.MediaPlayer2.hqplayerd'
复制代码
注意看时间,对比一下就知道脚本是否正常运行了




2
发表于 2022-10-6 16:06 | 只看该作者 来自 中国
呵呵,兄台的方法不失为折衷的好方法!堂堂大中国人才济济,群力群策总会找到不一样的出路的!
回复

使用道具 举报

您需要登录后才可以回帖 登录 | -注册-

本版积分规则

Archiver|手机版|粤icp备09046054号|耳机网-耳机大家坛

粤公网安备 44030602000598号 耳机大家坛、www.erji.net、网站LOGO图形均为注册商标

GMT+8, 2025-9-7 13:10

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表