Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
sbrennion committed Aug 19, 2016
0 parents commit aa99de9
Show file tree
Hide file tree
Showing 4 changed files with 111 additions and 0 deletions.
31 changes: 31 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"name": "node-red-contrib-play-audio-file",
"version": "0.0.1",
"description": "Play an audio file",
"icon": "fa-file-audio-o.png",
"dependencies": {
"soundplayer": "*"
},
"keywords": [
"node-red",
"sound",
"audio",
"mp3"
],
"repository": {
"type": "git",
"url": "git:https://github.com/sbrennion/node-red-contrib-play-audio-file.git"
},
"homepage": "https://leanbi.ch/industrie-40",
"node-red": {
"nodes": {
"play-audio-file": "play_audio_file.js"
}
},
"maintainers": [
{
"name": "leanbi",
"email": "[email protected]"
}
],
}
29 changes: 29 additions & 0 deletions play_audio_file.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<script type="text/javascript">
RED.nodes.registerType('play_audio_file',{
category: 'output',
color: '#A10C0C',
defaults: {
filename : {value:'/path/to/filename'}
},
inputs:1,
outputs:1,
label: function() {
return this.name||"play_audio_file";
},
oneditprepare: function() {
}
});
</script>

<script type="text/x-red" data-template-name="play_audio_file">
<!-- INPUT -->
<div class="form-row">
<label for="node-input-filename"><i class="fa fa-arrow-left"></i>Audio file</label>
<input type="text" id="node-input-filename" placeholder="">
</div>

</script>

<script type="text/x-red" data-help-array="play_audio_file">
<p>Play an audio file from disk</p>
</script>
36 changes: 36 additions & 0 deletions play_audio_file.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
module.exports = function(RED) {

function Play_audio_file(config) {
this.log("test")
RED.nodes.createNode(this,config);
var node = this;
//this.status({fill:"red",shape:"dot",text:"not started"});


this.on("input",function(msg){
f=config.filename || msg.filename
var SoundPlayer = require('soundplayer')
var player=new SoundPlayer();

// play with a callback
player.sound(f, function(){
node.log('playing ' + f)
});

player.on('error', function (error) {
node.log("unable to play sound : " + f + "\n" + JSON.stringify(error))
});


})



}





RED.nodes.registerType("play_audio_file",Play_audio_file);
}
15 changes: 15 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#requirements

See https://www.npmjs.com/package/soundplayer

One of the CLI based audio player

'mpg123'
'mpg321'
'play'
(anyother cli based audio player)


#usage

specify the audio file name to play in the config or in the message header : msg.filename=/home/me/file.mp3

0 comments on commit aa99de9

Please sign in to comment.