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 to your Make your ownGoogle Television workshop, Alright who between you is aware of what's a Google Tv set a Google Tv set can be a hardwaredevice; you connect it by HDMI on your Television, and you're Tv set becomeslike a sensible Television set you can check out YouTube films on it, playgames and It truly is, no it isn't really the nexus dice, It truly is Virtually just like the nexus cube but it surely's calledthe Google Tv set now there carrying out at the same time a hardwaredevice produced by Sony that you just join by HDMI for the Television and they'redoing a standalone Tv set which has a chip in it that serves the Google Television set we're sort ofreplicating this over the Raspberry Pi, ok but for now, we designed; I constructed a YouTubedownloader so you can watch YouTube movies around the Raspberry Pi and Management them withyour mobile gadget so right before digging deeper inthe technological things, I'll explain to you a smalldemo, Okay First off I will SSH into the Raspberry Pi thatyou can give it instructions ok, 102 and also the username is pi, so by default the RaspberryPi has this default username that is pi along with the password isRaspberry, ok so we are Within the pi this my home directory, Alright, I've installed the applying inside of homeNode Google TV ok, now I launch the Node application byexecuting this command and incorporate the & image to run it inside the qualifications.

Now there is a whole lot ofways to operate the NodeJs application within the qualifications but over the Raspberry Pi, It really is thefastest way, Okay, as it was running and I did a previousdemo, Certainly We'll in additional particulars concerning this butthis is just to run the demo, we're going to talk about Node, about how theremote is Performing, about all the things ah but we need to have it into, ok and now I'mgoing to run chromium in Kiosk method and that's why Don't be concerned men; we are likely togo by way of this, Alright and we have this mistake this error can't opendisplay, why since I'm executing the chromium browser from SSH, Okay so I want tocheck my atmosphere variables and increase to them Show so I click and typeexport Screen equals 0.

0 details into the monitor and afterwards I execute thisand we're going to see that our beautiful Television isup and operating now this unappealing bar is due to the fact I Formerly closed chromium in a nasty wayso give it a second and its loading and that'sit so this is our well-known Television, generally I just did the observe but I'm planning to dolisten and Enjoy in the future the temperature no, I designed the whole matter but the look I took it from the net I usedthese beautiful icons yea like you will find this icon which is this icon you already know, superior artistscopy excellent artists steal, which is it everywhereok so I will open up tree manner, notice this, this is simply not a native Website application but it has abeautiful icon, ok now, as you may see I'm swiping proper and itsmoving ok and I swipe remaining and it moves remaining now I'm going to search for a Motion picture Alright it'sshowing with you? Alright and I'll click on observe this script is termed YouTube downloader;We will also pass through it.

It downloadsthe Motion picture from YouTube and it saves it so It truly is in opposition to any YouTube procedures but it really'sRaspberry Pi and It can be an open org men Therefore the workaround should be to use the script, downloadthe Motion picture and Enjoy it observe Sure it might Perform as many as 1080p superior definitionmovie and the Film is loading, This can be the Harlem shake at Lamba Labs that Imissed, if I want to pause the movie I just faucet and it pauses, I tap all over again to resume andif I wish to exit I tap to the header now thisis my consumer knowledge relating to this you realize, I couldn't make like an appropriate remotewith buttons and things like that, so I mentioned whynot employing swipe gestures and tap and things similar to this, Alright Therefore the demo is okay, the demo is Operating Enable the workshop commence: Okay Firstly I'm going to teach you brieflythe blueprint with the Raspberry Pi which is a simplething to accomplish now, you can find the HDMI port, USB, u have two USB, LAN, the modelB includes 512mbytes of ram the design A comes along with 256mbytes you may have theaudio, the online video, LEDs, as well as GPIO which you'll software as well as the hardwarestuff design b with two USBs model A also along with the SD card now if youfirst obtain you might be Raspberry Pi, You need to check out RaspberryPi.

