Build your own Google TV Using Raspberry Pi, NodeJS and Socket.io by Donald Derek

IPTV Restream that means you use my stream with your server and your customer use from your server. The total user can use your IPTV service depends on...

 

Hi fellas and welcome to your Make your ownGoogle Television set workshop, Okay who amongst you is aware of what on earth is a Google Tv set a Google Tv set is actually a hardwaredevice; you link it by HDMI on your Television, and you also're TV becomeslike a sensible Tv set you could check out YouTube videos on it, playgames and It is really, no it is not the nexus cube, It is Just about like the nexus cube nonetheless it's calledthe Google TV now there doing in addition a hardwaredevice produced by Sony you link by HDMI towards the Television and they'redoing a standalone Television set which has a chip in it that serves the Google Tv set we are form ofreplicating this around the Raspberry Pi, ok but for now, we crafted; I constructed a YouTubedownloader so that you can look at YouTube movies around the Raspberry Pi and Handle them withyour mobile device so just before digging further inthe specialized stuff, I'll teach you a smalldemo, Okay To start with I'm going to SSH on the Raspberry Pi thatyou can provide it instructions Okay, 102 and the username is pi, so by default the RaspberryPi has this default username which happens to be pi and also the password isRaspberry, Alright so we are In the pi this my home directory, ok, I've set up the appliance inside homeNode Google Tv set Alright, now I launch the Node application byexecuting this command and increase the & image to operate it from the track record.

Now there is a large amount ofways to operate the NodeJs application in the qualifications but within the Raspberry Pi, It truly is thefastest way, ok, because it was managing And that i did a previousdemo, yes We will in more facts concerning this butthis is simply to operate the demo, We'll talk about Node, regarding how theremote is working, about everything ah but we have to have it into, ok and now I'mgoing to operate chromium in Kiosk manner and that's why Don't fret fellas; we are heading togo by this, ok and We've this mistake this error are unable to opendisplay, why due to the fact I am executing the chromium browser from SSH, Alright so I would like tocheck my natural environment variables and insert to them Exhibit so I click on and typeexport Show equals 0.

0 points for the screen and after that I execute thisand We'll see that our wonderful Television isup and functioning now this unappealing bar is for the reason that I Beforehand shut chromium in a foul wayso give it a 2nd and its loading and that'sit so This can be our popular Television set, mainly I just did the observe but I'm planning to dolisten and Participate in Later on the temperature no, I created the whole point but the look I took it from the web I usedthese stunning icons yea like you can find this icon which is this icon you understand, superior artistscopy good artists steal, that is it everywhereok so I'll open up tree manner, recognize this, this isn't a native World-wide-web application but it really has abeautiful icon, Okay now, as you'll be able to see I'm swiping correct and itsmoving ok And that i swipe still left and it moves remaining now I'm likely to look for a Motion picture Okay it'sshowing with you? Alright and I'll click look at this script is referred to as YouTube downloader;We'll also go through it.

It downloadsthe Film from YouTube and it will save it so It truly is versus any YouTube insurance policies but it'sRaspberry Pi and It is an open up org fellas And so the workaround is to utilize the script, downloadthe Motion picture and Enjoy it enjoy yes it might Perform as much as 1080p higher definitionmovie as well as movie is loading, this is the Harlem shake at Lamba Labs that Imissed, if I wish to pause the Motion picture I just tap and it pauses, I tap all over again to resume andif I need to exit I tap about the header now thisis my user knowledge relating to this you realize, I could not make like a suitable remotewith buttons and stuff like that, so I stated whynot applying swipe gestures and tap and things like this, Alright Therefore the demo is ok, the demo is Functioning Permit the workshop begin: Alright To begin with I will provide you with brieflythe blueprint on the Raspberry Pi which is a simplething to complete now, there is certainly the HDMI port, USB, u have two USB, LAN, the modelB includes 512mbytes of ram the model A includes 256mbytes you might have theaudio, the video clip, LEDs, as well as the GPIO which you can plan and the hardwarestuff design b with 2 USBs design A in addition as well as the SD card now if youfirst purchase you might be Raspberry Pi, You must drop by RaspberryPi.

