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 guys and welcome for the Establish your ownGoogle Television set workshop, ok who between you is familiar with what exactly is a Google Tv set a Google Television can be a hardwaredevice; you join it by HDMI to your TV, and also you're Television becomeslike a wise Television set you are able to watch YouTube movies on it, playgames and it's, no it isn't the nexus cube, It is Pretty much similar to the nexus dice nevertheless it's calledthe Google Television set now there doing at the same time a hardwaredevice produced by Sony that you choose to join by HDMI on the Tv set plus they'redoing a standalone Tv set which has a chip in it that serves the Google Television we are type ofreplicating this over the Raspberry Pi, Alright but for now, we created; I built a YouTubedownloader so you're able to view YouTube films about the Raspberry Pi and control them withyour mobile device so just before digging deeper inthe technical stuff, I will explain to you a smalldemo, Alright first of all I'll SSH into the Raspberry Pi thatyou can give it commands ok, 102 and also the username is pi, so by default the RaspberryPi has this default username which can be pi plus the password isRaspberry, Okay so we are inside the pi this my residence Listing, Okay, I have set up the applying inside of homeNode Google Television set Okay, now I launch the Node application byexecuting this command and include the & symbol to run it while in the track record.

Now there is a good deal ofways to run the NodeJs application within the history but within the Raspberry Pi, it's thefastest way, Okay, because it was jogging and I did a previousdemo, Certainly We'll in additional specifics relating to this butthis is simply to operate the demo, We will take a look at Node, about how theremote is Doing work, about anything ah but we must have it into, Okay and now I'mgoing to operate chromium in Kiosk method and that's why Don't fret guys; we are heading togo as a result of this, Alright and We've this error this mistake simply cannot opendisplay, why since I'm executing the chromium browser from SSH, Okay so I need tocheck my ecosystem variables and add to them Show so I click and typeexport Show equals 0.

0 details to the display and then I execute thisand We will see that our beautiful Television isup and operating now this unappealing bar is due to the fact I previously shut chromium in a nasty wayso give it a next and its loading Which'sit so That is our well-known Television set, mainly I just did the check out but I'm planning to dolisten and play Later on the weather no, I created The entire issue but the design I took it from the online world I usedthese lovely icons yea like there is certainly this icon that is this icon you realize, very good artistscopy excellent artists steal, that is it everywhereok so I'm going to open tree method, recognize this, this isn't a native World wide web application but it really has abeautiful icon, ok now, as you are able to see I am swiping suitable and itsmoving Okay and I swipe still left and it moves left now I'm heading to find a movie ok it'sshowing along with you? Alright and I'll click on view this script known as YouTube downloader;We'll also go through it.

It downloadsthe movie from YouTube and it saves it so it's towards any YouTube policies nonetheless it'sRaspberry Pi and It really is an open org fellas And so the workaround is usually to utilize the script, downloadthe movie and Perform it watch Indeed it may play around 1080p superior definitionmovie and also the movie is loading, Here is the Harlem shake at Lamba Labs that Imissed, if I need to pause the Film I just tap and it pauses, I tap yet again to resume andif I desire to exit I tap on the header now thisis my person knowledge concerning this you know, I could not make like an appropriate remotewith buttons and things like that, so I mentioned whynot employing swipe gestures and tap and things such as this, Okay Therefore the demo is fine, the demo is working Permit the workshop get started: Ok First off I'll provide you with brieflythe blueprint with the Raspberry Pi that is a simplething to carry out now, there is the HDMI port, USB, u have two USB, LAN, the modelB includes 512mbytes of ram the product A comes with 256mbytes you have theaudio, the movie, LEDs, plus the GPIO which you'll method as well as hardwarestuff model b with two USBs design A as well plus the SD card now if youfirst obtain you might be Raspberry Pi, You should check out RaspberryPi.

