当 systemd 运行 时,aplay 不播放音频
aplay does not play audio when run by systemd
我正在开发一个 Qt 应用程序,其中包含以下用于播放声音的代码块
QString soundApp = "/usr/bin/aplay";
QStringList soundFile;
soundFile << "/home/pi/urna-files/sources/som-longo.wav";
QProcess *playSound = new QProcess;
playSound->start(soundApp, soundFile);
当应用程序从命令行 运行 时,声音播放正常。
开机后使用systemd和unit file启动应用程序时,QProcess不播放音频
[Unit]
Description=Voting Machine Launch Service
[Service]
ExecStart=/home/pi/urna
Restart=always
[Install]
WantedBy=multi-user.target
我应该怎么做才能让它正常工作?单元文件中还有什么要添加的吗?或 QProcess 的任何其他参数?
该过程可能需要 运行 作为用户 "pi"。
这可以在 Service
部分完成
[Service]
User=pi
我正在开发一个 Qt 应用程序,其中包含以下用于播放声音的代码块
QString soundApp = "/usr/bin/aplay";
QStringList soundFile;
soundFile << "/home/pi/urna-files/sources/som-longo.wav";
QProcess *playSound = new QProcess;
playSound->start(soundApp, soundFile);
当应用程序从命令行 运行 时,声音播放正常。
开机后使用systemd和unit file启动应用程序时,QProcess不播放音频
[Unit]
Description=Voting Machine Launch Service
[Service]
ExecStart=/home/pi/urna
Restart=always
[Install]
WantedBy=multi-user.target
我应该怎么做才能让它正常工作?单元文件中还有什么要添加的吗?或 QProcess 的任何其他参数?
该过程可能需要 运行 作为用户 "pi"。
这可以在 Service
部分完成
[Service]
User=pi