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 men and welcome on the Establish your ownGoogle Television set workshop, ok who between you appreciates what is a Google Television a Google Television set is a hardwaredevice; you connect it by HDMI towards your TV, and you're Television becomeslike a sensible Tv set you'll be able to enjoy YouTube video clips on it, playgames and It is really, no it is not the nexus cube, It is really Nearly similar to the nexus cube but it really's calledthe Google Television now there undertaking also a hardwaredevice created by Sony that you just link by HDMI to your Tv set plus they'redoing a standalone Television using a chip in it that serves the Google Television we're kind ofreplicating this within the Raspberry Pi, Alright but for now, we developed; I created a YouTubedownloader so you're able to check out YouTube videos around the Raspberry Pi and control them withyour cell gadget so ahead of digging further inthe technical things, I'll tell you about a smalldemo, Alright For starters I'm going to SSH to the Raspberry Pi thatyou can provide it instructions Okay, 102 as well as the username is pi, so by default the RaspberryPi has this default username that's pi and also the password isRaspberry, Alright so we're inside the pi this my home directory, ok, I have installed the appliance within homeNode Google Television set ok, now I launch the Node software byexecuting this command and add the & symbol to run it within the background.

Now there is a whole lot ofways to run the NodeJs software while in the track record but to the Raspberry Pi, It is thefastest way, Alright, since it was functioning And that i did a previousdemo, yes We'll in additional specifics about this butthis is simply to operate the demo, We'll speak about Node, regarding how theremote is working, about all the things ah but we have to have it into, ok and now I'mgoing to operate chromium in Kiosk mode and that is why Don't fret guys; we're going togo via this, Alright and We have now 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 environment variables and insert to them Exhibit so I click on and typeexport Screen equals 0.

0 details towards the screen then I execute thisand We will see that our gorgeous Tv set isup and functioning now this hideous bar is simply because I previously closed chromium in a foul wayso give it a 2nd and its loading Which'sit so this is our famed Television, fundamentally I just did the check out but I am intending to dolisten and Enjoy Sooner or later the weather no, I produced the whole issue but the design I took it from the online market place I usedthese stunning icons yea like you can find this icon that is this icon you know, great artistscopy fantastic artists steal, which is it everywhereok so I will open tree manner, detect this, it's not a native World wide web application nevertheless it has abeautiful icon, Alright now, as you could see I'm swiping suitable and itsmoving ok and I swipe left and it moves remaining now I am going to look for a Film Okay it'sshowing with you? ok and I'll click enjoy this script known as YouTube downloader;We will also go through it.

It downloadsthe Motion picture from YouTube and it saves it so It really is towards any YouTube guidelines nevertheless it'sRaspberry Pi and It truly is an open org guys And so the workaround is to use the script, downloadthe Motion picture and Enjoy it view Indeed it could Participate in up to 1080p significant definitionmovie as well as Film is loading, this is the Harlem shake at Lamba Labs that Imissed, if I would like to pause the movie I just tap and it pauses, I faucet once again to resume andif I would like to exit I tap around the header now thisis my consumer working experience relating to this you are aware of, I couldn't make like a suitable remotewith buttons and things like that, so I explained whynot working with swipe gestures and faucet and things such as this, ok Therefore the demo is fine, the demo is Doing work Allow the workshop start out: Okay Firstly I'll tell you about brieflythe blueprint on the Raspberry Pi and that is a simplething to do now, there is the HDMI port, USB, u have two USB, LAN, the modelB includes 512mbytes of ram the model A includes 256mbytes you've got theaudio, the video, LEDs, as well as the GPIO which you can software along with the hardwarestuff design b with 2 USBs design A in addition as well as SD card now if youfirst obtain you are Raspberry Pi, You must visit RaspberryPi.

