Created
June 9, 2013 04:33
-
-
Save queso/5737663 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Exception while invoking method 'play' [object Object] | |
at Object.Future.wait (/Users/josh/.meteorite/meteors/meteor/meteor/5d736d4bf0448c7db1f9b47124dfafc34a9631bb/dev_bundle/lib/node_modules/fibers/future.js:322:15) | |
at monitorPlay (app/server/play.coffee.js:36:18) | |
at Meteor.methods.play (app/server/play.coffee.js:22:12) | |
at maybeAuditArgumentChecks (app/packages/livedata/livedata_server.js:1367:12) | |
at _.extend.protocol_handlers.method.exception (app/packages/livedata/livedata_server.js:596:20) | |
at _.extend.withValue (app/packages/meteor/dynamics_nodejs.js:31:17) | |
at app/packages/livedata/livedata_server.js:595:44 | |
at _.extend.withValue (app/packages/meteor/dynamics_nodejs.js:31:17) | |
at _.extend.protocol_handlers.method (app/packages/livedata/livedata_server.js:594:48) | |
at _.extend.processMessage.processNext (app/packages/livedata/livedata_server.js:488:43) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var monitorPlay; | |
Meteor.methods({ | |
play: function(mediaFileId, deviceId) { | |
var airplay, ap_device, content, device, mediaFile; | |
airplay = Airplay.createBrowser(); | |
device = Devices.findOne({ | |
_id: deviceId | |
}); | |
mediaFile = MediaFiles.findOne({ | |
_id: mediaFileId | |
}); | |
ap_device = _.find(DeviceList, function(d) { | |
return d['info_']['host'] === device['host']; | |
}); | |
content = "http://10.0.1.201:81/" + (encodeURI(mediaFile['path'])); | |
console.log("Content URL: " + content); | |
ap_device.play(content, 0); | |
return monitorPlay(ap_device, mediaFile); | |
} | |
}); | |
monitorPlay = function(device, mediaFile) { | |
var cb, future, loading, percentage, res, running, _results; | |
loading = true; | |
running = false; | |
console.log("Starting play monitor"); | |
future = new Future(); | |
cb = future.resolver(); | |
while (loading) { | |
device.status(cb); | |
res = future.wait(); | |
console.log(res.inspect); | |
if (res.duration > 0) { | |
console.log("Loaded"); | |
loading = false; | |
running = true; | |
} | |
} | |
_results = []; | |
while (running) { | |
device.status(cb); | |
res = future.wait(); | |
console.log("Running"); | |
if (res.duration > 0) { | |
console.log("Updating play percentage"); | |
percentage = new Number((res.position / res.duration) * 100); | |
_results.push(mediaFile.update({ | |
viewed_percentage: percentage.toPrecision(3) | |
})); | |
} else { | |
running = false; | |
_results.push(console.log("Finished playing " + mediaFile.name)); | |
} | |
} | |
return _results; | |
}; | |
Meteor.startup(function() { | |
Future = Npm.require('fibers/future'); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment