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 fellas and welcome towards the Develop your ownGoogle Television workshop, Alright who between you appreciates what on earth is a Google Television a Google TV is usually a hardwaredevice; you link it by HDMI towards your Television set, and you're Television set becomeslike a smart TV you may check out YouTube videos on it, playgames and It can be, no it isn't the nexus dice, It is Nearly like the nexus cube nevertheless it's calledthe Google TV now there carrying out in addition a hardwaredevice produced by Sony that you just connect by HDMI on the Television they usually'redoing a standalone TV that has a chip in it that serves the Google Television we are form ofreplicating this over the Raspberry Pi, Alright but for now, we designed; I built a YouTubedownloader in order to look at YouTube video clips on the Raspberry Pi and Handle them withyour cell gadget so before digging deeper inthe technological stuff, I'm going to teach you a smalldemo, Okay 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 and that is pi along with the password isRaspberry, Okay so we're In the pi this my dwelling Listing, ok, I have set up the application within homeNode Google TV Okay, now I start the Node software byexecuting this command and add the & image to run it from the track record.

Now there is a whole lot ofways to run the NodeJs software inside the background but to the Raspberry Pi, It can be thefastest way, Alright, since it was jogging and I did a previousdemo, Of course We'll in more details relating to this butthis is simply to operate the demo, We will take a look at Node, about how theremote is Doing work, about every thing ah https://iptvrestream.net but we have to have it into, Alright and now I'mgoing to run chromium in Kiosk manner and that's why don't worry fellas; we are likely togo as a result of this, Alright and Now we have this error this mistake can not opendisplay, why mainly because I am executing the chromium browser from SSH, Okay so I need tocheck my environment variables and include to them Show so I click and typeexport Exhibit equals 0.

0 details to your display after which I execute thisand we're going to see that our beautiful Tv set isup and managing now this unappealing bar is for the reason that I previously shut chromium in a bad wayso give it a next and its loading and that'sit so This is certainly our popular Television set, generally I just did the check out but I am planning to dolisten and Participate in Later on the weather no, I made The full point but the design I took it from the world wide web I usedthese attractive icons yea like there is this icon that is this icon you understand, good artistscopy good artists steal, which is it everywhereok so I'm going to open up tree manner, recognize this, this isn't a local Net application but it surely has abeautiful icon, Alright now, as you can see I'm swiping correct and itsmoving Okay and I swipe remaining and it moves still left now I am heading to find a movie Okay it'sshowing with you? ok and I'm going to click on observe this script is called YouTube downloader;We'll also pass through it.

It downloadsthe Film from YouTube and it will save it so It really is against any YouTube guidelines nevertheless it'sRaspberry Pi and It is really an open up org men Therefore the workaround is always to utilize the script, downloadthe movie and Perform it enjoy Sure it can Perform around 1080p significant definitionmovie and the Motion picture is loading, This can be the Harlem shake at Lamba Labs that Imissed, if I choose to pause the Motion picture I just faucet and it pauses, I tap once again to resume andif I wish to exit I tap within the header now thisis my consumer knowledge concerning this you know, I couldn't make like a suitable remotewith buttons and stuff like that, so I said whynot using swipe gestures and faucet and things like this, ok Therefore the demo is fine, the demo is working Enable the workshop get started: Alright first of all I'm going to teach you brieflythe blueprint of the Raspberry Pi which is a simplething to carry out now, you can find the HDMI port, USB, u have two USB, LAN, the modelB includes 512mbytes of ram the model A includes 256mbytes you have got theaudio, the video clip, LEDs, and also the GPIO which you'll application and the hardwarestuff design b with two USBs model A too as well as the SD card now if youfirst invest in you're Raspberry Pi, You need to drop by RaspberryPi.

