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...

 

Hello fellas and welcome into the Develop your ownGoogle Television workshop, ok who amid you appreciates what's a Google Tv set a Google TV is often a hardwaredevice; you hook up it by HDMI in your TV, and you're TV becomeslike a smart Television set you could view YouTube movies on it, playgames and It is really, no it's actually not the nexus dice, It can be Nearly much like the nexus cube but it surely's calledthe Google Television set now there performing too a hardwaredevice created by Sony which you join by HDMI to your Tv set and so they'redoing a standalone Tv set having a chip in it that serves the Google TV we are variety ofreplicating this about the Raspberry Pi, Okay but for now, we created; I constructed a YouTubedownloader so you're able to view YouTube video clips to the Raspberry Pi and Handle them withyour cellular gadget so just before digging further inthe technical stuff, I will tell you about a smalldemo, Alright Firstly I will SSH into the Raspberry Pi thatyou may give it commands Okay, 102 and the username is pi, so by default the RaspberryPi has this default username that is pi as well as the password isRaspberry, Okay so we are inside the pi this my property directory, Okay, I've installed the appliance inside homeNode Google TV ok, now I start the Node application byexecuting this command and add the & image to operate it in the history.

Now there is a good deal ofways to run the NodeJs software while in the track record but around the Raspberry Pi, It is thefastest way, Alright, as it was operating and I did a previousdemo, yes we're going to in additional details relating to this butthis is just to operate the demo, we're going to talk about Node, regarding how theremote is working, about anything ah but we have to have it into, Alright and now I'mgoing to operate chromium in Kiosk manner and that's why Don't fret guys; we're going togo through this, ok and Now we have this error this error are not able to opendisplay, why simply because I am executing the chromium browser from SSH, ok so I need tocheck my surroundings variables and include to them display so I simply click and typeexport Exhibit equals 0.

0 points into the screen and afterwards I execute thisand We'll see that our wonderful Television set isup and running now this unpleasant bar is due to the fact I Formerly shut chromium in a nasty wayso give it a second and its loading Which'sit so this is our popular Television set, mainly I just did the watch but I'm intending to dolisten and Participate in Sooner or later the climate no, I designed The entire detail but the look I took it from the world wide web I usedthese gorgeous icons yea like there is this icon that's this icon you realize, superior artistscopy excellent artists steal, that is it everywhereok so I'm going to open tree method, notice this, this is not a local World wide web software but it really has abeautiful icon, Alright now, as it is possible to see I'm swiping correct and itsmoving Alright and I swipe left and it moves remaining now I am going to search for a Film Okay it'sshowing with you? Okay and I'm going to click enjoy this script is called YouTube downloader;we're going to also go through it.

It downloadsthe Film from YouTube and it saves it so It really is in opposition to any YouTube guidelines however it'sRaspberry Pi and It really is an open up org fellas so the workaround would be to utilize the script, downloadthe Film and play it enjoy Indeed it could Participate in nearly 1080p high definitionmovie and also the Film is loading, This can be the Harlem shake at Lamba Labs that Imissed, if I need to pause the movie I just faucet and it pauses, I tap yet again to resume andif I want to exit I faucet over the header now thisis my consumer practical experience about this you realize, I couldn't make like an appropriate remotewith buttons and things like that, so I stated whynot using swipe gestures and faucet and things similar to this, ok And so the demo is okay, the demo is Performing let the workshop start out: Okay To begin with I'll explain to you brieflythe blueprint of your Raspberry Pi which can be a simplething to carry out now, you will find the HDMI port, USB, u have two USB, LAN, the modelB comes with 512mbytes of ram the model A comes along with 256mbytes you have got theaudio, the movie, LEDs, as well as GPIO which you can system plus the hardwarestuff model b with 2 USBs product A too plus the SD card now if youfirst get you happen to be Raspberry Pi, It's important to head to RaspberryPi.

