What's in Smart TV to you? Or what can be stuffed into the TV?

Instead of the foreword



Good afternoon, colleagues! My name is Aleksey and I am engaged in TVs, namely, the development of Smart TV applications (" let's pat Aleksey ").



But what is a smart TV? What is a spherical Smart TV app in a vacuum?



I will not bother you with the expectation: basically these kinds of applications are designed to display video content. In any variations. Recorded, live broadcasts, television shows, films, cartoons, commercials, and so on, and so on ... Thousands of them!



But is Smart TV just for that?







Yes, of course, the TV shows video content best of all, and it copes well with this, but is it only for this that we can use it?



( Now all the happy owners of consoles and HDMI cables will throw their rotten tomatoes at me, say “Unsubscribe!” And the happy ones will leave, and we will continue .)



Indeed, the vast majority of the applications that we had to develop are primarily intended for showing videos, but there were some remarkable exceptions among them. In addition, suffering from the well-known disease “Awl in a place just below the back”, I wanted to squeeze something more from TVs than everyone expects from them.



About my (and not only) modest attempts will be discussed below.



TV - Game?



Indeed, the first thing that comes to mind is the game! The large screen, the possibility of cross-domain requests (since the Smart TV application, in fact, is a local HTML page), and at the very least standard control (remote control) allow us to implement a game scenario.



For the most part, these are casual games like “1024,” or variations on the theme of “Tower Defense.” Not much. Unfortunately, wrapping up super 3D with shaders, shadows and dynamic lighting will only work out on the latest models ... next year. Because TV is usually not the most advanced version of the browser, and, worst of all, it is either rarely updated or not updated at all. In addition, the difference between the power of TV, even last year's and current, can be a multiple.



Therefore, if you want to cover the maximum number of models, get ready for the bloody optimization of everything and everything. A clean, native Canvas will be your best friend. The wrappers work on it, but it is extremely gluttonous. The unsatisfactory operation of the rotate and transform methods is especially depressing, so plan sprite animation and implement sprite turns only in the most extreme case.



Once we did a game on Career Night. She managed to go to wonderful colleagues from Web Standarts Days and make a presentation.



Visually, the game is a playing field, fit in the size of the screen, without scrolling, without barriers. The background is divided into several layers to realize the 3d effect. On the stage, flying targets (ducks) are generated, on which the user can shoot.









Fig. 1. General view of the application.



The main task was to give the opportunity to play the game to anyone and whatever, which immediately excluded interaction with the remote control. The console is one, but there are many players. Management was implemented using the phone, and for maximum coverage of mobile devices, it was decided to implement the client in the form of an adaptive website. We implemented it on WebSockets, and added a chip - management through changing the position of the phone.



Then a lot of interesting features surfaced, low-quality orientation sensors and other glitches. We had to apply noise reduction algorithms, otherwise the “sight” of the player on the TV screen suffered from a terrible tremor. It also turned out that the game was "blowing the wind": an error accumulated in the calculations on the phones and the sights gradually "blown away" in one direction, which forced the players to gradually turn. Some played with their backs to the TV.



Moral : Use orientation sensors in phone browsers as little as possible.




Fig. 2. Duck killers at work



The application uses animation by replacing sprites. This method was quite productive. We tested the application with hundreds or more flying ducks. In reality, there were only 10 of them in the game. Performance problems arose when the designer ran in and cried out: “I want the planet to spin”!



Twist the sprite was not a problem. The problem happened when we launched the application on a relatively old TV. It turned out that he didn’t take out a sprite rotation of 900 × 900 pixels a little more than nothing. As a result, the most big-eyed user can notice that the planet in the background is cut into 9 parts that rotate around one center. This solved the performance issue.



Hence another moral : do not rotate large sprites.


Another feature of the project was that the game logic is calculated ... on TV. In this case, the server acts simply as a data transmitter between the clients and the TV. We did this so that even in case of loss of connection, ducks continued to fly around the screen, and after restoring the Internet, it was not necessary to restart the application. A curious case, but still optional.



TV Screen?



It would seem that this is already commonplace, but no. As usual, everything is hidden in the details. Screen for what? What function does it carry? What is it for?



I will give just a few examples.



Congratulatory



