-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplay-test.js
128 lines (95 loc) · 2.87 KB
/
play-test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
soundName1 = "./sounds/1-Marijo_Slavna.mp3";
soundName2 = "./sounds/Barbara.mp3";
soundName3 = "./sounds/Galija-Cujem_te_lepo_kako_dises.mp3";
soundName4 = "./sounds/400402_5121236-hq.ogg";
soundName = soundName3;
var fs = require('fs');
var lame = require('lame');
var Speaker = require('speaker');
fs.createReadStream(soundName)
.pipe(new lame.Decoder)
.on('format', console.log)
.pipe(new Speaker);
// var player = require("play-sound")(opts = {})
// audio = player.play(soundName, {
// afplay: ["-v", 1] // lower volume for afplay on OSX
// }, function(err) {
// if (err) throw err;
// })
// audio.kill();
/* LIB: play-sound
var player = require('play-sound')(opts = {})
// $ mplayer foo.mp3
audio = player.play(soundName1, function(err) {
if (err) throw err
})
// { timeout: 300 } will be passed to child process
player.play(soundName2, { timeout: 300 }, function(err) {
if (err) throw err
})
// configure arguments for executable if any
player.play(soundName3, { afplay: ['-v', 1] // lower volume for afplay on OSX
},
function(err) {
if (err) throw err
})
// access the node child_process in case you need to kill it on demand
var audio = player.play('foo.mp3', function(err) {
if (err && !err.killed) throw err
})
audio.kill();
*/
/*
// LIB: soundplayer
var SoundPlayer = require('soundplayer');
var player = new SoundPlayer();
// play with a callback
player.sound(soundName1, function() {
// these are all "fire and forget", no callback
player.sound(soundName2);
});
//If you want to know when the player has defintely started playing
player.on('play', function(valid) {
console.log('I just started playing!');
});
var sound = player.sound(soundName3);
//If you want to know if this can't play for some reason
sound.on('error', function(error) {
console.error("I can't play!", error);
});
*/
/*
var play = require('play').Play();
// play with a callback
play.sound(soundName1, function() {
// these are all "fire and forget", no callback
play.sound(soundName2);
});
//If you want to know when the player has defintely started playing
play.on('play', function(valid) {
console.log('I just started playing!');
});
play.sound(soundName3);
//If you want to know if this can't play for some reason
play.on('error', function() {
console.log("I can't play!");
});
*/
/*
LIB: sound-player
// All options
var options = {
filename: "/Users/sasha/Box Sync/should check and clean/crkva/ноте/1-Marijo_Slavna.mp3",
// gain: 100,
// debug: true,
// player: "afplay" // other supported players are 'aplay', 'mpg123', 'mpg321'
// device: "plughw0:0"
}
// instantiation with options
var soundplayer = require("sound-player");
var player = new soundplayer(options);
player.play();
// options.filename =
// "/Users/sasha/Box Sync/should check and clean/crkva/ноте/1-Marijo_Slavna.mp3";
// player.play(options);
*/