org and obtain the Okay, There are tons of Linuxdistributions which you could boot about the SD card, They are all pictures, I am employing Raspbianbecause It is quite possibly the most identified and there's a ton ofthese Distros are depending on Debian, most of us knowDebian, but this Raspbian is specifically created forthe Raspberry Pi with a great deal of softwares and applications and driverson it, ok now after you initially get you're Raspberry Pi you should copy thisimage and execute a number of codes to produce the graphic bootable about the SD card Okay, we'renot planning to undergo this now, but you will find a lotof tutorials on the web I didn't transform it, remaining it how it can be ok, components element completed, configuration andsoftware utilized Alright we talked about Raspbian, Certainly the YouTube downloader, the script, YYouTube-dl ah sorry, https://iptvrestream.net no no, YouTube downloader, Certainly It is an exceedingly know script todownload YouTube videos on Ubuntu Debian Linux Okay, naturally It is really forbidden by Google, You can not obtain YouTube videos, You will need to stream them Certainly specifically, You should updateit when they modify, the blokes improve Okay It is really very simple to downloada YouTube Film utilizing that; I'll drop by YouTube, that'sa Film, downloading video, and It truly is downloading, now I'll quit it, becausewe have minimal quota ok, Of course it's messy Okay, it dependson the components, Omx player along with the Motion picture started, Omx player offers a set ofshortcuts, for example I'm able to stop and Participate in;I'm tapping on my cellular I know it's an exceptionally great track, we will not watchit: p ok and now I will make clear a bit aboutthe architecture made use of Within this venture and why, ok as you can see its all JavaScript, JavaScript to the frontend, JavaScript to the backend, ideal, This is why I needed to use NodeJs, now, whoknows about NodeJs, come in this article guys, tell us a bit about NodeJs and why did I take advantage of itin this task I explained to u why :p Piotr: alright, so my name is Piotr Yordanovand, nicely the people who know me are aware that I'ma fanatic of sort of Node for the reason that I've beenusing Node for a while, but there is certainly, so I'm going to inform you why, tothe code instantly, Alright so NodeJs in essence is, so chrome truly operates anything named v8 it is a JavaScript engine; it's the enginethat understands and interprets JavaScript so there'sthis mad man who like 4 a long time ago took this v8 and put it within the server andnow all outside of a unexpected you are able to summon you're terminal, you can start joining interpretingJavaScript the attractiveness about it is that you've the powerfulv8 engine executing this, ok so ignore this, as programmers what is fascinating about itis that Formerly till now if you do not useNode and you would like to make a Internet software, you'regoing to get working with any sort of other language No matter, dependant upon your flavor, python, it may be php, it may be ruby, and it could bewhatever, and each language, even Java, just about every 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 whichever cake, python has jungleflask and the rest Node is not a language and Node isnot a framework, Node is just Node, a JavaScript interpreter, that's what it can be, youcan't Assess Node for the Some others nevertheless that remaining mentioned, Node has few offrameworks on the market that are style of exciting but the exciting Section of working with Node isthat you might be working with JavaScript, in the event you forget aboutperformance, mainly because at the tip working day how can we actually proveif It can be a lot more profound compared to others? It does have limitations, for the reason that Node issingle threaded, so which happens to be very good for io terrible forCPU intensive responsibilities, correct? So when Derek was describing to mehow he did the app, what is actually truly interesting isthat, do I talk about socket? Derek: Certainly Piotr: thisis termed socket.

io, now any of you, Have you ever done web get the job done just before? Does one knowabout Ajax? Audience: yea Piotr: should you don'tknow, just To put it simply, Ajax is largely within the browser and I need tolet's say alter what is actually taking place over in this article without having loading the web page, but I need to fetchcontent from somewhere, it can be my server or any server, so I makean Ajax request, Ajax is sweet, but it's kindof troublesome once you publish it, the specific situation is Protected, maybe, Idon't know but what's occurring in this easy socket.