org and download the ok, There are many of Linuxdistributions which you can boot over the SD card, they're all photos, I am making use of Raspbianbecause It is one of the most regarded and there is a large amount ofthese Distros are dependant on Debian, we all knowDebian, but this Raspbian is specially created forthe Raspberry Pi with lots of softwares and applications and driverson it, Okay now whenever you very first obtain you might be Raspberry Pi you might want to duplicate thisimage and execute two or three codes to make the picture bootable over the SD card Okay, we'renot gonna undergo this right now, but there are a lotof tutorials on the net I did not change it, remaining it the way it really is ok, components ingredient finished, configuration andsoftware used ok we mentioned Raspbian, Of course the YouTube downloader, the script, YYouTube-dl ah sorry, no no, YouTube downloader, Certainly It is a very know script todownload YouTube movies on Ubuntu Debian Linux Alright, of course It truly is forbidden by Google, you cannot obtain YouTube videos, It's important to stream them Indeed just, You should updateit when they alter, the guys change Alright It really is quite simple to downloada YouTube Film working with that; I will visit YouTube, that'sa movie, downloading video, and it's downloading, now I'll halt it, becausewe have confined quota Alright, Indeed it's messy ok, it dependson the components, Omx participant and also the Film started off, Omx player supplies a set ofshortcuts, one example is I am able to stop and Engage in;I am tapping on my mobile I realize it's an exceedingly pleasant tune, we won't watchit: p ok and now I'm going to explain a bit aboutthe architecture made use of During this task and why, Alright as you may see its all JavaScript, JavaScript within the frontend, JavaScript about the backend, correct, that's why I had to use NodeJs, now, whoknows about NodeJs, arrive right here fellas, notify us slightly about NodeJs and why did I use itin this project I informed u why :p Piotr: alright, so my name is Piotr Yordanovand, well the those who know me know that I'ma fanatic of form of Node simply because I've beenusing Node for quite a while, but you can find, so I'm going to inform you why, tothe code instantly, ok so NodeJs mainly is, so chrome in fact operates one thing named v8 it's a JavaScript engine; it is the enginethat understands and interprets JavaScript so there'sthis crazy guy who like 4 decades ago took this v8 and place it to the server andnow all away from a sudden you can summon you are terminal, you can start signing up for interpretingJavaScript the beauty about it is that you have the powerfulv8 motor doing this, Okay so ignore this, as programmers what is exciting about itis that Formerly until these days if you don't useNode and you need to produce a World-wide-web application, you'regoing to be applying virtually any other language Irrespective, depending on your flavor, python, it might be php, it may be ruby, and it could possibly bewhatever, and each language, even Java, each languagehas a framework in addition to it that is definitely like for web, Ruby has Rails, Php has a great deal ofthem coding evenings or what ever cake, python has jungleflask and The remainder Node is just not a language and Node isnot a framework, Node is simply Node, a JavaScript interpreter, That is what it truly is, youcan't Review Node for the Other individuals even so that staying reported, Node has few offrameworks around that are kind of attention-grabbing although the interesting Portion of employing Node isthat you're using JavaScript, in the event you neglect aboutperformance, since at the tip working day how can we actually proveif It truly is additional profound compared to the Other individuals? It does have constraints, because Node issingle threaded, so that's great for io bad forCPU intense jobs, correct? So when Derek was describing to mehow he did the app, what's genuinely interesting isthat, do I talk about socket? Derek: Of course Piotr: thisis called socket.

io, now any of you, Have you ever carried out Website work before? Does one knowabout Ajax? Viewers: yea Piotr: if you don'tknow, just To put it simply, Ajax is essentially within the browser and I want tolet's say alter what's going on around below with no loading the webpage, but I choose to fetchcontent from someplace, it could be my server or any server, so I makean Ajax ask for, Ajax is sweet, but it's kindof frustrating when you create it, the situation is Risk-free, maybe, Idon't know but what's occurring in this simple socket.

iowhat seriously takes place is always that it results in sockets, so now, if you are about the shopper, you connectto a socket over the server and it won't block, it just emits gatherings, quickly occasion driven, the detail about socket.