org and down load the Alright, there are a lot of Linuxdistributions you could boot to the SD card, they're all illustrations or photos, I am employing Raspbianbecause It is probably the most acknowledged and there is a ton ofthese Distros are dependant on Debian, all of us knowDebian, but this Raspbian is specially made forthe Raspberry Pi with loads of softwares and applications and driverson it, Alright now if you first obtain you are Raspberry Pi you should copy thisimage and execute a couple of codes to make the picture bootable on the SD card Okay, we'renot going to endure this these days, but you will find a lotof tutorials on the internet I did not modify it, left it just how it truly is Alright, hardware ingredient completed, configuration andsoftware employed Okay we discussed Raspbian, Of course the YouTube downloader, the script, YYouTube-dl ah sorry, no no, YouTube downloader, Sure it's a very know script todownload YouTube movies on Ubuntu Debian Linux ok, needless to say It is really forbidden by Google, You can't obtain YouTube movies, It's important to stream them Of course particularly, You need to updateit when they change, the fellows adjust Okay It really is quite simple to downloada YouTube Motion picture working with that; I'll head over to YouTube, that'sa Film, downloading video clip, and It truly is downloading, now I'll halt it, becausewe have confined quota ok, Certainly It really is messy Okay, it dependson the hardware, Omx participant as well as the Motion picture started out, Omx participant offers a established ofshortcuts, such as I can end and play;I am tapping on my cellular I comprehend it's a really pleasant music, we will not watchit: p Alright and now I will describe a little bit aboutthe architecture employed In this particular job and why, Alright as you could see its all JavaScript, JavaScript to the frontend, JavaScript about the backend, correct, This is why I had to use NodeJs, now, whoknows about NodeJs, come here guys, inform us somewhat about NodeJs and why did I use itin this task I advised u why :p Piotr: alright, so my name is Piotr Yordanovand, perfectly the folks who know me know that I'ma fanatic of type of Node since I have beenusing Node for some time, but there is certainly, so I'm going to let you know why, tothe code directly, Okay so NodeJs in essence is, so chrome essentially operates something known as v8 it is a JavaScript engine; it's the enginethat understands and interprets JavaScript so there'sthis crazy man who like 4 yrs back took this v8 and set it about the server andnow all away from a unexpected you are able to summon you might be terminal, you can start becoming a member of interpretingJavaScript the splendor about this is that you've got the powerfulv8 engine carrying out this, Okay so ignore this, as programmers what is actually fascinating about itis that Formerly until currently if you do not useNode and you need to create a World-wide-web application, you'regoing to become utilizing any sort of other language regardless, based upon your flavor, python, it might be php, it may be ruby, and it may bewhatever, and each language, even Java, each languagehas a framework along with it that is certainly like for Website, Ruby has Rails, Php has a good deal ofthem coding evenings or whatever cake, python has jungleflask and the rest Node just isn't a language and Node isnot a framework, Node is simply Node, a JavaScript interpreter, That is what it is actually, youcan't Examine Node for the Other folks having said that that staying reported, Node has pair offrameworks available which are sort of attention-grabbing even so the attention-grabbing Portion of working with Node isthat you might be employing JavaScript, when you forget about aboutperformance, because at the end working day how can we really proveif it's additional profound as opposed to Other people? It does have limits, due to the fact Node issingle threaded, so that is superior for io terrible forCPU intense duties, ideal? So when Derek was describing to mehow he did the app, what is really interesting isthat, do I take a look at socket? Derek: Sure Piotr: thisis called socket.

io, now any of you, have you finished World-wide-web do the job before? Do you knowabout Ajax? Audience: yea Piotr: when you don'tknow, just To put it simply, Ajax is largely on the browser and I would like tolet's say improve what is actually going on in excess of here with out loading the website page, but I want to fetchcontent from someplace, it can be my server or any server, so I makean Ajax ask for, Ajax is nice, but it really's kindof bothersome if you publish it, your situation is Protected, probably, Idon't know but what is actually going on in this straightforward socket.