iowhat really comes about is always that it results in sockets, so now, when you are within the client, you connectto a socket within the server and it does not block, it just emits gatherings, right away occasion pushed, the point about socket.

io Specially is thatit's purely in JavaScript so It is really like, it natively operates in Node, and World wide web sockets ingeneral, they do not natively operate in every other language there is library~ Just what exactly Derek is performing in excess of Here's: he wantsto have the ability to Handle from his controller whichis the phone he wants to regulate the browser or Raspberry Pi and it must be live, it needs to be gatherings occurring “swipe” that is anevent, so on my pi I wish to know that's anevent and make a little something about it so he could have finished it in Ajax but He's doingit making use of socket for the reason that, yea really that's the syntax, it's truly muchmore simpler, and It truly is like integrated in native within the ecosystem he is utilizing, so socketis a single strong stage and the other sturdy level isthat he just utilized JavaScript on the pi, Derek: onthe socket thing, do you recall producing a code, an Ajax code natively, ahnot natively but without employing jQuery?it's a long course of action; You need to satisfy a whole lot ofbrowsers like Web explorer, things like that, so jQuery, they did Ajax and that is asimple Device to accessibility Ajax and will get and put up and whichever, now socket.

io did a similar detail for Website sockets, and not merely for Website sockets, forreal-time programs like socket.

io supports even IE6 that has no web sockets in it Piotr:It's Flash Derek: Certainly , so it falls into One more technological innovation, like flash or Xhr polling, prolonged polling, stuff likethat Piotr: Believe they really use Ajax Derek: andthey use Ajax too, socket.

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

io was the potent issue, the other sturdy position is me doingJavaScript in each and every position, correct Derek: and the thirdpoint is spawning Piotr: that is truly a fascinating andfunny matter what happened with Node, is usually that Abruptly you can actually builda shell script, using JavaScript, in the event you ever needto simply call a thing on your own terminal, basically there is certainly this functionality named spawnDerek: Spawn baby course of action, module Piotr: you may have your application, which has a programrunning; it spawns another application and run a command in it, and you'll startpiping success from a single app to another, when you find out about piping, yea so that's what'scool about it Derek: making sure that's The rationale why I'm making use of NodePiotr: did I forget about something? Derek: no that's essentially it Piotr: okDerek: needless to say, on the entrance end, I use html, CSS and JavaScript, And that i use CSS3 and html5 CSS3 on the mobiledevice to try and do the CSS transforms stuff.

Piotr: which one? Derek: about the app ok, a single previous detail, nowwe are going into a totally distinct part and that is the front conclude ofthe application although performing this undertaking I learned Piotr: Github:p Derek: I uncovered Github for mac, no :p ok, by the way this undertaking is open up supply;it is possible to fork me on Github, and have your personal versionof the Raspberry Television so just before likely deeper while in the app framework, I'm going to tell you a little concerning the trick that Idiscovered whilst performing the world wide web cellular application, Okay you understand, there is native applications and mobileweb applications and there's Phonegap that's hybridso I have, yea ok, as you could see in this article, the iconof the app what? Of course, could you open up the application you should, Okay? you can find aflash display, and it appears like a native app, there is not any browser, why, because of this, I went for the apple safari documentation, and I readthe following: in case you include the Metatag with your html application cellular web application title remote, if you head over to safari, you head over to this hyperlink, youcan click on include to residence screen, suitable and this title will arrive by default, the impression, the icon will appear, and we exchange the default icon by saying Ralequal apple contact icon as well as the startup image that is the flash picture is apple contact startupimage so these Metatags and back links are provided by apple, so we are sort of noticing what theywant to perform Down the road you realize they're jumping into webtechnologies and JavaScripts to generate indigenous applicationsthat's my notion about mobile development, and a short while ago Firefox cellular OS, if you readabout it, it's all about acquiring Those people nativemobile applications applying Website know-how Piotr: It really is actually a process Create on html5Derek: Certainly, exactly, Viewers: and do you're thinking that if on android itwill be chrome OS? Derek: Certainly, I hope so: p no it is the samehouse anyways, yea that's it, I'm utilizing the logoas Svg, I do not know why :p Okay, now let us go back to Node, now back again tothe Main of the appliance, as you could begin to see the construction is very simple I have a publicdirectory, in it there is the html, JavaScript, images, fonts, CSS, all These items, andmy server is just this code, It truly is app.