io Specially is thatit's purely in JavaScript so It really is like, it natively will work in Node, and World wide web sockets ingeneral, they do not natively do the job in some other language there is library~ so what Derek is doing around Here's: he wantsto have the capacity to Management from his controller whichis the phone he desires to control the browser or Raspberry Pi and it has to be Stay, it should be activities taking place “swipe” that's anevent, so on my pi I want to realize that's anevent and make a little something over it so he might have performed it in Ajax but he is doingit utilizing socket mainly because, yea actually that's the syntax, It can be in fact muchmore less difficult, and It truly is like built-in in indigenous from the ecosystem he's using, so socketis a single solid position and one other powerful issue isthat he just utilised JavaScript about the pi, Derek: onthe socket issue, does one bear in mind composing a code, an Ajax code natively, ahnot natively but without using jQuery?it is a lengthy course of action; You should fulfill a good deal ofbrowsers like Web explorer, things like that, so jQuery, they did Ajax that is asimple Device to entry Ajax and receives and submit and no matter what, now socket.

io did precisely the same point for World-wide-web sockets, and not only for web sockets, forreal-time programs like socket.

io supports even IE6 that has no Internet sockets in it Piotr:It's Flash Derek: yes , so it falls into One more know-how, like flash or Xhr polling, lengthy polling, stuff likethat Piotr: Consider they really use Ajax Derek: andthey use Ajax likewise, socket.

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

io was the sturdy position, the other robust issue is me doingJavaScript in each and every put, ideal Derek: as well as thirdpoint is spawning Piotr: that is truly an interesting andfunny thing what occurred with Node, is all of a sudden you can actually builda shell script, utilizing JavaScript, for those who ever needto get in touch with a thing in your terminal, fundamentally you will find this purpose known as spawnDerek: Spawn child procedure, module Piotr: you may have your app, which has a programrunning; it spawns A different program and run a command in it, and you will startpiping final results from 1 app to a different, in the event you know about piping, yea so that's what'scool about it Derek: making sure that's The explanation why I am utilizing NodePiotr: did I neglect anything? Derek: no that is fundamentally it Piotr: okDerek: certainly, within the front conclusion, I use html, CSS and JavaScript, And that i use CSS3 and html5 CSS3 to the mobiledevice to complete the CSS transforms things.

Piotr: which a person? Derek: about the app Okay, 1 previous thing, nowwe are shifting into a very diverse portion and that is the front end ofthe application whilst doing this task I discovered Piotr: Github:p Derek: I learned Github for mac, no :p ok, Incidentally this project is open resource;you'll be able to fork me on Github, and also have your own private versionof the Raspberry Television so just before likely deeper within the app construction, I will let you know a little bit in regards to the trick that Idiscovered while accomplishing the online cellular application, Okay you already know, you will find native applications and mobileweb apps and there's Phonegap which is hybridso I've, yea Okay, as you may see here, the iconof the app what? Indeed, is it possible to open up the app make sure you, Alright? there is aflash monitor, and it appears like a native app, there isn't any browser, why, due to this, I went into the apple safari documentation, and I readthe next: if you increase the Metatag in your html app cellular web app title distant, when you drop by safari, you drop by this hyperlink, youcan click insert to household display, proper and this identify will come by default, the graphic, the icon will come, and we swap the default icon by saying Ralequal apple touch icon along with the startup graphic that is the flash impression is apple contact startupimage so these Metatags and backlinks are supplied by apple, so we are kind of noticing what theywant to perform Sooner or later you recognize They are leaping into webtechnologies and JavaScripts to generate indigenous applicationsthat's my concept about cell advancement, and not long ago Firefox cell OS, in the event you readabout it, It can be all about producing People nativemobile programs making use of Website technologies Piotr: it's actually a system Establish on html5Derek: Certainly, exactly, Audience: and do you believe if on android itwill be chrome OS? Derek: Certainly, I hope so: p no it is the samehouse anyhow, yea that is it, I'm utilizing the logoas Svg, I don't know why :p ok, now let us return to Node, now back again tothe core of the appliance, as it is possible to see the construction is very simple I have a publicdirectory, in it there is the html, JavaScript, pictures, fonts, CSS, all People things, andmy server is only this code, It is really application.