iowhat truly takes place is it results in sockets, so now, should you be around the shopper, you connectto a socket to the server and it will not block, it just emits events, quickly event driven, the factor about socket.

io Particularly is thatit's purely in JavaScript so It is really like, it natively is effective in Node, and World-wide-web sockets ingeneral, they don't natively function in some other language there is library~ so what Derek is undertaking around here is: he wantsto be capable to Handle from his controller whichis the cellular phone he wants to control the browser or Raspberry Pi and it must be Stay, it should be functions taking place “swipe” that's anevent, so on my pi I need to know that's anevent and make one thing about it so he could have completed it in Ajax but he is doingit employing socket mainly because, yea actually that's the syntax, It really is basically muchmore less complicated, and It is really like built-in in native inside the ecosystem he is utilizing, so socketis just one solid point and the opposite powerful place isthat he just employed JavaScript on the pi, Derek: onthe socket point, would you don't forget producing a code, an Ajax code natively, ahnot natively but devoid of working with jQuery?it is a lengthy system; you have to satisfy lots ofbrowsers like Online explorer, stuff like that, so jQuery, they did Ajax that is asimple Instrument to access Ajax and gets and write-up and whatsoever, now socket.

io did exactly the same issue for Internet sockets, and not merely for World-wide-web sockets, forreal-time applications like socket.

io supports even IE6 which has no World wide web sockets in it Piotr:It's Flash Derek: Of course , so it falls into A further technologies, like flash or Xhr polling, long polling, stuff likethat Piotr: think they actually use Ajax Derek: andthey use Ajax at the same time, socket.

io Marc: yea it deprecates to Ajax, particularly, sothat's it Piotr: so socket.

io was the sturdy stage, one other solid place is me doingJavaScript in each place, ideal Derek: as well as the thirdpoint is spawning Piotr: that is in fact a fascinating andfunny issue what occurred with Node, is usually that Swiftly you can in fact builda shell script, working with JavaScript, in the event you ever needto connect with a thing in your terminal, basically there is certainly this perform called spawnDerek: Spawn child course of action, module Piotr: you've got your application, that has a programrunning; it spawns A different system and run a command in it, and you'll startpiping effects from one particular application to a different, should you understand about piping, yea so That is what'scool over it Derek: to make sure that's The key reason why why I'm employing NodePiotr: did I overlook anything at all? Derek: no that is fundamentally it Piotr: okDerek: of course, about the entrance close, I exploit html, CSS and JavaScript, And that i use CSS3 and html5 CSS3 on the mobiledevice to accomplish the CSS transforms stuff.

Piotr: which a person? Derek: on the app Okay, just one past factor, nowwe are going into a totally distinctive segment and that is the entrance conclude ofthe application while undertaking this project I learned Piotr: Github:p Derek: I found Github for mac, no :p Okay, Incidentally this undertaking is open up supply;you may fork me on Github, and have your very own versionof the Raspberry Tv set so right before going deeper while in the app construction, I'll inform you a little concerning the trick that Idiscovered while accomplishing the online mobile app, ok you already know, there is certainly indigenous applications and mobileweb applications and there's Phonegap that's hybridso I have, yea ok, as you may see here, the iconof the application what? Yes, can you open up the application remember to, ok? there is aflash monitor, and it seems like a native app, there's no browser, why, due to this, I went on the apple safari documentation, and I readthe next: when you incorporate the Metatag with your html application mobile World-wide-web application title remote, once you go to safari, you check out this backlink, youcan click on add to residence display screen, correct which title will come by default, the image, the icon will arrive, and we change the default icon by declaring Ralequal apple contact icon as well as the startup image that's the flash impression is apple contact startupimage so these Metatags and links are provided by apple, so we are form of noticing what theywant to try and do Down the road you know They are leaping into webtechnologies and JavaScripts to produce native applicationsthat's my notion about mobile advancement, and not too long ago Firefox cellular OS, in case you readabout it, It can be all about producing Individuals nativemobile purposes employing web technologies Piotr: It can be really a system build on html5Derek: Indeed, just, Viewers: and do you think if on android itwill be chrome OS? Derek: Of course, I hope so: p no it is the samehouse in any case, yea that is it, I am utilizing the logoas Svg, I don't know why :p Okay, now let's return to Node, now back again tothe core of the applying, as it is possible to see the composition is very simple I have a publicdirectory, in it you can find the html, JavaScript, photos, fonts, CSS, all All those things, andmy server is barely this code, It truly is app.

