2015-10-15 15:25:10 +00:00
|
|
|
spawn = require("child_process").spawn
|
|
|
|
services = require("../services")
|
|
|
|
config = require("../config")
|
2015-10-27 00:14:55 +00:00
|
|
|
wc = require("webchimera.js")
|
2015-10-15 15:25:10 +00:00
|
|
|
StreamSplitter = require("stream-splitter")
|
|
|
|
|
|
|
|
module.exports = class VLCService extends services.Service
|
|
|
|
dependencies: [
|
|
|
|
"pulseaudio"
|
|
|
|
]
|
|
|
|
constructor: -> super "VLC",
|
2015-10-27 00:14:55 +00:00
|
|
|
###
|
|
|
|
# Starts an instance of VLC and keeps it ready for service.
|
|
|
|
###
|
2015-10-15 15:25:10 +00:00
|
|
|
start: (cb) ->
|
2015-10-27 00:14:55 +00:00
|
|
|
if @_instance
|
|
|
|
cb? null, @_instance
|
2015-10-15 15:25:10 +00:00
|
|
|
return
|
|
|
|
|
|
|
|
calledCallback = false
|
|
|
|
|
2015-10-27 00:14:55 +00:00
|
|
|
instance = wc.createPlayer [
|
|
|
|
"--aout", "pulse",
|
|
|
|
"--no-video"
|
|
|
|
]
|
|
|
|
instance.audio.volume = 50
|
2015-10-15 15:25:10 +00:00
|
|
|
|
2015-10-27 00:14:55 +00:00
|
|
|
@_instance = instance
|
|
|
|
cb? null, @_instance
|
2015-10-15 15:25:10 +00:00
|
|
|
|
2015-10-27 00:14:55 +00:00
|
|
|
###
|
|
|
|
# Shuts down the VLC instance.
|
|
|
|
###
|
2015-10-15 15:25:10 +00:00
|
|
|
stop: (cb) ->
|
2015-10-27 00:14:55 +00:00
|
|
|
if not @_instance
|
2015-10-15 15:25:10 +00:00
|
|
|
cb?()
|
|
|
|
return
|
|
|
|
|
2015-10-29 01:24:11 +00:00
|
|
|
@_instance.stop()
|
|
|
|
|
2015-10-27 00:14:55 +00:00
|
|
|
# TODO: Is there even a proper way to shut this down?
|
|
|
|
@_instance = null
|
2015-10-15 15:25:10 +00:00
|
|
|
|
|
|
|
cb?()
|
|
|
|
|