js, Alright now when you're building on Node, youhave anything identified as npm, npm is often a pool of modules and libraries Make on Node so Permit'ssay I would like Omx player, that's what I did, and shockingly, it labored, I used to be hunting fora way to manage Omx player with no crafting The complete Main so I discovered this, Okay, how canI use it? I go to my dependencies file; ah not thisone, that is the Node module, yea bundle.

Json, listed here you may specify many variables, thename of one's software, no matter what, dependencies, That is what's significant, I am employing Categorical, I'll talk about it, jade, no I am not working with jade Alright, good, could it be crystal clear, effectively I am goingto shift to Github, the code is on Github, significantly better Alright so express, jade, I'm not usingjade, socket.

io Omx controller, just so why do we make this happen? on Node, you write downyour dependencies on one particular file, and you also go on your terminal, to your Node directory whichis this one below, and appear , what I will do, I'll be insane , I am likely todelete my venture Alright, I'll notify it sudo, and what, I deleted the Node modulesnow the applying isn't Performing any longer so I go ahead and create down npm install, and what transpires can it be read the dependencies file and downloads all the dependencies andthe dependencies in the dependencies so you don't do anything, you'll be able to deploy your software on the server, with a advancement for your personal developer friendyou know any where and you only ~~~~~ these, justification me Audience: why Really don't you utilize apt-get? Derek: apt-get is for Ubuntu and Debian, youknow to down load stuff, npm is similar it a similar notion but applied to the web just, but bear in mind, these dependencies are unique in the dependencies you happen to be pondering aboutthese dependencies are for Node, using npm as opposed to apt-get, but it's the very same conceptand That is what's wonderful about Node Alright so after downloading the dependencies you can geta folder identified as Node modules, Alright and also to use these modules, You need to need them, soI'm going to say var Convey demand Convey application equivalent Specific generates the express server, nonetheless it would not, but I should require http that is by default there and build serverand wrap it with application, so inside of it, within build server, There exists your express server, now if I don't desire to work with express, which will save a great deal of time, I am able to predefine my serverto provide the written content that I want, ok but right here I'm working with express for these explanations, route, by no means brain, io is socket.

io, and socket.

io listens into the server and to the customer soyou want socket.

io on the server aspect and socket.

io in your front conclusion spawn is alsolike Piotr stated, a native module and Node, you don't need to obtain it Omx participant isto Regulate the Omx player to the Raspberry Pi now every Specific server desires a littlebit of configuration specifying the port and stuff like that now see listed here I am usingprocess.

natural environment.

testport Okay, now if I return into this, And that i type in env it stayson the environments, now if I add exam port, export take a look at port equal 8080 ok, this fashion wheneverI deploy my app, it is going to do the job, you already know so if on my staging server I am using the port8080 but on my real server I am utilizing the default port 80, suitable so I am able to do that by specifyingthis in the method surroundings, like I am able to entry this through Node by performing this method.

env.

thevariable, indicating if I console .

load now process .

env Exhibit within the Raspberry Pi, it willshow, 0.

0 app.

person.

omx this is to the Omx player, for example I would like to pause the Film, if I am making use of Specific, I am able to condition that Categorical.

use.

omx , it'll create for me these a few requests, which i can perform, pause, Stop and begin now the routes, commonly, what you can do on Node, You will need a boiler plate to get started on, right, https://iptvrestream.net you don't want to write the tedious code againand again and again, What exactly Convey does, which can be the Node server, To begin with youshould set up it like that, npm and put in Categorical, and supply the minus g parameter, minus g will install it globally, so now if I want to make a new undertaking, ~~~, let'sgive it sudo I hate my password and type, Alright I will go into take a look at look at the magicof Specific, ok it made for me a boiler plate, and now I can write