Once, we decided on Valentine's Day to cut down an online birthday card in the company, and use the available TVs as translators of congratulations. The application was implemented in a minimalistic version with a single request to the server returning a list of congratulations. The main problem was the unpleasant feature of TVs to go into sleep mode. If Samsung allows you to disable this feature using the setScreenSaver method, then other platforms do not really allow it. Alternatively, you can run in the background any looped video - TV in the video display mode turns off much less often. As a result, the application fulfilled its function: in all parts of the office on several floors, congratulations of employees were broadcast online.



Map



To be precise - a combat map with a list of the best players.



We again made the game on Career Night and this time decided to combine TVs, phones and VR. The bottom line was that the player in the VR helmet flies on the dragon and shoots the princesses, which are controlled by players from phones. Whoever killed the dragon puts on a helmet. And so in a circle. I modestly note that the application coped with its function (to collect the maximum number of people at our stand and keep them as long as possible). Learn more about dragons exterminating princesses here .









Fig. 3. General view of the stand



The TV application provided a demonstration of the general battle scene for all comers.



In this project, we were faced with the need to optimize previously stable and well-functioning code. With an increase in the number of players, application performance indicators deteriorated markedly. We identified the main ways of optimization:





The creation of each new instance of the class is noticeable to the eye, so all instances must be created in advance and shown to the user as necessary.



On the TV on the left is a view from the VR glasses, on the TV in the center is a scene map.





Fig. 4. The gameplay. On TV on the left - view from VR glasses, on TV in the center - scene map



Interactive background



You can rightly ask: “Do you even work there, don’t ?!” To which I will answer with a sincere lack of sleep on my face: “Of course, I work!” But more on that later. In the meantime, we did not sit back and wanted to implement an interactive background for the quadrocopter. More details about the project can be found here .



The idea was to show on the TV the very estate of Santa Claus, which would respond to the departure / arrival of the quadrocopter.



The main interest was to “stretch” the picture on three TVs. Different manufacturers.



We did this by dividing the whole scene into "rooms." Each TV showed a “room” with its number. The numbers of the "rooms" could be changed, so the TVs, in principle, could show the same parts of one scene, but we showed the whole scene in sequence. Commands to move the environment of the scenes (animals, the movement of the moon and smoke from the pipes) were transmitted from the server via their favorite WebSockets.









Fig. 5. A scene stretched over three TVs



Since we knew the time of arrival / departure of the quadrocopter, the idea came up to make “wind” on TVs, which would “blow” smoke out of pipes with close operation of the screws.



Again, the command to take off from the quadrocopter through the server descended to the clients.



And here, too, we had difficulties with performance. The “old” webOS of 2013 extremely hard rendered a large picture (5760 × 1080). I had to cut the backdrop specifically for him to fit the screen size and substitute it strictly.



Moral : Do not try to draw pictures that are substantially larger than the TV screen. He will not survive this.


Nevertheless, we have successfully implemented everything related to Smart TV and the backend.



TV - Guard?



However, the most interesting project was completely non-fiction, and no matter what, useful.



The application was engaged in home security. Yes, it’s TV. Yes, it was guarded.



The essence of the application is that the existing camera takes everything that happens in front of it, and in the event of a sharp change in the picture, it takes actions to choose:





TV itself at this moment strenuously pretends to be a felt boot and not working at all. In the application, cases of turning off the TV from the Internet or simply from power were handled. The application supported multilingualism.



Several tens of thousands of people installed it for themselves.



But here it was not all simple.



When you connect the camera and try to get a stream in the browser from it, as you know, the system popup falls out with confirmation of the action. The peculiarity is that TVs block all pop-ups. Therefore, our application was implemented only on the Samsung platform using either the built-in TV camera or a special camera supplied by the same Samsung.



Another disadvantage was, again, the performance of the TV. On relatively old TVs (2013), one could sneak past the camera and the TV would “slap” this moment.



But overall, the idea is simply brilliant.



Output



Televisions have long outgrown their main function - to show a picture from a channel, to show vidosiki or to be a second monitor.



Their capabilities and productivity are constantly growing, and the scope of application is limited only by your imagination. Any tasks can be solved with due consideration of the idea and appropriate implementation. Dare and succeed!



Television everyone!



Z.Y. Maybe you, reader, had unusual tasks for smart TV, when you had to use TV in an unusual role for it? Share it! Tell me!



All Articles