This sample app showcases different components that come with Leanback library.
The home screen in this sample app is a BrowseFragment consisting of a set of different cards. Each card represents a component in Leanback.
All the cards in this sample app work except the Settings. Settings for now crashes due to some internal issue, and we are working on resolving that in the next few days.
We will also add a new music example card soon. This will be a new PlaybackOverlayFragment that comes with a set of new features.
If you use Android Studio as recommended, the following dependencies will automatically be installed by Gradle.
git clone https://github.com/googlesamples/leanback-showcase.git
Need more information about getting started with Android TV? Check the official docs.
If you need additional help, our community might be able to help.
We love contributions! :smile: Please follow the steps in the CONTRIBUTING guide to get started. If you found a bug, please file it here.
Licensed under the Apache 2.0 license. See the LICENSE file for details.
compileSdkVersion 26
applicationId 'com.example.android.persistence'
minSdkVersion 21
targetSdkVersion 26
versionCode 1
versionName "1.0"
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:design:' + rootProject.supportLibVersion
compile 'com.android.support:cardview-v7:' + rootProject.supportLibVersion
compile 'com.android.support:recyclerview-v7:' + rootProject.supportLibVersion
compile 'android.arch.lifecycle:extensions:' + rootProject.archLifecycleVersion
compile 'android.arch.persistence.room:runtime:' + rootProject.archRoomVersion
testCompile 'junit:junit:4.12'
compile 'com.android.support:leanback-v17:' + rootProject.supportLibVersion
compile 'com.android.support:appcompat-v7:' + rootProject.supportLibVersion
compile 'com.android.support:preference-v7:'+ rootProject.supportLibVersion
compile 'com.android.support:preference-leanback-v17:' + rootProject.supportLibVersion
compile 'com.android.support:preference-v14:' + rootProject.supportLibVersion
compile "com.google.code.gson:gson:2.8.1"
compile "com.android.support:palette-v7:" + rootProject.supportLibVersion
compile 'com.google.android.exoplayer:exoplayer:r2.2.0'
compile 'com.github.bumptech.glide:glide:4.0.0-RC1'
compile 'com.android.support:support-tv-provider:' + rootProject.supportLibVersion
compile 'com.squareup.retrofit2:converter-gson:2.3.0'
compile 'com.squareup.retrofit2:retrofit:2.3.0'
package android.support.v17.leanback.supportleanbackshowcase
uses-permission
application .app.room.controller.app.SampleApplication
Called when the activity is first created.
Activity showcasing the use of {@link android.support.v17.leanback.widget.PageRow} and {@link android.support.v17.leanback.widget.ListRow}.
An Activity displaying a wizard for renting a movie.
TODO: Javadoc
Contains a {@link DetailsFragment} in order to display more details for a given card.
Contains a {@link DetailsFragment} with video background in order to display more details for a given card.
TODO: Javadoc
TODO: Javadoc
TODO: Javadoc
Activity that hosts VideoConsumptionExampleFragment.
Activity that hosts VideoConsumptionExampleWithExoPlayerFragment.
TODO: Javadoc
The main activity to demonstrate how to add/ remove video rows from app to android tv launcher * It will hold DynamicRowsFragment for all UI interaction
VideoPlaybackActivity for video playback that loads PlaybackFragment * This activity can be invoked in two scenarios,
- In DynamicRowFragment, when the video clips is clicked, this activity will be fired up to play the video
- When the channel is added to the home screen, click the video content will also start since this activity can receive the broadcast which is declared in AndroidManifest.xml * <data android:scheme="rowsnewapi" android:host="android.support.v17.leanback.supportleanbackshowcase" android:pathPrefix="/playvideo" />
This is the helper function to extract the videoId (an unique id which will not be changed along with the transaction)
This is a helper function which can extract key fields from VideoContent (a data structure designed specific for the video clip which can be added to home screen) to MediaMetaData (a data structure which is used by VideoConsumptionExampleFragment.java to play and extract video meta data) So we can have unified data transmission interface without type casting on the fragment side * @param videoContent The video content you want to convert to MediaMetaData. @return MediaMetaData The conversion result.
If this activity is started from the home screen (that is the only information we have is videoId) a videoContent will be constructed through it, and put as an extra to the intent So VideoConsumptionExampleFragment can find the video source to play
Populate play lists firstly
Iterate through all video clips to find the video content which is selected from home screen
If this activity is started from clicking the video content from DynamicRowFragment
Firstly convert VideoContent to MediaMetaData, then put MediaMetaData as an extra for this intent
Activity that showcases different aspects of GuidedStepFragments.
Extend from LifecycleActivity so this activity can be used as the owner of lifecycle event
Extend from LifecycleActivity so this activity can be used as the owner of lifecycle event
Extend from LifecycleActivity so this activity can be used as the owner of lifecycle event
Music service that handles all the interactions between the app and the media player. It receives media list from an app and starts playing the media items one after another. Apps can also directly interact with the service for specific operations such as playing or pausing or getting different info about the current media item.
Sets the media session's activity launched when clicking on NowPlayingCard. This returns to the media screen that is playing or paused; the launched activity corresponds to the currently shown media session in the NowPlayingCard on TV launcher.
@return The available set of actions for the media session. These actions should be provided for the MediaSession PlaybackState in order for {@link MediaSessionCompat.Callback#onMediaButtonEvent} to call relevant methods of onPause() or onPlay().
starts playback of the previously opened media file
pauses playback (call play() to resume)
skip to next item
skip to previous item
@return The current playback position in milliseconds.
@return The duration of the current media item in milliseconds
Seeks to the given new position in milliseconds of the current media item @param newPosition The new position of the current media item in milliseconds
Configures service as a foreground service.