Friday 6 September 2019

Create an airplay server nodejs

I am creating an airplay server with this documentation https://nto.github.io/AirPlay.html#screenmirroring

My code is the following one

const airplay = require('airplay-server');
const macaddress = require('macaddress');
const express = require('express');

const http = express()

macaddress.one((err, mac) => {
  airplayServer = airplay({
    name: 'test',
    txt: {
      deviceid: mac,
      features: '0x5A7FFFF7',
      flags: '0x44',
      model: 'AppleTV3,2',
      srcvers: '220.68',
      vv: 2
    }
  })
  airplayServer.listen(7000);

  airplayServer.on('request', function (req, res) {
    console.log('Request received');
    console.log(req.method, req.url)
    console.log(req.headers)
  })

  airplayServer.on('listening', function () {
    console.log('Listen 7000');
  })
})

http.get('/stream.xml', (req, res) => {
  res.header("Content-Type", "text/x-apple-plist+xml");
  res.send('<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"><plist version="1.0"><dict><key>height</key><integer>720</integer><key>overscanned</key><true/><key>refreshRate</key><real>0.016666666666666666</real><key>version</key><string>130.14</string><key>width</key><integer>1280</integer></dict></plist>')
});

http.post('/stream', ((req, res) => {
  console.log('STREAM !!!!!');
  res.end(200);
}))

http.listen(7100)

I have a server on 7000 and an other on 7100 to use the screen mirroring functionality of my phone

The test device appear when I am going in screen mirroring on my IPhone but I have the error message Unable to connect to "test"

The doc is quite old, can be outdated.

I receive nothing on post or request



from Create an airplay server nodejs

No comments:

Post a Comment