daap.js
v1.1.0
Published
A promise based Digital Audio Access Protocol (DAAP) client implementation
Downloads
13
Maintainers
Readme
daap.js
A promise based Digital Audio Access Protocol (DAAP) client implementation in JavaScript
A note on CORS
daap.js uses XMLHttpRequest internally. Therefore it depends heavily on CORS which isn't supported by any known daap server currently. To enable Cors for your daap server you could put it behind a http proxy that adds CORS headers.
Example Apache proxy config for CORS
Listen 3690
NameVirtualHost *:3690
<VirtualHost *:3690>
ProxyRequests On
<Proxy>
Order deny,allow
Allow from all
</Proxy>
ProxyPass / http://<server-url>:3689/
ProxyPassReverse / http://<server-url>:3689/
Header set Access-Control-Allow-Origin "*"
Header set Access-Control-Allow-Methods "GET
</VirtualHost>"
Example usage
/* Daap accepts server and port. Per default server is 127.0.0.1 */
/* and port 3689. server can be an IP or domain name */
var daap = Daap({server: '192.168.1.123'});
daap.serverinfo().then(function(server_info) {
console.log(server_info);
})
/* set password if your server requires one */
daap.setPassword('.....');
daap.login().then(function() {
console.log('Yeah I am connected to my daap server');
return daap.items();
}).then(function(songs) {
console.log('I have got ' + songs.length + ' songs from my daap server');
}).catch(function(error) {
console.error('An error occured', error);
});