org and obtain the Alright, There are plenty of Linuxdistributions that you can boot around the SD card, They are all visuals, I'm making use of Raspbianbecause It is the most recognized and there's a lot ofthese Distros are based on Debian, many of us knowDebian, but this Raspbian is specially manufactured forthe Raspberry Pi with lots of softwares and packages and driverson it, Okay now after you initially invest in you happen to be Raspberry Pi you might want to copy thisimage and execute a few codes to generate the picture bootable on the SD card ok, we'renot gonna experience this now, but you will find a lotof tutorials online I didn't transform it, left it the way it truly is Okay, hardware part accomplished, configuration andsoftware employed Okay we discussed Raspbian, Indeed the YouTube downloader, the script, YYouTube-dl ah sorry, no no, YouTube downloader, Of course It is an incredibly know script todownload YouTube films on Ubuntu Debian Linux ok, naturally it's forbidden by Google, You can't obtain YouTube movies, You will need to stream them Of course just, You should updateit when they change, the fellows adjust Alright It is quite simple to downloada YouTube Motion picture employing that; I'll go to YouTube, that'sa Film, downloading online video, and It really is downloading, now I will quit it, becausewe have confined quota Okay, Certainly It is really messy ok, it dependson the components, Omx participant along with the movie commenced, Omx player offers a set ofshortcuts, such as I can end and Engage in;I'm tapping on my cellular I know it's an exceptionally nice tune, we can't watchit: p Okay and now I will clarify a little bit https://iptvrestream.net aboutthe architecture employed During this undertaking and why, ok as you may see its all JavaScript, JavaScript around the frontend, JavaScript to the backend, ideal, This is exactly why I needed to use NodeJs, now, whoknows about NodeJs, arrive here guys, inform us a bit about NodeJs and why did I use itin this project I advised u why :p Piotr: alright, so my name is Piotr Yordanovand, properly the those who know me realize that I'ma fanatic of style of Node for the reason that I have beenusing Node for some time, but there is certainly, so I'll tell you why, tothe code specifically, ok so NodeJs fundamentally is, so chrome in fact operates some thing referred to as v8 it's a JavaScript motor; it is the enginethat understands and interprets JavaScript so there'sthis crazy man who like four years in the past took this v8 and place it within the server andnow all outside of a sudden you may summon you're terminal, you can start signing up for interpretingJavaScript the attractiveness about this is that you've got the powerfulv8 engine accomplishing this, Okay so forget about this, as programmers what is appealing about itis that Beforehand until currently if you do not useNode and you ought to make a World wide web application, you'regoing being using any kind of other language regardless, based on your taste, python, it can be php, it may be ruby, and it may bewhatever, and every language, even Java, each and every languagehas a framework on top of it that is like for Website, Ruby has Rails, Php has lots ofthem coding evenings or what ever cake, python has jungleflask and the rest Node is not really a language and Node isnot a framework, Node is just Node, a JavaScript interpreter, that's what it truly is, youcan't Look at Node on the others nonetheless that becoming explained, Node has couple offrameworks out there that happen to be style of fascinating however the interesting part of using Node isthat that you are utilizing JavaScript, in the event you overlook aboutperformance, mainly because at the tip day how can we really proveif It is far more profound than the Many others? It does have limitations, simply because Node issingle threaded, so and that is very good for io negative forCPU intensive tasks, correct? So when Derek was describing to mehow he did the application, what's seriously interesting isthat, do I mention socket? Derek: yes Piotr: thisis known as socket.

io, now any of you, Have you ever completed Website do the job right before? Does one knowabout Ajax? Viewers: yea Piotr: should you don'tknow, just To put it simply, Ajax is largely to the browser and I would like tolet's say improve what is actually taking place around below with out loading the site, but I want to fetchcontent from someplace, it might be my server or any server, so I makean Ajax request, Ajax is sweet, however it's kindof troublesome after you publish it, your situation is Protected, perhaps, Idon't know but what is actually occurring in this simple socket.

