1

Currently I'm trying build a tv application. The goal is to have the ability to run the project on the laptop browser and have it work on the tv as an app.

So what I'm trying to do is detect if user is a browser or a app on the tv.

I've tried using user agents it works when I try to detect a browser so it tells me that its Chrome for instance. It does not work when I try to detect the tv.

Expected: Console log me back the user agent when on tv.

Actual: Currently its just not detecting a user.

Vash
  • 176
  • 1
  • 15
  • 2
    check if `navigator.userAgent` works here. – Yahiya Oct 24 '19 at 10:25
  • 1
    [Does this help](https://udger.com/resources/ua-list)? – Paul Oct 24 '19 at 10:28
  • Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.120 Safari/537.36 this is what it returns. But when I'm on a tv it does not return anything... – Vash Oct 24 '19 at 10:28
  • @Paul I'll have a look – Vash Oct 24 '19 at 10:29
  • 1
    Why does it need to behave differently on a TV than on a laptop? Feature detection is probably the way forward. Not device detection. – Quentin Oct 24 '19 at 10:30
  • Because when using a browser the video should not start at fullscreen but when you're on tv it should. – Vash Oct 24 '19 at 11:20

2 Answers2

1

There is a list of user agents which are mostly used by smart TVs. Since they are also using Chrome or Firefox or other browsers, it's not that easy to rely 100% on that list but it could provide you a solution?

https://udger.com/resources/ua-list/device-detail?device=Smart%20TV

Devestel
  • 211
  • 1
  • 4
-1

Try use the css @media rule, you should get a hook:

@media tv {
   html {
      border-color: red; - any unimportant for view property, but you can check if it exist from JS
   }
}

UserAgent is useless for this case.

MaxWall
  • 195
  • 5
  • We've created a working useragent check for this by utilizing custom modules. We're not looking for a tv but for a specific model. – Vash Feb 28 '20 at 11:39