js, Alright now if you're building on Node, youhave anything called npm, npm is usually a pool of modules and libraries build on Node so Enable'ssay I want Omx participant, That is what I did, and shockingly, it worked, I had been wanting fora way to manage Omx player with out crafting the whole core so I found this, Okay, how canI use it? I go to my dependencies file; ah not thisone, that's the Node module, yea offer.

Json, here it is possible to specify a lot of variables, thename of the software, whichever, dependencies, that's what's crucial, I'm working with express, I'll speak about it, jade, no I am not utilizing jade Ok, fantastic, can it be crystal clear, effectively I'm goingto shift to Github, the code is on Github, much better ok so Convey, jade, I'm not usingjade, socket.

io Omx controller, basically so why do we do this? on Node, you compose downyour dependencies on just one file, and you also go in your terminal, for your Node Listing whichis this one particular below, and seem , what I'm going to do, I will be crazy , I am heading todelete my project Okay, I'm going to explain to it sudo, and what, I deleted the Node modulesnow the appliance is not really Performing any longer so I go ahead and create down npm put in, and what transpires is it read through the dependencies file and downloads all the dependencies andthe dependencies of your dependencies so you don't do something, you can deploy your application with a server, with a growth on your developer friendyou know anyplace and you merely ~~~~~ these, justification me Viewers: why don't you employ apt-get? Derek: apt-get is for Ubuntu and Debian, youknow to download stuff, npm is analogous it exactly the same thought but placed on the net particularly, but be aware, these dependencies are distinct in the dependencies you will be pondering aboutthese dependencies are for Node, using npm as opposed to apt-get, but it's the very same conceptand that's what's wonderful about Node Alright so immediately after downloading the dependencies you'll geta folder called Node modules, ok also to use these modules, you have to have to have them, soI'm gonna say var Specific demand Specific app equal Categorical creates the Convey server, but it doesn't, but I ought to demand http that's by default there and make serverand wrap it with application, so within it, inside create server, There exists your Specific server, now if I don't want to implement Specific, which will save loads of time, I'm able to predefine my serverto provide the information that I want, Okay but listed here I am applying Convey for these causes, route, never intellect, io is socket.

io, and socket.

io listens towards the server also to the shopper soyou will need socket.

io with your server aspect and socket.

io with your front finish spawn is alsolike Piotr said, a native module and Node, you need not download it Omx participant isto Management the Omx player within the Raspberry Pi now every single Categorical server demands a littlebit of configuration specifying the port and stuff like that now notice in this article I'm usingprocess.

surroundings.

testport Okay, now if I return into this, And that i key in env it stayson the environments, now if I increase check port, export test port equal 8080 ok, in this manner wheneverI deploy my application, it is going to perform, you realize Therefore if on my staging server I'm utilizing the port8080 but on my genuine server I am using the default port eighty, correct so I am able to do that by specifyingthis in the method atmosphere, like I am able to obtain this through Node by undertaking this process.

env.

thevariable, indicating if I console .

load now approach .

env Show over the Raspberry Pi, it willshow, 0.

0 app.

person.

omx That is for your Omx participant, for instance I want to pause https://iptvrestream.net the movie, if I'm working with Convey, I am able to condition that express.

use.

omx , it is going to generate for me these a few requests, that I can perform, pause, Give up and start now the routes, commonly, what you can do on Node, you need a boiler plate to begin, proper, you don't want to jot down the unexciting code againand over and over, so what Categorical does, which is the Node server, To start with youshould put in it like that, npm and install express, and supply the minus g parameter, minus g will install it globally, so now if I want to make a new venture, ~~~, Permit'sgive