0

I would like to control an external player with Emacs under Windows. Because I'd like a bit of background music, I would avoid bloated libraries. I saw, for example, that mpv can use IPC calls.

In a Windows shell, once I start mpv in server mode:

mpv --input-ipc-server=\\.\pipe\mypipe  --idle=yes

I can easily send commands to it with:

$pipeCon = [System.IO.Pipes.NamedPipeClientStream]::new('.', "mypipe")
$pipeWriter = [System.IO.StreamWriter]::new($pipeCon)
$pipeCon.Connect()
$pipeWriter.AutoFlush = $true
$pipeWriter.WriteLine("loadfile C:\my.mp3 append-play")

The good thing here is that, by using a pipe, I do not have to fiddle with Windows admin privileges, the firewall etc.

The problem is now to replicate the snippet above in elisp. Given the server side is on (first line above), I could create the connection along these steps:

(setq myproc (make-network-process
 :name "test-stream"
 :server nil
 :family 'local
 :service "\\\\.\\pipe\\mypipe"
 :nowait t
 :noquery t))
 
(process-send-string myproc "loadfile C:\\my.mp3 append-play")

However, :family 'local is intended for Unix pipes/sockets. What should I use to connect to Windows named pipes?

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.