org and obtain the Okay, There are tons of Linuxdistributions you can boot within the SD card, They are all pictures, I'm working with Raspbianbecause It truly is one of the most acknowledged and there's a large amount ofthese Distros are dependant on Debian, all of us knowDebian, but this Raspbian is specially created forthe Raspberry Pi with plenty of softwares and systems and driverson it, ok now if you very first acquire you might be Raspberry Pi you need to copy thisimage and execute a number of codes to create the graphic bootable on the SD card ok, we'renot gonna experience this right now, but you will discover a lotof tutorials on the internet I didn't change it, still left it the best way it really is ok, components ingredient performed, configuration andsoftware applied Alright we discussed Raspbian, Certainly the YouTube downloader, the script, YYouTube-dl ah sorry, no no, YouTube downloader, Sure It is an extremely know script todownload YouTube motion pictures on Ubuntu Debian Linux Okay, of course it's forbidden by Google, you cannot down load YouTube movies, you have to stream them Certainly exactly, It's important to updateit when they alter, the blokes change Alright It https://iptvrestream.net truly is very simple to downloada YouTube movie making use of that; I will go to YouTube, that'sa movie, downloading movie, and It is downloading, now I will cease it, becausewe have limited quota Okay, Of course it's messy Okay, it dependson the components, Omx participant along with the movie began, Omx player delivers a set ofshortcuts, such as I am able to quit and Enjoy;I'm tapping on my cellular I realize it's an extremely pleasant track, we can't watchit: p ok and now I'll reveal a bit aboutthe architecture employed Within this challenge and why, Alright as you'll be able to see its all JavaScript, JavaScript over the frontend, JavaScript about the backend, ideal, That is why I needed to use NodeJs, now, whoknows about NodeJs, appear here fellas, convey to us a little bit about NodeJs and why did I exploit itin this venture I advised u why :p Piotr: alright, so my identify is Piotr Yordanovand, properly the folks who know me recognize that I'ma fanatic of form of Node since I have beenusing Node for quite a while, but you can find, so I will inform you why, tothe code immediately, Alright so NodeJs generally is, so chrome basically runs some thing termed v8 it's a JavaScript motor; it's the enginethat understands and interprets JavaScript so there'sthis insane man who like 4 decades back took this v8 and place it around the server andnow all away from a sudden you could summon you might be terminal, you can start signing up for interpretingJavaScript the natural beauty about it is you have the powerfulv8 motor undertaking this, Okay so ignore this, as programmers what's attention-grabbing about itis that Formerly till now if you do not useNode and you want to create a World wide web software, you'regoing to generally be employing almost any other language regardless, dependant upon your taste, python, it might be php, it might be ruby, and it could possibly bewhatever, and each language, even Java, just about every languagehas a framework in addition to it that is certainly like for World wide web, Ruby has Rails, Php has quite a bit ofthem coding nights or whatever cake, python has jungleflask and The remainder Node is just not a language and Node isnot a framework, Node is just Node, a JavaScript interpreter, That is what it really is, youcan't Review Node to your Other people nonetheless that being explained, Node has couple offrameworks in existence which can be kind of attention-grabbing although the attention-grabbing Portion of making use of Node isthat you will be utilizing JavaScript, if you forget aboutperformance, due to the fact at the top working day how can we really proveif It is a lot more profound in comparison to the Other individuals? It does have restrictions, for the reason that Node issingle threaded, so which can be very good for io undesirable forCPU intensive jobs, suitable? So when Derek was describing to mehow he did the application, what is actually truly interesting isthat, do I speak about socket? Derek: Certainly Piotr: thisis identified as socket.

io, now any of you, have you accomplished World-wide-web do the job ahead of? Would you knowabout Ajax? Viewers: yea Piotr: in the event you don'tknow, just simply put, Ajax is essentially on the browser and I want tolet's say adjust what's occurring around here with out loading the page, but I desire to fetchcontent from somewhere, it might be my server or any server, so I makean Ajax ask for, Ajax is good, but it surely's kindof irritating if you compose it, your situation is safe, it's possible, Idon't know but what is occurring in this simple socket.