iowhat genuinely transpires is the fact that it results in sockets, so now, if you're on the customer, you connectto a socket over the server and it won't block, it just emits situations, promptly celebration driven, the point about socket.

io especially is thatit's purely in JavaScript so it's like, it natively works in Node, and World-wide-web sockets ingeneral, they do not natively work in some other language you will find library~ so what Derek is doing in excess of here is: he wantsto manage to Command from his controller whichis the mobile phone he needs to regulate the browser or Raspberry Pi and it should be Stay, it needs to be events going on “swipe” that is anevent, so on my pi I choose to understand that's anevent and make a thing about this so he might have done it in Ajax but he is doingit utilizing socket due to the fact, yea in fact that's the syntax, It really is essentially muchmore easier, and It truly is like integrated in indigenous during the ecosystem he is making use of, so socketis one powerful point and the other solid stage isthat he just utilized JavaScript about the pi, Derek: onthe socket matter, does one don't forget creating a code, an Ajax code natively, ahnot natively but without having employing jQuery?it's a prolonged process; It's important to satisfy a good deal ofbrowsers like internet explorer, things like that, so jQuery, they did Ajax which happens to be asimple Device to accessibility Ajax and will get and article and what ever, now socket.

io did the exact same detail for Internet sockets, and don't just for Internet sockets, forreal-time programs like socket.

io supports even IE6 which has no World-wide-web sockets in it Piotr:It has Flash Derek: Indeed , so it falls into One more technological innovation, like flash or Xhr polling, very long polling, things likethat Piotr: Feel they really use Ajax Derek: andthey use Ajax in addition, socket.

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

io was the strong stage, the other strong issue is me doingJavaScript in each and every spot, correct Derek: and also the thirdpoint is spawning Piotr: that's really an interesting andfunny matter what happened with Node, is always that Hastily you can in fact builda shell script, working with JavaScript, in case you at any time needto call a little something on your terminal, fundamentally there is this operate called spawnDerek: Spawn baby course of action, module Piotr: you've got your app, which has a programrunning; it spawns One more system and run a command in it, and you'll startpiping results from just one application to another, should you understand about piping, yea so that's what'scool about it Derek: to ensure's The rationale why I am making use of NodePiotr: did I forget just about anything? Derek: no which is generally it Piotr: okDerek: obviously, on the entrance end, I use html, CSS and JavaScript, And that i use CSS3 and html5 CSS3 to the mobiledevice to accomplish the CSS transforms things.

Piotr: which one particular? Derek: within the application Alright, one very last point, nowwe are transferring into a totally distinctive section which happens to be the front stop ofthe application though executing this job I uncovered Piotr: Github:p Derek: I learned Github for mac, no :p Alright, Incidentally this challenge is open up resource;you could fork me on Github, and also have your own personal versionof the Raspberry Television so just before going further while in the application composition, I will tell you somewhat regarding the trick that Idiscovered though carrying out the world wide web mobile application, Alright you already know, there is indigenous applications and mobileweb apps and there's Phonegap which is hybridso I have, yea Alright, as you could see in this article, the iconof the application what? Indeed, could you open the app be sure to, ok? you will find aflash display screen, and it looks like a native app, there isn't any browser, why, due to this, I went to your apple safari documentation, and I readthe subsequent: in case you add the Metatag in the html application cell World-wide-web app title distant, any time you check out safari, you go to this link, youcan click on increase to household monitor, ideal and this identify will arrive by default, the image, the icon will appear, and we exchange the default icon by declaring Ralequal apple touch icon as well as the startup impression that's the flash graphic is apple touch startupimage so these Metatags and links are supplied by apple, so we are form of noticing what theywant to perform Sooner or later you know they're leaping into webtechnologies and JavaScripts to generate indigenous applicationsthat's my notion about cellular development, and lately Firefox cellular OS, should you readabout it, It really is all about building Individuals nativemobile apps employing Website technological know-how Piotr: it's actually a technique Create on html5Derek: yes, just, Audience: and do you're thinking that if on android itwill be chrome OS? Derek: Of course, I hope so: p no it's 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 begin to see the framework is very simple I've a publicdirectory, in it there's the html, JavaScript, pictures, fonts, CSS, all those factors, andmy server is simply this code, It really is application.

