Courtesy: GitHub

Sample Android TV Channel App (TV Input) using TIF

This app is designed to show how to build live TV channel apps for Android TV using the TV Input Framework (TIF). The sample is a service that once installed, is recognized and run by the default TV app (e.g. Live Channels app).

Introduction

The sample app consists of a single TV input: 4 channels consisting of MP4 videos, HLS stream and MPEG-DASH stream, organized into various genres. The video files are served from Google Cloud Storage.

References and Developer Guides

TIF Companion Library

This app uses the TIF Companion Library. The source code for the library is in the library directory. To use this library in your project, copy the directory over or use the following Gradle dependency:

compile 'com.google.android.libraries.tv:companionlibrary:0.1'

Pre-requisites

Getting Started

Note that the Live Channels app does not show up in Apps on Home screen unless there is at least one TV input service or a physical input like HDMI1.

To set up the TV input:

  • Start Live Channels app
  • Click Search to search for and add channels
  • Alternatively within Live Channels app,
    • Click ENTER to bring out Recent Channels
    • Click DOWN to enter TV options
    • Click RIGHT to Channel sources and select it
    • Click DOWN to select Rich Input and click ENTER to select it
    • Click ADD CHANNELS NOW to add channels of MP4 videos, HLS stream and MPEG-DASH stream
  • To watch sample channels, simply toggle UP and DOWN to switch channels
  • Visit Channel Sources -> Rich Input -> Settings to see mock options for input settings.

Screenshots

TV program guide TV options TV options:channel sources Add Rich TV Input

Support

License

License under the Apache 2.0 license. See the LICENSE file for details.

How to make contributions?

Please read and follow the steps in the CONTRIBUTING.md

Notice

Images/videos used in this sample are courtesy of the Blender Foundation, shared under copyright or Creative Commons license.

  • Elephant's Dream: (c) copyright 2006, Blender Foundation / Netherlands Media Art Institute / www.elephantsdream.org
  • Sintel: (c) copyright Blender Foundation | www.sintel.org
  • Tears of Steel: (CC) Blender Foundation | mango.blender.org
  • Big Buck Bunny: (c) copyright 2008, Blender Foundation / www.bigbuckbunny.org

compileSdkVersion 24

minSdkVersion 21

targetSdkVersion 24

versionCode 1

versionName "1.0"

compile fileTree(dir: 'libs', include: ['*.jar'])

compile 'com.android.support:appcompat-v7:24.0.0'

compile 'com.google.ads.interactivemedia.v3:interactivemedia:3.2.1'

compile 'com.google.android.gms:play-services-ads:8.4.0'

testCompile 'junit:junit:4.12'

testCompile 'org.mockito:mockito-core:1.10.19'

testCompile "org.robolectric:robolectric:3.1"

compileSdkVersion 24

applicationId "com.example.android.sampletvinput"

minSdkVersion 21

targetSdkVersion 24

versionCode 2

versionName "1.1"

compile project(':library')

compile 'com.android.support:recyclerview-v7:24.0.0'

compile 'com.android.support:leanback-v17:24.0.0'

compile 'com.android.support:appcompat-v7:24.0.0'

compile 'com.google.android.exoplayer:exoplayer:r1.5.6'

package com.google.android.media.tv.companionlibrary

package com.google.android.media.tv.companionlibrary.test

uses-permission

  • com.android.providers.tv.permission.READ_EPG_DATA
  • com.android.providers.tv.permission.WRITE_EPG_DATA
  • android.permission.RECEIVE_BOOT_COMPLETED

package com.example.android.sampletvinput

uses-permission

  • android.permission.INTERNET
  • com.android.providers.tv.permission.READ_EPG_DATA
  • com.android.providers.tv.permission.WRITE_EPG_DATA
  • android.permission.RECEIVE_BOOT_COMPLETED

MainActivity

RichTvInputSetupActivity

RichAppLinkDetailsActivity

RichAppLinkSidePanelActivity

MainActivity

RichTvInputSetupActivity

RichAppLinkDetailsActivity

RichAppLinkSidePanelActivity

MainActivity

MainActivity class that loads {@link MainFragment}.

RichTvInputSetupActivity

The setup activity for demonstrating {@link RichTvInputService}.

RichAppLinkDetailsActivity

RichAppLinkSidePanelActivity

Activity that shows a simple side panel UI.

Adapter class that provides the app link menu list.

RichTvInputService

SampleJobService

RichTvInputService

SampleJobService

RichTvInputService

TvInputService which provides a full implementation of EPG, subtitles, multi-audio, parental controls, and overlay view.

Gets the track id of the track type and track index. * @param trackType the type of the track e.g. TvTrackInfo.TYPE_AUDIO @param trackIndex the index of that track within the media. e.g. 0, 1, 2... @return the track id for the type & index combination.

Gets the index of the track for a given track id. * @param trackId the track id. @return the track index for the given id, as an integer.

SampleJobService

EpgSyncJobService that periodically runs to update channels and programs.

Test VAST URL from DoubleClick for Publishers (DFP). More sample VAST tags can be found on DFP website. You should replace it with the vast tag that you applied from your advertisement provider. To verify whether your video ad response is VAST compliant, try<a href="https://developers.google.com/interactive-media-ads/docs/sdks/android/vastinspector"> Google Ads Mobile Video Suite Inspector

RichBootReceiver

RichBootReceiver

RichBootReceiver

This BroadcastReceiver is set up to make sure sync job can schedule after reboot. Because JobScheduler doesn't work well on reboot scheduler on L/L-MR1.