JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 301
  • Score
    100M100P100Q84330F
  • License Dual MIT & Beerware

Parse m3u, pls, and asx

Package Exports

  • playlist-parser

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (playlist-parser) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

#javascript-playlist-parser# ##Parse m3u, pls, and asx in JavaScript##

##Usage##

###Browser###

<script src="parser.js"></script>
// Fetch the playlist file, using xhr for example
var xhr = new XMLHttpRequest();
xhr.open("GET", "my_playlist.m3u");
xhr.overrideMimeType("audio/x-mpegurl");
xhr.onload = parse;
xhr.send();

// Parse it
function parse () {
  var playlist = M3U.parse(this.response);
  var audio = new Audio();
  next(audio, playlist, 0);
};

// Play each song after a song finishes
function next (audio, playlist, i) {
  if (i < playlist.length) {
    audio.src = playlist[i++].location;
    audio.onended = next.bind(null, playlist, i);
    audio.play();
  }
};

###Node.js### npm install XXX

var parsers = require("XXX");
var M3U = parsers.M3U;

var fs = require("fs");
var playlist = M3U.parse(fs.readFileSync("my_playlist.m3u", { encodeing: "utf8" }));

##License##

This software is dual licensed under the MIT and Beerware license.

The MIT License (MIT)

Copyright (c) 2013 Nick Desaulniers

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

"THE BEER-WARE LICENSE" (Revision 42): ndesaulniers@mozilla.com wrote this file. As long as you retain this notice you can do whatever you want with this stuff. If we meet some day, and you think this stuff is worth it, you can buy me a beer in return. Nick Desaulniers