js, Alright now when you are establishing on Node, youhave a little something named npm, npm is really a pool of modules and libraries Establish on Node so Allow'ssay I would like Omx participant, that's what I did, and shockingly, it worked, I had been searching fora way to manage Omx player with out producing the whole core so I discovered this, Okay, how canI use it? I go to my dependencies file; ah not thisone, that's the Node module, yea package deal.

Json, here it is possible to specify loads of variables, thename of the application, regardless of what, dependencies, that's what's vital, I'm using Categorical, I will discuss it, jade, no I'm not making use of jade Alright, good, can it be crystal clear, well I'm goingto go to Github, the code is on Github, far better ok so Categorical, jade, I am not usingjade, socket.

io Omx controller, basically so why do we try this? on Node, you compose downyour dependencies on one file, and you also go towards your terminal, for your Node directory whichis this a single right here, and glimpse , what I will do, I will be insane , I am going todelete my job ok, I'll inform it sudo, and what, I deleted the Node modulesnow the appliance will not be working any longer so I go on and create down npm install, and what comes about could it be study the dependencies file and downloads the many dependencies andthe dependencies with the dependencies so you don't do anything, you could deploy your application over a server, with a improvement to your developer friendyou know anywhere and you simply ~~~~~ these, excuse me Audience: why don't you use apt-get? Derek: apt-get is for Ubuntu and Debian, youknow to download things, npm is comparable it precisely the same principle but placed on the online just, but be aware, these dependencies are diverse through the dependencies you are pondering aboutthese dependencies are for Node, utilizing npm in lieu of apt-get, but it's the very same conceptand that's what's wonderful about Node ok so following downloading the dependencies you are going to geta folder referred to as Node modules, Okay and also to use these modules, It's important to require them, soI'm gonna say var express need Convey application equal Convey creates the Specific server, however it would not, but I should involve http and that is by default there and make serverand wrap it with app, so inside it, within make server, There exists your express server, now if I don't desire to implement Categorical, which will save many time, I am able to predefine my serverto provide the written content that I want, ok but here I am applying Specific for these factors, route, hardly ever head, io is socket.

io, and socket.

io listens to your server also to the client soyou need to have socket.

io on your server aspect and socket.

io with your entrance stop spawn is alsolike Piotr explained, a native module and Node, you don't need to down load it Omx participant isto Manage the Omx participant on the Raspberry Pi now each and every Specific server desires a littlebit of configuration specifying the port and stuff like that now observe below I'm usingprocess.

ecosystem.

testport ok, now if I return into this, and I type in env it stayson the environments, now if I incorporate examination port, export check port equal 8080 Alright, this way wheneverI deploy my application, it will eventually do the job, you already know so if on my staging server I'm using the port8080 but on my actual server I'm utilizing the default port 80, right so I'm able to do that by specifyingthis in the procedure atmosphere, like I am able to accessibility this via Node by executing this process.

env.

thevariable, which means if I console .

load now process .

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

0 application.

consumer.

omx That is with the Omx player, as an example I would like to pause the movie, if I am working with express, I can point out that express.

use.

omx , it's going to build for me these three requests, that I can do, pause, Give up and start now the routes, generally, what you are able to do on Node, you need a boiler plate to begin, appropriate, you don't need to write the dull code againand many times, What exactly Categorical does, that is the Node server, Firstly youshould set up it like that, npm and put in Specific, and provide the minus g parameter, minus g will install it globally, so now if I need to make a new project, ~~~, Enable'sgive it sudo I