iowhat truly takes place is always that it generates sockets, so now, if you're over the consumer, you connectto a socket about the server and it doesn't block, it just emits events, right away party driven, the issue about socket.

io Specifically is thatit's purely in JavaScript so It is really like, it natively functions in Node, and World-wide-web sockets ingeneral, they don't natively perform in almost every other language there is certainly library~ so what Derek is carrying out over here is: he wantsto have the capacity to Management from his controller whichis the cellphone he desires to regulate the browser or Raspberry Pi and it must be Dwell, it must be situations going on “swipe” that is anevent, so on my pi I desire to understand that's anevent and make something about it so he could have finished it in Ajax but He's doingit applying socket for the reason that, yea actually that's the syntax, it's basically muchmore more simple, and It is like integrated in native within the ecosystem he is employing, so socketis 1 powerful place and the other potent stage isthat he just applied JavaScript within the pi, Derek: onthe socket thing, would you don't forget composing a code, an Ajax code natively, ahnot natively but without having employing jQuery?it is a prolonged process; You need to satisfy a good deal ofbrowsers like World wide web explorer, stuff like that, so jQuery, they did Ajax that is asimple Instrument to entry Ajax and will get and put up and no matter what, now socket.

io did the identical thing for web sockets, and not only for Internet sockets, forreal-time programs like socket.

io supports even IE6 which has no Internet sockets in it Piotr:It's Flash Derek: Certainly , so it falls into another technology, like flash or Xhr polling, lengthy polling, stuff likethat Piotr: Imagine they actually 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 solid level, another sturdy stage is me doingJavaScript in each and every put, correct Derek: and the thirdpoint is spawning Piotr: which is actually an interesting andfunny point what took place with Node, is the fact Rapidly you can actually builda shell script, applying JavaScript, in the event you ever needto get in touch with a little something in your terminal, fundamentally there's this function known as spawnDerek: Spawn kid procedure, module Piotr: you've got your app, that has a programrunning; it spawns A further plan and operate a command in it, and you can startpiping results from a person application to another, in the event you know about piping, yea so that's what'scool about this Derek: to ensure that's the reason why I'm making use of NodePiotr: did I overlook just about anything? Derek: no that's basically it Piotr: okDerek: obviously, over the front close, I use html, CSS and JavaScript, And that i use CSS3 and html5 CSS3 within the mobiledevice to carry out the CSS transforms things.

Piotr: which just one? Derek: over the application Okay, one previous factor, nowwe are moving into a completely various segment which happens to be the front finish ofthe application even though accomplishing this venture I discovered Piotr: Github:p Derek: I learned Github for mac, no :p Alright, Incidentally this undertaking is open supply;it is possible to fork me on Github, and possess your own versionof the Raspberry Tv set so before going deeper during the app framework, I'm going to inform you a bit about the trick that Idiscovered when performing the net cell application, Alright you know, there's indigenous applications and mobileweb apps and there's Phonegap that's hybridso I have, yea ok, as you could see in this article, the iconof the app what? Sure, could you open up the app make sure you, Okay? there is certainly aflash monitor, and it seems like a local application, there isn't any browser, why, for this reason, I went into the apple safari documentation, And that i readthe following: in the event you incorporate the Metatag within your html application cell World wide web app title remote, whenever you visit safari, you visit this link, youcan click add to household display screen, appropriate which title will come by default, the impression, the icon will arrive, and we switch the default icon by indicating Ralequal apple touch icon plus the startup image which is the flash impression is apple contact startupimage so these Metatags and back links are supplied by apple, so we're sort of noticing what theywant to carry out Sooner or later you understand They are leaping into webtechnologies and JavaScripts for making indigenous applicationsthat's my idea about mobile enhancement, and recently Firefox cellular OS, in the event you readabout it, It truly is all about creating those nativemobile applications employing Net technological know-how Piotr: It truly is actually a technique Create on html5Derek: Indeed, exactly, Viewers: and do you think that if on android itwill be chrome OS? Derek: Certainly, I hope so: p no it's the samehouse in any case, yea which is it, I am using the logoas Svg, I don't know why :p ok, now let's return to Node, now back tothe Main of the appliance, as you'll be able to see the structure is quite simple I have a publicdirectory, in it there is certainly the html, JavaScript, photos, fonts, CSS, all All those items, andmy server is barely this code, It is really app.

