{ "name": "playlist-parser", "version": "0.0.12", "description": "Parse m3u, m3u extended, and pls", "main": "lib/parser.min.js", "directories": { "test": "test" }, "scripts": { "test": "grunt test" }, "repository": { "type": "git", "url": "git://github.com/nickdesaulniers/javascript-playlist-parser.git" }, "keywords": [ "javascript", "playlist", "parse", "m3u", "pls", "asx" ], "author": { "name": "Nick Desaulniers" }, "license": "Dual MIT & Beerware", "bugs": { "url": "https://github.com/nickdesaulniers/javascript-playlist-parser/issues" }, "devDependencies": { "chai": "1.7.2", "grunt-contrib-coffee": "0.7.0", "grunt-mocha-test": "0.6.3", "grunt-contrib-uglify": "~0.2.4" }, "dependencies": { "xmldom": "0.1.16" }, "readme": "#javascript-playlist-parser#\nParse m3u, m3u extended, pls, and asx in JavaScript.\n\n##Usage##\n###Browser###\nAdds `window.M3U.parse`, `window.PLS.parse`, and `window.ASX.parse` which take a\nstring and return a possibly empty array of objects.\n\n```html\n\n```\n\n```javascript\n// Fetch the playlist file, using xhr for example\nvar xhr = new XMLHttpRequest();\nxhr.open(\"GET\", \"my_playlist.m3u\");\nxhr.overrideMimeType(\"audio/x-mpegurl\"); // Needed, see below.\nxhr.onload = parse;\nxhr.send();\n\n// Parse it\nfunction parse () {\n var playlist = M3U.parse(this.response);\n var audio = new Audio();\n next(audio, playlist, 0);\n};\n\n// Play each song after a song finishes\nfunction next (audio, playlist, i) {\n if (i < playlist.length) {\n audio.src = playlist[i++].file;\n audio.onended = next.bind(null, audio, playlist, i);\n audio.play();\n }\n};\n```\n\n[Demo](http://nickdesaulniers.github.io/javascript-playlist-parser/)\n\n###Node.js###\nAdds `require('playlist-parser').M3U.parse`,\n`require('playlist-parser').PLS.parse`,\nand `require('playlist-parser').ASX.parse`\nwhich take a string and return\na possibly empty array of objects.\n\n`npm install playlist-parser`\n```javascript\nvar parsers = require(\"playlist-parser\");\nvar M3U = parsers.M3U;\n\nvar fs = require(\"fs\");\nvar playlist = M3U.parse(fs.readFileSync(\"my_playlist.m3u\", { encoding: \"utf8\" }));\n```\n##Return Values##\nCalls to parse return an array of objects that look like:\n\n###M3U Simple or ASX###\n```javascript\n[{\n file: \"http://song.com/song.mp3\"\n}]\n```\n\n###M3U Extended###\n```javascript\n[{\n length: 1234,\n artist: \"Iron Maiden\",\n title: \"Rime of the Ancient Mariner\",\n file: \"http://song.com/song.mp3\"\n}]\n```\n\n###PLS###\n```javascript\n[{\n file: \"http://song.com/song.mp3\",\n title: \"My favorite song ever by my favorite artist\",\n length: 1234\n}]\n```\n\n##MIME Types##\n* m3u -> audio/x-mpegurl\n* pls -> audio/x-scpls\n* asx -> video/x-ms-asf\n\n##License##\n\nThis software is dual licensed under the MIT and Beerware license.\n\nThe MIT License (MIT)\n\nCopyright (c) 2013 Nick Desaulniers\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of\nthis software and associated documentation files (the \"Software\"), to deal in\nthe Software without restriction, including without limitation the rights to\nuse, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of\nthe Software, and to permit persons to whom the Software is furnished to do so,\nsubject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS\nFOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR\nCOPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER\nIN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\nCONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n\"THE BEER-WARE LICENSE\" (Revision 42):\n wrote this file. As long as you retain this\nnotice you can do whatever you want with this stuff. If we meet some day,\nand you think this stuff is worth it, you can buy me a beer in return.\nNick Desaulniers\n\n", "readmeFilename": "README.md", "homepage": "https://github.com/nickdesaulniers/javascript-playlist-parser", "_id": "playlist-parser@0.0.12", "dist": { "shasum": "4250e5b11771ad68213983bf9bb6ecab64ddf526" }, "_from": "playlist-parser@*", "_resolved": "https://registry.npmjs.org/playlist-parser/-/playlist-parser-0.0.12.tgz" }