Permalink
Browse files

handle no stream url when attempting to open a track audio stream

  • Loading branch information...
1 parent 77b6526 commit d3076f689858ba60f1e07158fcc2cabc308e4775 @olivernn committed Oct 25, 2011
Showing with 6 additions and 2 deletions.
  1. +3 −1 app.js
  2. +3 −1 lib/track.js
View
4 app.js
@@ -40,7 +40,9 @@ app.get('/stream/:track_id', function (request, response) {
response.contentType('application/ogg')
response.header('Access-Control-Allow-Origin', '*')
- track.stream(function (trackStream) {
+ track.stream(function (err, trackStream) {
+ if (err) throw(err)
+
trackStream.pipe(converter.process.stdin)
converter.process.stdout.pipe(response)
})
View
@@ -47,9 +47,11 @@ Track.prototype = {
stream: function (fn) {
var self = this
http.get(optionsForRequest(this.id()), function (res) {
+ if (!res.headers.location) fn(["No stream url for track", this.id()].join(" "))
+
var location = url.parse(res.headers.location)
self.request = http.get(optionsFromLocation(location), function (res) {
- fn(res)
+ fn(null, res)
})
})
},

0 comments on commit d3076f6

Please sign in to comment.