org and download the Okay, There are tons of Linuxdistributions which you can boot about the SD card, They are all illustrations or photos, I am making use of Raspbianbecause it's essentially the most acknowledged and there is a great deal ofthese Distros are according to Debian, all of us knowDebian, but this Raspbian is specially built forthe Raspberry Pi with many softwares and applications and driverson it, Okay now if you 1st buy you are Raspberry Pi you'll want to copy thisimage and execute several codes to make the picture bootable around the SD card ok, we'renot gonna go through this now, but you'll find a lotof tutorials on the internet I did not adjust it, still left it the way it really is Alright, hardware part completed, configuration andsoftware made use of Okay we mentioned Raspbian, yes the YouTube downloader, the script, YYouTube-dl ah sorry, no no, YouTube downloader, Sure It is really an extremely know script todownload YouTube flicks on Ubuntu Debian Linux Okay, not surprisingly It is really forbidden by Google, You can't download YouTube films, You will need to stream them yes accurately, You should updateit when they modify, the blokes change ok It really is quite simple to downloada YouTube Motion picture using that; I will go to YouTube, that'sa movie, downloading online video, and It truly is downloading, now I'm going to end it, becausewe have limited quota Alright, Indeed It truly is messy Alright, it dependson the hardware, Omx player along with the Film started off, Omx player gives a established ofshortcuts, for example I am able to prevent and play;I am tapping on my cell I understand it's a really great track, we can't watchit: p ok and now I'm going to clarify a bit aboutthe architecture utilized During this undertaking and why, ok as it is possible to see its all JavaScript, JavaScript over the frontend, JavaScript on the backend, right, that's why I needed to use NodeJs, now, whoknows about NodeJs, occur in this article men, notify us somewhat about NodeJs and why did I take advantage of itin this undertaking I informed u why :p Piotr: alright, so my name is Piotr Yordanovand, perfectly the those who know me know that I'ma fanatic of kind of Node since I have beenusing Node for a while, but there is certainly, so I will let you know why, tothe code immediately, Okay so NodeJs in essence is, so chrome essentially operates one thing named v8 it's a JavaScript motor; it is the enginethat understands and interprets JavaScript so there'sthis ridiculous guy who like 4 decades in the past took this v8 and place it over the server andnow all outside of a sudden you may summon you're terminal, you can begin signing up for interpretingJavaScript the natural beauty about this is you have the powerfulv8 engine accomplishing this, ok so ignore this, as programmers what is actually exciting about itis that Formerly until nowadays if you don't useNode and you would like to create a Website application, you'regoing to generally be using any sort of other language Irrespective, dependant upon your flavor, python, it might be php, it may be ruby, and it might bewhatever, and each language, even Java, just about every languagehas a framework in addition to it that may be like for Website, Ruby has Rails, Php has a great deal ofthem coding evenings or whatsoever cake, python has jungleflask and The remainder Node just isn't a language and Node isnot a framework, Node is simply Node, a JavaScript interpreter, that's what it can be, youcan't Examine Node towards the others nevertheless that staying said, Node has couple offrameworks available which can be style of attention-grabbing but the appealing Element of utilizing Node isthat you're utilizing JavaScript, in case you forget aboutperformance, mainly because at the tip day how can we actually proveif It is really far more profound compared to Other individuals? It does have limitations, due to the fact Node issingle threaded, so which can be superior for io poor forCPU intensive duties, suitable? So when Derek was describing to mehow he did the app, what is actually attention-grabbing isthat, do I take a look at socket? Derek: yes Piotr: thisis referred to as socket.

io, now any of you, have you finished Website do the job before? Would you knowabout Ajax? Audience: yea Piotr: in the event you don'tknow, just To put it simply, Ajax is largely to the browser and I would like tolet's say alter what's occurring over below with out loading the website page, but I wish to fetchcontent from someplace, it can be my server or any server, so I makean Ajax ask for, Ajax is good, but it's kindof bothersome when you write it, your situation is Harmless, probably, Idon't know but what's occurring in this straightforward socket.

