forked from LeanBI/node-red-contrib-play-audiofile
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit aa99de9
Showing
4 changed files
with
111 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]" | ||
} | ||
], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |