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 to your Create your ownGoogle Television workshop, ok who among you knows precisely what is a Google Television a Google Television set is really a hardwaredevice; you hook up it by HDMI for your Tv set, therefore you're Television becomeslike a sensible TV you could look at YouTube videos on it, playgames and It really is, no it isn't really the nexus dice, it's Practically similar to the nexus dice nevertheless it's calledthe Google Television set now there executing likewise a hardwaredevice made by Sony that you simply connect by HDMI on the TV plus they'redoing a standalone TV having a chip in it that serves the Google Television we're sort ofreplicating this around the Raspberry Pi, Alright but for now, we designed; I created a YouTubedownloader to help you watch YouTube videos to the Raspberry Pi and Management them withyour mobile system so just before digging deeper inthe technological stuff, I'm going to provide you with a smalldemo, ok To begin with I'm going to SSH on the Raspberry Pi thatyou can give it instructions Okay, 102 as well as username is pi, so by default the RaspberryPi has this default username that is pi and also the password isRaspberry, ok so we're In the pi this my property directory, Okay, I've set up the applying within homeNode Google Television set Alright, now I start the Node application byexecuting this command and include the & symbol to operate it while in the history.

Now there's a ton ofways to run the NodeJs application from the background but around the Raspberry Pi, It really is thefastest way, Alright, since it was working and I did a previousdemo, Of course We will in additional details concerning this butthis is simply to operate the demo, We will look at Node, about how theremote is Functioning, about every little thing ah but we must have it into, Okay and now I'mgoing to operate chromium in Kiosk mode and that is why don't worry fellas; we are likely togo through this, ok and We've got this mistake this mistake simply cannot opendisplay, why due to the fact I am executing the chromium browser from SSH, ok so I need tocheck my atmosphere variables and include to them display so I click and typeexport display equals 0.

0 points towards the monitor and after that I execute thisand we're going to see that our beautiful TV isup and running now this unpleasant bar is for the reason that I Formerly closed chromium in a nasty wayso give it a next and its loading Which'sit so That is our well-known Tv set, fundamentally I just did the look at but I'm planning to dolisten and play Sooner or later the temperature no, I built The entire issue but the look I took it from the internet I usedthese beautiful icons yea like you can find this icon that's this icon you understand, great artistscopy wonderful artists steal, that is it everywhereok so I will open up tree method, see this, this is not a native web application but it surely has abeautiful icon, ok now, as you can see I am swiping appropriate and itsmoving Alright And that i swipe still left and it moves still left now I am likely to search for a movie Okay it'sshowing with you? Okay and I will click on view this script is referred to as YouTube downloader;We will also pass through it.

It downloadsthe movie from YouTube and it will save it so It is really against any YouTube procedures but it really'sRaspberry Pi and It can be an open up org men so the workaround should be to use the script, downloadthe movie and Participate in it observe yes it may play as much as 1080p higher definitionmovie along with the Motion picture is loading, This can be the Harlem shake at Lamba Labs that Imissed, if I need to pause the Film I just tap and it pauses, I tap all over again to resume andif I need to exit I faucet over the header now thisis my user experience concerning this you know, I couldn't make like a suitable remotewith buttons and stuff like that, so I stated whynot applying swipe gestures and faucet and things like this, Okay so the demo is fine, the demo is Operating let the workshop start: Okay First off I'm going to demonstrate brieflythe blueprint from the Raspberry Pi which can be a simplething to complete now, there's the HDMI port, USB, u have two USB, LAN, the modelB includes 512mbytes of ram the product A includes 256mbytes you've got theaudio, the online video, LEDs, as well as the GPIO which you'll be able to system along with the hardwarestuff model b with two USBs product A in addition as well as the SD card now if youfirst invest in you might be Raspberry Pi, You must head over to RaspberryPi.

org and down load the Okay, there are a lot of Linuxdistributions that you could boot around the SD card, They are all pictures, I am applying Raspbianbecause It is really by far the most regarded and there's a great deal ofthese Distros are based upon Debian, all of us knowDebian, but this Raspbian is specially designed forthe Raspberry Pi with a great deal of softwares and plans and driverson it, Alright now if you very first buy you happen to be Raspberry Pi you might want to duplicate thisimage and execute a few codes to produce the image bootable over the SD card ok, we'renot going to endure this currently, but you will discover a lotof tutorials on the web I did not modify it, remaining it the way it is Okay, components part finished, configuration andsoftware utilized ok we talked about Raspbian, Indeed the YouTube downloader, the script, YYouTube-dl ah sorry, no no, YouTube downloader, Sure It is an extremely know script todownload YouTube flicks on Ubuntu Debian Linux Okay, obviously it's forbidden by Google, You can not obtain YouTube movies, You need to stream them Certainly specifically, It's important to updateit when they modify, the fellows adjust ok It truly is very simple to downloada YouTube Film applying that; I will drop by YouTube, that'sa movie, downloading online video, and it's downloading, now I will end it, becausewe have minimal quota Okay, Sure it's messy Alright, it dependson the components, Omx participant plus the movie started, Omx participant supplies a set ofshortcuts, by way of example I am able to end and Perform;I am tapping on my cell I comprehend it's an exceedingly good song, we will not watchit: p ok and now I'm going to describe a bit aboutthe architecture employed In this particular job and why, ok as you'll be able to see its all JavaScript, JavaScript within the frontend, JavaScript over the backend, suitable, This is why I needed to use NodeJs, now, whoknows about NodeJs, arrive in this article guys, convey to us just a little about NodeJs and why did I use itin this project I informed u why :p Piotr: alright, so my name is Piotr Yordanovand, nicely the people that know me realize that I'ma fanatic of kind of Node because I've beenusing Node for a while, but you will find, so I will inform you why, tothe code right, Alright so NodeJs in essence is, so chrome truly operates one thing named v8 it's a JavaScript engine; it's the enginethat understands and interprets JavaScript so there'sthis ridiculous dude who like four yrs in the past took this v8 and put it to the server andnow all outside of a unexpected you may summon you're terminal, you can begin signing up for interpretingJavaScript the natural beauty about it is that you've the powerfulv8 motor undertaking this, Okay so ignore this, as programmers what is actually appealing about itis that Formerly till these days if you do not useNode and you should make a web software, you'regoing being employing almost any other language regardless, dependant upon your style, python, it can be php, it could be ruby, and it might bewhatever, and each language, even Java, every single languagehas a framework in addition to it that is definitely like for World-wide-web, Ruby has Rails, Php has a whole lot ofthem coding evenings or whatever cake, python has jungleflask and The remainder Node isn't a language and Node isnot a framework, Node is just Node, a JavaScript interpreter, that's what it is, youcan't Look at Node for the Other individuals having said that that getting said, Node has few offrameworks around which might be kind of attention-grabbing nevertheless the interesting Section of using Node isthat you happen to be utilizing JavaScript, in case you overlook aboutperformance, simply because at the top working day how can we really proveif it's extra profound as opposed to Some others? It does have restrictions, mainly because Node issingle threaded, so which happens to be great for io undesirable forCPU intensive jobs, suitable? So when Derek was describing to mehow he did the app, what is actually genuinely fascinating isthat, do I talk about socket? Derek: Sure Piotr: thisis termed socket.

io, now any of you, have you completed Website perform in advance of? Does one knowabout Ajax? Viewers: yea Piotr: should you don'tknow, just To put it simply, Ajax is largely on the browser and I want tolet's say change what's happening more than in this article devoid of loading the web page, but I want to fetchcontent from someplace, it could be my server or any server, so I makean Ajax ask for, Ajax is nice, however it's kindof frustrating after you generate it, your situation is Risk-free, perhaps, Idon't know but what's going on in this straightforward socket.