iowhat definitely comes about is usually that it results in sockets, so now, in case you are over the customer, you connectto a socket around the server and it won't block, it just emits events, quickly function pushed, the matter about socket.

io In particular is thatit's purely in JavaScript so It really is like, it natively will work in Node, and World wide web sockets ingeneral, they don't natively get the job done in almost every other language there is library~ Just what exactly Derek is carrying out about Here's: he wantsto have the ability to Manage from his controller whichis the cellphone he would like to manage the browser or Raspberry Pi and it needs to be Are living, it must be events occurring “swipe” that's anevent, so on my pi I choose to recognize that's anevent and make anything about this so he could have carried out it in Ajax but He's doingit applying socket due to the fact, yea in fact that's the syntax, It really is truly muchmore simpler, and it's like built-in in indigenous within the ecosystem he is applying, so socketis one particular potent issue and the opposite robust issue isthat he just utilized JavaScript around the pi, Derek: onthe socket thing, would you don't forget composing a code, an Ajax code natively, ahnot natively but without making use of jQuery?it is a very long approach; You need to fulfill a lot ofbrowsers like internet explorer, things like that, so jQuery, they did Ajax which is asimple tool to obtain Ajax and receives and post and whatsoever, now socket.

io did a similar matter for Website sockets, and not just for Net sockets, forreal-time apps like socket.

io supports even IE6 which has no web sockets in it Piotr:It has Flash Derek: Certainly , so it falls into another engineering, like flash or Xhr polling, long polling, things likethat Piotr: Imagine they actually use Ajax Derek: andthey use Ajax in addition, socket.

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

io was the powerful issue, the other robust stage is me doingJavaScript in each and every area, appropriate Derek: as well as thirdpoint is spawning Piotr: that's essentially a fascinating andfunny detail what took place with Node, is the fact Impulsively you can actually builda shell script, utilizing JavaScript, when you ever needto call one thing on your terminal, in essence you will find this purpose called spawnDerek: Spawn child system, module Piotr: you might have your application, which has a programrunning; it spawns another application and operate a command in it, and you may startpiping outcomes from one particular application to another, in case you understand about piping, yea so That is what'scool about this Derek: to ensure that's The main reason why I'm employing NodePiotr: did I forget about anything at all? Derek: no that is generally it Piotr: okDerek: needless to say, about the entrance conclusion, I exploit html, CSS and JavaScript, and I use CSS3 and html5 CSS3 to the mobiledevice to accomplish the CSS transforms things.

Piotr: which one particular? Derek: to the app Okay, just one very last detail, nowwe are going into a completely distinct part that's the front close ofthe application when undertaking this task I identified Piotr: Github:p Derek: I uncovered Github for mac, no :p Okay, by the way this undertaking is open source;it is possible to fork me on Github, and also have your personal versionof the Raspberry Television set so just before likely further in the application structure, I'm going to let you know a tiny bit in regards to the trick that Idiscovered although performing the internet mobile app, Alright you are aware of, you can find indigenous applications and mobileweb apps and there's Phonegap which happens to be hybridso I have, yea Alright, as you could see here, the iconof the app what? Sure, are you able to open the app you should, ok? there's aflash display, and it seems like a local application, there is not any browser, why, because of this, I went towards the apple safari documentation, And that i readthe next: for those who incorporate the Metatag in your html app cellular Internet app title distant, after you head over to safari, you check out this hyperlink, youcan click incorporate to residence display screen, ideal which name will appear by default, the impression, the icon will arrive, and we exchange the default icon by stating Ralequal apple touch icon along with the startup image which can be the flash image is apple contact startupimage so these Metatags and backlinks are furnished by apple, so we are style of noticing what theywant to accomplish Later on you are aware of They are leaping into webtechnologies and JavaScripts to help make native applicationsthat's my thought about cellular development, and just lately Firefox cell OS, in case you readabout it, It is all about creating These nativemobile purposes utilizing Internet technology Piotr: It really is in fact a procedure Make on html5Derek: yes, particularly, Audience: and do you're thinking that if on android itwill be chrome OS? Derek: Of course, I hope so: p no it is the samehouse anyways, yea which is it, I am using the logoas Svg, I don't know why :p ok, now let us go back to Node, now again tothe core of the appliance, as you can begin to see the construction is quite simple I have a publicdirectory, in it there's the html, JavaScript, illustrations or photos, fonts, CSS, all These points, andmy server is barely this code, It is application.

