UNPKG

neo-neo-bblessed

Version:

A fork of neo-blessed (which is a fork of blessed) with bug fixes and maintenance.

3 lines (2 loc) 1.55 kB
var c=require("child_process"),f=require("./node"),o=require("./box"),h=require("./terminal");function i(t){var e=this,r,s;if(!(this instanceof f))return new i(t);if(t=t||{},o.call(this,t),this.exists("mplayer"))r="mplayer",s=["-vo","caca","-quiet",t.file];else if(this.exists("mpv"))r="mpv",s=["--vo","caca","--really-quiet",t.file];else return this.parseTags=!0,this.setContent("{red-fg}{bold}Error:{/bold} mplayer or mpv not installed.{/red-fg}"),this;var n={parent:this,left:0,top:0,width:this.width-this.iwidth,height:this.height-this.iheight,shell:r,args:s.slice()};this.now=Date.now()/1e3|0,this.start=n.start||0,this.start&&(r==="mplayer"?n.args.unshift("-ss",this.start+""):r==="mpv"&&n.args.unshift("--start",this.start+""));var l=process.env.DISPLAY;delete process.env.DISPLAY,this.tty=new h(n),process.env.DISPLAY=l,this.on("click",function(){e.tty.pty.write("p")}),this.on("resize",function(){e.tty.destroy();var a={parent:e,left:0,top:0,width:e.width-e.iwidth,height:e.height-e.iheight,shell:r,args:s.slice()},p=(Date.now()/1e3|0)-e.now;e.now=Date.now()/1e3|0,e.start+=p,r==="mplayer"?a.args.unshift("-ss",e.start+""):r==="mpv"&&a.args.unshift("--start",e.start+"");var d=process.env.DISPLAY;delete process.env.DISPLAY,e.tty=new h(a),process.env.DISPLAY=d,e.screen.render()})}i.prototype.__proto__=o.prototype,i.prototype.type="video",i.prototype.exists=function(t){try{return!!+c.execSync("type "+t+" > /dev/null 2> /dev/null && echo 1",{encoding:"utf8"}).trim()}catch(e){return!1}},module.exports=i; //# sourceMappingURL=video.js.map