js, ok now when you're establishing on Node, youhave some thing identified as npm, npm is actually a pool of modules and libraries Develop on Node so Permit'ssay I want Omx participant, that's what I did, and shockingly, it worked, I had been looking fora way to regulate Omx player without having writing The full core so I discovered this, ok, how canI utilize it? I head to my dependencies file; ah not thisone, that's the Node module, yea bundle.

Json, in this article you could specify loads of variables, thename of the application, whatsoever, dependencies, that's what's vital, I'm employing express, I will talk about it, jade, no I'm not making use of jade Okay, excellent, is it very clear, effectively I'm goingto shift to Github, the code is on Github, a lot better Okay so Categorical, jade, I'm not usingjade, socket.

io Omx controller, only so why do we do that? on Node, you write downyour dependencies on one particular file, and you go towards your terminal, for your Node Listing whichis this a single below, and glance , what I'm going to do, I will be ridiculous , I am likely todelete my job ok, I'm going to convey to it sudo, and what, I deleted the Node modulesnow the appliance is not really Doing work any longer so I go ahead and generate down npm put in, and what comes about can it be browse the dependencies file and downloads each of the dependencies andthe dependencies in the dependencies so you don't do nearly anything, you can deploy your application on a server, on a development to your developer friendyou know any where and you only ~~~~~ these, justification me Viewers: why Really don't you use apt-get? Derek: apt-get is for Ubuntu and Debian, youknow to down load things, npm is comparable it a similar concept but applied to the world wide web specifically, but be aware, these dependencies are distinct with the dependencies you might be pondering aboutthese dependencies are for Node, using npm in lieu of apt-get, but it's the very same conceptand that's what's good about Node ok so after downloading the dependencies you might geta folder identified as Node modules, Okay also to use these modules, It's important to need them, soI'm about to say var express involve express application equivalent express creates the Specific server, however it would not, but I really need to require http and that is by default there and make serverand wrap it with application, so inside of it, within generate server, There may be your express server, now if I don't desire to work with Categorical, which saves plenty of time, I'm able to predefine my serverto serve the content material which i want, ok but here I'm using Categorical for these factors, path, by no means intellect, io is socket.

io, and socket.

io listens on the server and to the client soyou will need socket.

io on the server aspect and socket.

io on your own front conclude spawn is alsolike Piotr stated, a native module and Node, you don't need to down load it Omx player isto control the Omx player within the Raspberry Pi now each and every Categorical server demands a littlebit of configuration specifying the port and things like that now recognize here I am usingprocess.

surroundings.

testport ok, now if I return into this, And that i type in env it stayson the environments, now if I insert examination port, export examination port equal 8080 Alright, this way wheneverI deploy my app, it will get the job done, you recognize so if on my staging server I am using the port8080 but on my real server I am using the default port eighty, proper so I am able to do that by specifyingthis in the procedure setting, like I am able to access this by means of Node by performing this process.

env.

thevariable, meaning if I console .

load now procedure .

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

0 application.

user.

omx this is for that Omx participant, as an instance I desire to pause the movie, if I'm employing express, I am able to point out that Convey.

use.

omx , it will eventually produce for me these 3 requests, that I can perform, pause, Stop and begin now the routes, generally, what you can do on Node, you need a boiler plate to start, appropriate, you don't want to put in writing the uninteresting code againand many times, so what Convey does, which can be the Node server, Firstly youshould put in it like that, npm and set up Specific, and provide the minus g parameter,