js, Okay now when you are acquiring on Node, youhave one thing known as npm, npm is usually a pool of modules and libraries Develop on Node so Permit'ssay I would like Omx participant, that's what I did, and shockingly, it labored, I used to be searching fora way to regulate Omx player without producing The complete core so I discovered this, Okay, how canI use it? I head over to my dependencies file; ah not thisone, that is the Node module, yea offer.

Json, below it is possible to specify a great deal of variables, thename of the software, whatever, dependencies, That is what's crucial, I'm making use of express, I'll mention it, jade, no I'm not working with jade Okay, superior, could it be obvious, properly I'm goingto move to Github, the code is on Github, significantly better Okay so express, jade, I'm not usingjade, socket.

io Omx controller, simply so How come we try this? on Node, you generate downyour dependencies on 1 file, and also you go towards your terminal, for your Node directory whichis this one particular here, and glimpse , what I'll do, I will be outrageous , I'm going todelete my challenge ok, I will tell it sudo, and what, I deleted the Node modulesnow the applying just isn't Operating any longer so I go on and write down npm put in, and what transpires could it be browse the dependencies file and downloads many of the dependencies andthe dependencies in the dependencies so You do not do just about anything, you can deploy your software on the server, on the enhancement for your personal developer friendyou know anyplace and you merely ~~~~~ these, excuse me Viewers: why You should not you utilize apt-get? Derek: apt-get is for Ubuntu and Debian, youknow to download things, npm is similar it the same principle but applied to the internet accurately, but bear in mind, these dependencies are distinct in the dependencies you're pondering aboutthese dependencies are for Node, using npm in lieu of apt-get, but it's the very same conceptand That is what's nice about Node Okay so immediately after downloading the dependencies you are going to geta folder identified as Node modules, Okay also to use these modules, It's important to need them, soI'm gonna say var Categorical have to have Specific application equivalent Categorical makes the express server, nonetheless it isn't going to, but I have to demand http which happens to be by default there and build serverand wrap it with app, so within it, within create server, You can find your Convey server, now if I don't need to implement Specific, which saves plenty of time, I'm able to predefine my serverto serve the information which i want, Okay but right here I am utilizing Categorical for these factors, route, never brain, io is socket.

io, and socket.

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

io on the server side and socket.

io with your entrance conclusion spawn is alsolike Piotr reported, a native module and Node, you don't need to down load it Omx participant isto Command the Omx player to the Raspberry Pi now every Specific server desires a littlebit of configuration specifying the port and stuff like that now discover in this article I'm usingprocess.

atmosphere.

testport Alright, now if I go back into this, and I type in env it stayson the environments, now if I increase take a look at port, export take a look at port equivalent 8080 Alright, in this way wheneverI deploy my app, it's going to work, you are aware of so if on my staging server I'm utilizing the port8080 but on my authentic server I'm utilizing the default port eighty, suitable so I'm able to do this by specifyingthis in the procedure atmosphere, like I can accessibility this by way of Node by doing this process.

env.

thevariable, that means if I console .

load now procedure .

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

0 app.

user.

omx This can be for that Omx player, for example I desire to pause the movie, if I'm making use of express, I'm able to state that express.

use.

omx , it can generate for me these 3 requests, which i can do, pause, Stop and start now the routes, typically, what you can do on Node, you need a boiler plate to start out, appropriate, you don't want to write down the tedious code againand many times, so what express does, which can be the Node server, first