Tag: omxplayer

使用Node.js在RPi上播放本地文件

我有一个树莓派设置了一个Node.js应用程序,当它看到从亚马逊的Dashbuttonbutton时,响应。 它原本应该是从https://github.com/initialstate/silent-doorbell无声门铃,但我想只是让它播放本地声音文件。 我认为应该很容易,但是我对编码的经验不足,使我只能尝试在互联网上find的新东西。 我可以从terminal播放下面的文件,它玩的很好: $ omxplayer example.mp3 但是,不pipe我怎么试着把它放在Node.js应用程序中,并按下Dashbutton时触发它将不起作用。 var dash_button = require('node-dash-button'), dash = dash_button('XX:XX:XX:XX:XX:XX'), //REPLACE WITH YOUR ADDRESS exec = require('child_process').exec; Omx = require('node-omxplayer'); player = Omx('~/node_modules/node-dash-button/example.mp3'); let spawn = require('child_process').spawn; dash.on('detected', function() { console.log('Button pushed!'); player.play(); }); 当我运行与我的最新如上,我得到这个: /home/pi/node_modules/node-dash-button/doorbell.js:7 let spawn = require('child_process').spawn; ^^^^^ SyntaxError: Unexpected identifier at exports.runInThisContext (vm.js:73:16) at Module._compile (module.js:443:25) […]