Recording kinda working but not quite
This commit is contained in:
35
examples/record-app.php
Normal file
35
examples/record-app.php
Normal file
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
require_once __DIR__."/../vendor/autoload.php";
|
||||
|
||||
use NoccyLabs\PulseAudio\PulseAudio;
|
||||
|
||||
$pulse = new PulseAudio();
|
||||
|
||||
// Find the client
|
||||
$inputs = $pulse->getSinkInputs();
|
||||
foreach ($inputs as $input) {
|
||||
if ($input->getProperty('application.name') == 'Audacious') {
|
||||
echo "Found audacious on input #".$input->getIndex()."\n";
|
||||
record($pulse, $input, "output.wav");
|
||||
}
|
||||
}
|
||||
|
||||
function record($pulse, $input, $filename)
|
||||
{
|
||||
echo "Creating null sink...\n";
|
||||
$recSink = $pulse->createNullSink();
|
||||
|
||||
echo "Creating recorder...\n";
|
||||
$recorder = $recSink->createRecorder();
|
||||
$recorder->setFilename($filename);
|
||||
|
||||
echo "Moving audacious to the null sink with index #".$recSink->getIndex()."...\n";
|
||||
$input->moveToSink($recSink);
|
||||
|
||||
echo "Recording 5 seconds...\n";
|
||||
$recorder->start();
|
||||
sleep(5);
|
||||
$recorder->stop();
|
||||
|
||||
}
|
Reference in New Issue
Block a user