четверг, 16 июня 2016 г.

Кратко о разработке для ТВ-приставок: Roku

Мои заказчики думали, что Roku — это тоже что-то про Android, но всё оказалось не так. У Roku свой отдельный и полный загадок мир.

Roku Home Screen

Первым делом, конечно, хотелось сделать ту же трансляцию. Однако, в документации не обнаружилось об этом вообще ничего. Притом, что YouTube и Netflix, при наличии установленного на Roku своего канала, устройство обнаруживали и на него транслировали. Ладно,— подумали мы,— напишем тогда себе канал, может в процессе что-нибудь и выясним. Да и вообще пригодится.

Для разработки каналов Roku придумали свой язык BrightScript и написали поддерживающий его плагин для eclipse. Язык не особенно приятный, набор функций в стандартной библиотеке не такой большой, но в целом жить можно. Главное, можно отправлять запросы и легко парсить JSON. Дебаггера нет, но есть функция print и дебажная консолька. Довольно удобна функция публикации приватных каналов, которая позволяет по инвайт-коду легко распространять бета-версии.

Конечно, с самого начала нас больше всего интересуют возможности для UI. Есть несколько вариантов.

Стандартные экраны Roku

Стандартные экраны можно немножко кастомизировать (менять цвета, добавлять кое-где кнопки и т.д.), но в целом это довольно жесткие шаблоны. Исключение составляет только roScreen, на котором можно рисовать. Описание экранов размазано по всей документации, это неудобно, так что перечислю их в таблице:

Класс Как выглядит
roPosterScreen
roSpringboardScreen
roParagraphScreen
roGridScreen
roListScreen
roSearchScreen
roKeyboardScreen
roCodeRegistrationScreen
roVideoScreen
roTextScreen
roScreen Здесь можно рисовать на канвасе и создавать более-менее кастомные интерфейсы

Работа с экранами описана в документации и примерах. Общая схема такова:

Sub ShowPosterScreen()
    port = CreateObject("roMessagePort")     ' слушатель событий
    poster = CreateObject("roPosterScreen")  ' экран
    poster.SetMessagePort(port)              ' прицепили к экрану слушатель

    poster.show()                            ' показали экран
    While True                               ' сели слушать
        message = Wait(0, port)              ' получили событие
        If message.isScreenClosed()          ' определили, что случилось
            Exit While                       ' отреагировали
        else if message.isListItemSelected()
            …
        end if
    End While
End Sub

Для примера приложения на стандартных экранах можно посмотреть Vevo или Fullscreen Selects. В последнем, кстати, экран проигрывания сделан явно с помощью roScreen, и довольно хорошо показывает, что с ним можно наворотить.

Scene Graph

Более гибкий способ создания интерфейсов. Здесь уже есть какие-то UI-компоненты и XML-лэйауты. Можно настраивать анимации и красиво переключающиеся панельки, да и работает всё это гораздо более отзывчиво. Подробнее пока писать об этом не буду, так как тема большая и ещё не совсем уложилась у меня в голове. Возможности и примеры кода можно посмотреть в блоге Roku.

Marmalade

Под Roku можно писать игры на Marmalade. Это всё, что я могу сказать по этой теме.

Закрытый SDK

Если открыть тот же YouTube или Netflix, то окажется, что они совсем не похожи на то, что описано в документации. Говорят, что у подобных больших корпораций есть доступ к специальному SDK. Также есть мнение, что на самом деле это всё HTML. В общем, это ещё одна загадка Roku.

Проблемы

Проблема первая. Уже написав какой-никакой работающий канал, я всё ещё не понимаю, как это поможет сделать стриминг, аналогичный Chromecast. YouTube это умеет, а вот Vevo, сделанный на стандартном BrightScript, — нет. Кажется, это тоже фича только для избранных.

Проблема вторая. В нашем приложении есть несколько видео с YouTube. Так вот Roku напрочь отказывается воспроизводить их в хорошем качестве. Проблема известная, обсуждена много где (вот, например, её проявление). Единственное рабочее решение тут — скачивать mp4 на свой сервер, как-то его перекодировать и проигрывать оттуда. Именно так делают упомянутые выше Fullscreen Selects: несмотря на то, что представленные у них видео явно с YouTube, показывают они их, судя по снифферу, со своего CDN.

В общем, Roku полон сюрпризов не хуже Андроида. Хоть разработка канала и не выглядит ничем особенно сложным, завязнуть в ней можно плотно.

23 комментария:

George Luther комментирует...

Are you Unable to fix the Roku HDCP Error code 020 as your own? Don't get panic. Just grab your phone and dial the Roku helpline number for instant solutions. Our technical experts are 24/7 available to solve your queries instantly. Get in touch with us.

George Luther комментирует...

Is your Roku remote not working while you're streaming your Roku device? Don't get panic about your issues. Just talk to our technical experts on our toll-free number USA/Canada: +1-888-480-0288 & UK: +44-800-041-8324. Our technical experts are 24/7 available to solve your queries instantly. Get in touch with us.

Lisa Ashley комментирует...

