Skip to main content

Posts

Showing posts from March, 2018

Regular expression

Learn about the regular expressions in programming with examples explained in python. link : https://automatetheboringstuff.com/chapter7/ summary  The  ?  matches zero or one of the preceding group. The  *  matches zero or more of the preceding group. The  +  matches one or more of the preceding group. The  {n}  matches exactly  n  of the preceding group. The  {n,}  matches  n  or more of the preceding group. The  {,m}  matches 0 to  m  of the preceding group. The  {n,m}  matches at least  n  and at most  m  of the preceding group. {n,m}?  or  *?  or  +?  performs a nongreedy match of the preceding group. ^spam  means the string must begin with  spam . spam$  means the string must end with  spam . The  .  matches any character, except newline characters. \d ,  \w , and  \s  match a digit, word, or space character, respectively. \D ,  \W , and  \S  match anything except a digit, word, or space character, respectively. [abc]  matches a

working code seeking video on youtube chromecast

var Client                = require('castv2-client').Client; var Youtube               = require('youtube-castv2-client').Youtube; var mdns                  = require('mdns'); //var browser = mdns.createBrowser(mdns.tcp('googlecast')); var sequence = [     mdns.rst.DNSServiceResolve(),     'DNSServiceGetAddrInfo' in mdns.dns_sd ? mdns.rst.DNSServiceGetAddrInfo() : mdns.rst.getaddrinfo({families:[4]}),     mdns.rst.makeAddressesUnique() ]; var browser = mdns.createBrowser(mdns.tcp('googlecast'), {resolverSequence: sequence}); browser.on('serviceUp', function(service) {   console.log('found device "%s" at %s:%d', service.name, service.addresses[0], service.port);   ondeviceup(service.addresses[0]);   browser.stop(); }); browser.start(); function ondeviceup(host) {   var client = new Client();   client.connect(host, function() {     console.log('connected, launching app ...');    

working code for any video url with seek time other than youtube

var ChromecastAPI = require('chromecast-api') var chromeCast = function(content  , contentType , timeseek){ var browser = new ChromecastAPI.Browser() console.log("browser api"); browser.on('deviceOn', function (device) {   var urlMedia = 'http://commondatastorage.googleapis.com/gtv-videos-bucket/big_buck_bunny_1080p.mp4';   console.log("\n content is "+ content);;   device.play(content, 0, function () {     console.log('Playing in your chromecast ' + timeseek)       if (timeseek) {       device.seek(timeseek,function (err) {               if (err) console.log('Seek forward: ERROR')               else console.log('Seek forward: SUCCESS')           })     }   }) }) } module.exports.chromeCast = chromeCast;

working code for casting youtube

var Client                = require('castv2-client').Client; var Youtube               = require('youtube-castv2-client').Youtube; var mdns                  = require('mdns'); //var browser = mdns.createBrowser(mdns.tcp('googlecast')); var sequence = [     mdns.rst.DNSServiceResolve(),     'DNSServiceGetAddrInfo' in mdns.dns_sd ? mdns.rst.DNSServiceGetAddrInfo() : mdns.rst.getaddrinfo({families:[4]}),     mdns.rst.makeAddressesUnique() ]; var browser = mdns.createBrowser(mdns.tcp('googlecast'), {resolverSequence: sequence}); browser.on('serviceUp', function(service) {   console.log('found device "%s" at %s:%d', service.name, service.addresses[0], service.port);   ondeviceup(service.addresses[0]);   browser.stop(); }); browser.start(); function ondeviceup(host) {   var client = new Client();   client.connect(host, function() {     console.log('connected, launching app ...');    

Cast youtube video using node js on chromecast

Cast youtube video using node js on chromecast Use this forked git repo which uses latest protocols and thus helps to make the old repo work https://github.com/irfanhabib/youtube-castv2-client after doing npm and installing all libraries download the files in repo and replace them in the folder of node_modules "youtube-castv2-client"

chrome-cast cast Ubuntu issue, avahi error getaddrinfo

avahi ubuntu error getaddrinfo Error: *** WARNING *** The program 'node' uses the Apple Bonjour compatibility layer of Avahi. *** WARNING *** Please fix your application to use the native API of Avahi! *** WARNING *** For more information see <http://0pointer.de/avahi-compat?s=libdns_sd&e=node> *** WARNING *** The program 'node' called 'DNSServiceRegister()' which is not supported (or only supported partially) in the Apple Bonjour compatibility layer of Avahi. *** WARNING *** Please fix your application to use the native API of Avahi! *** WARNING *** For more information see <http://0pointer.de/avahi-compat?s=libdns_sd&e=node&f=DNSServiceRegister> events.js:182       throw er; // Unhandled 'error' event       ^ Error: getaddrinfo -3008     at errnoException (/home/kishlay/node_modules/mdns/lib/resolver_sequence_tasks.js:199:11) Solution reference: https://github.com/agnat/node_mdns/issue