iowhat genuinely comes about is the fact that it generates sockets, so now, when you are over the shopper, you connectto a socket within the server and it does not block, it just emits functions, right away celebration pushed, the issue about socket.

io especially is thatit's purely in JavaScript so It truly is like, it natively performs in Node, and Net sockets ingeneral, they do not natively work in any other language there is certainly library~ What exactly Derek is undertaking over here is: he wantsto be able to Regulate from his controller whichis the mobile phone he wishes to regulate the browser or Raspberry Pi and it should be Reside, it has to be functions taking place “swipe” which is anevent, so on my pi I need to recognize that's anevent and make one thing about it so he could have accomplished it in Ajax but he is doingit working with socket since, yea essentially that's the syntax, It can be really muchmore more simple, and It can be like built-in in indigenous during the ecosystem he's utilizing, so socketis just one robust position and one other strong place isthat he just utilized JavaScript on the pi, Derek: onthe socket matter, would you bear in mind writing a code, an Ajax code natively, ahnot natively but without the need of employing jQuery?it's a prolonged method; You should fulfill lots ofbrowsers like World wide web explorer, things like that, so jQuery, they did Ajax and that is asimple Device to obtain Ajax and gets and publish and whatever, now socket.

io did the exact same factor for World wide web sockets, and not just for Net sockets, forreal-time applications like socket.

io supports even IE6 which has no web sockets in it Piotr:It's Flash Derek: Indeed , so it falls into An additional know-how, like flash or Xhr polling, lengthy polling, stuff likethat Piotr: think they actually use Ajax Derek: andthey use Ajax too, socket.

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

io was the potent place, the opposite strong point is me doingJavaScript in each and every location, right Derek: as well as thirdpoint is spawning Piotr: which is essentially a fascinating andfunny thing what happened with Node, is always that Abruptly you can actually builda shell script, employing JavaScript, for those who ever needto simply call a thing in your terminal, essentially there is this functionality identified as spawnDerek: Spawn boy or girl course of action, module Piotr: you have your application, that has a programrunning; it spawns another method and run a command in it, and you'll startpiping final results from one particular app to a different, if you learn about piping, yea so that's what'scool about this Derek: to ensure that's The explanation why I'm using NodePiotr: did I neglect anything? Derek: no which is generally it Piotr: okDerek: of course, within the front end, I take advantage of html, CSS and JavaScript, And that i use CSS3 and html5 CSS3 over the mobiledevice to complete the CSS transforms stuff.

Piotr: which 1? Derek: within the application ok, one past point, nowwe are going into a very distinctive part which can be the front close ofthe application even though executing this challenge I learned Piotr: Github:p Derek: I identified Github for mac, no :p Okay, Incidentally this task is open source;it is possible to fork me on Github, and possess your personal versionof the Raspberry TV so before likely further from the application composition, I'll let you know somewhat concerning the trick that Idiscovered even though doing the net mobile app, ok you know, you can find native applications and mobileweb apps and there is Phonegap that's hybridso I have, yea Alright, as it is possible to see listed here, the iconof the application what? Indeed, could you open the app please, Alright? you can find aflash screen, and it looks like a local application, there's no browser, why, due to this, I went towards the apple safari documentation, and I readthe adhering to: in the event you include the Metatag within your html application cellular web app title distant, whenever you visit safari, you head over to this hyperlink, youcan click on incorporate to dwelling monitor, proper and this identify will arrive by default, the graphic, the icon will arrive, and we replace the default icon by stating Ralequal apple touch icon and also the startup image which can be the flash image is apple touch startupimage so these Metatags and backlinks are provided by apple, so we're kind of noticing what theywant to carry out Later on you realize They are jumping into webtechnologies and JavaScripts to generate indigenous applicationsthat's my plan about cell progress, and lately Firefox cellular OS, when you readabout it, It really is all about establishing All those nativemobile apps making use of Net technological know-how Piotr: It truly is essentially a method Establish on html5Derek: Sure, precisely, Viewers: and do you're thinking that if on android itwill be chrome OS? Derek: Indeed, I hope so: p no it is the samehouse in any case, yea that is it, I'm using the logoas Svg, I do not know why :p Okay, now let us return to Node, now again tothe core of the applying, as you are able to begin to see the structure is very simple I've a publicdirectory, in it there is certainly the html, JavaScript, photographs, fonts, CSS, all Those people items, andmy server is barely this code, it's application.