Echo Dot is one of the best artificial intelligence devices and it can operate many devices on your command. But sometimes it can stop responding to your voice commands. It can happen due to various issues. Alexa Helpline can fix these issues. alexa helpline

georgelurther комментирует...

If you are looking for the solution to resolve the canon printer won't connect to wifi
error then get in touch with us. We are a team of dedicated techies who are available at day as well as at night for you. You can take the services anytime according to your wish. To know more check out our website canon printer offline.

ebookhelpline комментирует...

how to update kindle fire? Looking for the solution? Don’t worry we are here to guide you. Our skilled and dedicated team provide kindle services round the clock. So if you are facing any error related to kindle or if you want to know some tips about kindle device then feel free to call at our helpline number i.e. USA/Canada: +1–855–978–6855, UK: +44–800–041–8324 and for more information visit our website kindle help guides.
https://kindlehelpguides.com/how-to-update-kindle/

Antivirus 24x7 Support комментирует...

Thanks for sharing this type of post It’s really amazing post, this is very useful Blog. I have realized what we can miss if we don’t seek expert’s help for Panda antivirus related queries as soon as we face any issue. You can find Panda antivirus customer support Number.

George Luther комментирует...

Are you unable to find IP Address on Roku without Remote? Don't get panic. Just grab your phone and dial Roku helpline number for instant solution USA/Canada: +1-888-480-0288 & UK: +44-800-041-8324. Our technical experts are 24/7 available to solve your queries instantly. Get in touch with us.

George Luther комментирует...

Are you getting frustrated with your Roku Error Code 016 ? is your Roku device won't connect to Wi-Fi while you're using your Roku streaming device? Don't get frustrated anymore. Just talk to the technical experts which can help you to solve your queries instantly. Call us on our toll-free number for instant solution USA/Canada: +1-888-480-0288 & UK: +44-800-041-8324. Get in touch with us.

George Luther комментирует...

Is your Roku won't connect to Wi-Fi network? Don't get panic. Just simply talk to our technical experts they can provide you online helpdesk services for Roku device issues. Call us on our toll-free number for instant solution USA/Canada: +1-888-480-0288 & UK: +44-800-041-8324. Get in touch with us.

Roku-comlink комментирует...

If you are watching the video content that doesn’t support HDCP cable, then you will get Fix Roku hdcp error. To get this issue resolved.If AVR port is available on your device, then connect using the HDCP cable.

George Luther комментирует...

Is your Roku won't connect to Wi-Fi without Remote ? Don't get frustrated with these issue. Just grab your phone and dial Roku helpline number for instant solution USA/Canada: +1-888-480-0288 & UK: +44-800-041-8324. Go to our website for more information.

Unknown комментирует...


your blog is amazing thanks for sharing. visit the Great Assignment Help site.tbs activate roku

Unknown комментирует...


Your blog is amazing and incredible all information is very informative.roku related inquiry please click.nfl.com/activate/roku

Unknown комментирует...

Your blog is amazing and incredible all information is very informative.Roku related inquiry please click.disneynow activate roku

garmin express комментирует...

Thank for sharing the post if u want more information about gps then visit our website related inquiry please click.garmin express software

garmin express комментирует...

I truly making the most of your blog Thanks for sharing such a useful post. visit the Great Assignment Help site.Web Updater

Garmin.com/express-updates комментирует...

Since it lets you up to date your software, upload actions to Garmin Connect, upgrade your golf class maps, and enroll your products.Garmin express is a unique desktop software that offers the solution under one roof, follow the instructions to setup Garmin express. With the latest updates of Garmin Express Maps, you can without much of a stretch locate the new tracks, way points, and courses in the specific region.

Fubo.tv/Activate комментирует...

Unable to sign in and fubo.tv/connect a prevalent error that many people face when launching their face. are two options to sign-in or login on FuboTV. Before talking about installing and updating the application, let’s look at the devices it supports. You will only be able to fubo.tv/Connect.

techmanoj комментирует...



Norton is an antivirus that protects the system from web viruses and malware. As we know, millions of users come on the Internet every day in today’s environment, which can have both benefits and drawbacks, and to prevent those pitfalls

norton.com/enroll

jacksoncooper комментирует...

How to solve Kindle won’t connect to wifi error quickly? If you want to know the solution to fix this error then get connected with us. We will tell you the actual reason behind this error and provide you with the best solution. To know more check out the website Ebook Helpline.

lucynelson комментирует...

If you are facing canon printer won't connect to wifi error then get connected with our experts. Our team is very experienced and dedicated and are available round the clock to help you. For more information visit the website Printer Offline Error.

Fubotv Activate комментирует...

You can enjoy local channels of sports and entertainment with the highest quality of video resolution.A new feature called ‘4K On Demand’ comes to FuboTV Connect Code, which will help you browse exclusive 4k videos and channels. To choose this feature, just click on Fubo.tv/Activate and tap on the ‘4K on Demand’option.

Unknown комментирует...

You will first have to sign in and connect your device to further fubo.tv/activate your services. After you have created the account, you can download the application on your streaming device. You can even login with fubo.tv/connect enter code later if you forget your email id or password. fubo tv connect code