Bläddra i källkod

add quickstart

boyska 2 år sedan
förälder
incheckning
a7253dc6c8
2 ändrade filer med 48 tillägg och 1 borttagningar
  1. 47 0
      doc/tutorials/quickstart.md
  2. 1 1
      package.json

+ 47 - 0
doc/tutorials/quickstart.md

@@ -0,0 +1,47 @@
+Using radiomanifest is pretty simple. In an ideal usecase, you can easily do this:
+
+```javascript
+const radiomanifest = require('radiomanifest')
+const radio = radiomanifest.get('http://myradio.com/')
+console.log(radio.getName())
+```
+
+Now we have `radio`, a {@link Radio} object, which can be seen as the "center" of our data. From here, we can
+get more data. How about this?
+
+```javascript
+const show = radio.getShowAtTime()
+if (show !== null) {
+  console.log(show.getName())
+} else {
+  console.log("Nothing special going on right now, sorry")
+}
+```
+
+## Streaming
+
+The first thing we could want to do is just to *play* the radio.
+
+```javascript
+var urls = await radio.pickURLs()
+console.log(urls)
+```
+
+and here we go! This is a list of URLs that the radio is indicating to us as their preferred ones. Why not a
+single one? Well, this could include different servers, so that the client itself can act as load-balancers.
+
+## Shows
+
+Another nice thing you might want to do, is to display a list of all the shows that the radio is broadcasting.
+Our {@link Radio} keeps track of those, and for each show we can have useful metadata. See {@link RadioShow}
+for more details.
+
+```javascript
+var shows = radio.getShows()
+console.log(shows.map(s => s.getName()))
+```
+
+## Conclusions
+
+I hope this tutorial helped you get your feet wet. Hopefully, using radiomanifest you'd be able to create
+great webapps that work on *any* webradio (well, any webradio that supports radiomanifest, at least).

+ 1 - 1
package.json

@@ -14,7 +14,7 @@
     "test": "npm run test:node && npm run test:browser",
     "test:node": "mocha",
     "test:browser": "karma start --single-run --browsers ChromeHeadless,FirefoxHeadless karma.config.js",
-    "docs": "jsdoc -c ./jsdoc.conf.json --package ./package.json .",
+    "docs": "jsdoc -c ./jsdoc.conf.json --tutorials doc/tutorials/ --package ./package.json .",
     "build": "webpack"
   },
   "author": "",