js, Okay now when you are developing on Node, youhave some thing known as npm, npm can be a pool of modules and libraries Develop on Node so Permit'ssay I want Omx player, that's what I did, and shockingly, it labored, I had been hunting fora way to regulate Omx participant without writing the whole Main so I found this, ok, how canI use it? I visit my dependencies file; ah not thisone, that's the Node module, yea offer.

Json, in this article you may specify lots of variables, thename of your respective application, whichever, dependencies, That is what's significant, I am working with Convey, I will mention it, jade, no I'm not employing jade Okay, very good, is it very clear, nicely I'm goingto shift to Github, the code is on Github, a lot better Alright so Convey, jade, I'm not usingjade, socket.

io Omx controller, only so why do we try this? on Node, you create downyour dependencies on one file, and you simply go to your terminal, in your Node Listing whichis this a single right here, and search , what I'll do, I'm going to be insane , I'm likely todelete my challenge ok, I'll explain to it sudo, and what, I deleted the Node modulesnow the application is not Doing work any longer so I go ahead and produce down npm put in, and what takes place can it be browse the dependencies file and downloads each of the dependencies andthe dependencies of the dependencies so You do not do something, you'll be able to deploy your application on the server, over a enhancement for the developer friendyou know anywhere and you simply ~~~~~ these, excuse me Audience: why Do not you use apt-get? Derek: apt-get is for Ubuntu and Debian, youknow to download stuff, npm is similar it a similar strategy but placed on the online accurately, but remember, these dependencies are various within the dependencies you happen to be imagining aboutthese dependencies are for Node, using npm as opposed to apt-get, but it's the similar conceptand that's what's awesome about Node ok so following 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 gonna say var Specific have to have Categorical app equal express generates the Convey server, but it doesn't, but I need to call for http that is by default there and build serverand wrap it with app, so inside it, inside build server, You can find your Categorical server, now if I don't need to use Convey, which will save plenty of time, I can predefine my serverto provide the content material that I want, Okay but right here I am employing express for these causes, path, in no way brain, io is socket.

io, and socket.

io listens towards the server and also to the customer soyou need to have socket.

io on the server facet and socket.

io in your front close spawn is alsolike Piotr stated, a local module and Node, you needn't obtain it Omx participant isto Handle the Omx player to the Raspberry Pi now each and every express server requirements a littlebit of configuration specifying the port and things like that now discover right here 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 add examination port, export check port equivalent 8080 Alright, using this method wheneverI deploy my app, it will function, you know Therefore if on my staging server I'm using the port8080 but on my real server I am utilizing the default port eighty, suitable so I am able to do this by specifyingthis in the process surroundings, like I can obtain this by way of Node by undertaking this process.

env.

thevariable, which means if I console .

load now approach .

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

0 app.

consumer.

omx This really is with the Omx participant, for instance I want to pause the Motion picture, if I'm applying Specific, I'm able to state that Specific.

use.

omx , it can build for me these three requests, which i can do, pause, Give up and begin now the routes, ordinarily, what you can https://iptvrestream.net do on Node, You will need a boiler plate to start out, proper, you do not need to write down the boring code againand over and over, Just what exactly Convey does, which happens to be the Node server, Firstly youshould set up it like that, npm and put in Categorical, and provide the minus g parameter, minus g will put in it globally, so now if I would like to make a new challenge, ~~~, Permit'sgive