js, ok now if you're acquiring on Node, youhave something termed npm, npm is actually a pool of modules and libraries Create on Node so let'ssay I want Omx player, That is what I did, and shockingly, it worked, I was seeking fora way to control Omx player with out writing The entire Main so I discovered this, Okay, how canI use it? I drop by my dependencies file; ah not thisone, that is the Node module, yea deal.

Json, right here you'll be able to specify a lot of variables, thename of the application, no matter what, dependencies, That is what's significant, I am utilizing express, I'll discuss it, jade, no I'm not making use of jade Okay, great, is it very clear, perfectly I am goingto go to Github, the code is on Github, far better ok so Convey, jade, I'm not usingjade, socket.

io Omx controller, basically so why do we do that? on Node, you generate downyour dependencies on just one file, and you go to the terminal, to your Node directory whichis this one in this article, and glance , what I'll do, I will be insane , I am likely todelete my challenge ok, I'm going to notify it sudo, and what, I deleted the Node modulesnow the application is not working anymore so I go ahead and publish down npm set up, and what happens can it be read the dependencies file and downloads all the dependencies andthe dependencies of your dependencies so you don't do nearly anything, you'll be able to deploy your application over a server, on the development to your developer friendyou know anywhere and you just ~~~~~ these, excuse me Viewers: why Never you employ apt-get? Derek: apt-get is for Ubuntu and Debian, youknow to down load things, npm is similar it the exact same notion but applied to the net just, but bear in mind, these dependencies are various in the dependencies you will be contemplating aboutthese dependencies are for Node, employing npm instead of apt-get, but it's the exact same conceptand That is what's awesome about Node Alright so immediately after downloading the dependencies you might geta folder termed Node modules, ok and also to use these modules, You must involve them, soI'm intending to say var Convey involve Categorical app equivalent Convey results in the Categorical server, but it doesn't, but I should require http which can be by default there and develop serverand wrap it with app, so inside it, inside make server, You can find your Convey server, now if I don't want to use Categorical, which saves loads of time, I'm able to predefine my serverto provide the content which i want, Alright but right here I am using Convey for these explanations, route, in no way intellect, io is socket.

io, and socket.

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

io on the server side and socket.

io in your entrance stop spawn is alsolike Piotr mentioned, a local module and Node, you need not download it Omx participant isto Management the Omx player about the Raspberry Pi now every single Categorical server demands a littlebit of configuration specifying the port and stuff like that now discover here I am usingprocess.

atmosphere.

testport ok, now if I return into this, And that i key in env it stayson the environments, now if I increase examination port, export examination port equivalent 8080 ok, in this manner wheneverI deploy my application, it can function, you realize Therefore if on my staging server I'm using the port8080 but on my real server I'm using the default port 80, suitable so I am able to do that by specifyingthis in the procedure ecosystem, like I'm able to entry this by using Node by undertaking this method.

env.

thevariable, indicating if I console .

load now procedure .

env Display screen about the Raspberry Pi, it willshow, 0.

0 app.

consumer.

omx This is certainly to the Omx participant, for instance I would like to pause the movie, if I am working with Convey, I can condition that Specific.

use.

omx , it is going to develop for me these three requests, which i can do, pause, quit and begin now the routes, ordinarily, what you can do on Node, you need a boiler plate to start, right, you don't need to jot down the unexciting code againand many times, so what Specific does, which can be the Node server, For starters youshould install it like that, npm and set up express, and provide