android TV-Building TV Channels,Developing a TV Input Service
2016-01-22 11:28
543 查看
》Building TV Channels
To provide your users a similar experience, use the TV Input Framework to create channels for publishing video or music content so that your media appears alongside traditional
TV channels in the programming guide.
Android supports receiving and playback of live video content through the TV Input Framework in Android 5.0 (API level 21). This framework provides a unified method for receiving
audio and video channel content from hardware sources, such as HDMI ports and built-in-tuners, and software sources, such as video streamed over the internet.The framework enables
developers to define live TV input sources by implementing a TV input service.
The TV Input Framework is designed to provide access to a wide variety of live TV input sources and bring them together in a single user interface for users to browse, view, and
enjoy content. Building a TV input service for your content can help make it more accessible on TV devices.
》Developing a TV Input Service
With the TV input service, you can provide parental controls, program guide information, and content ratings.
> To develop a TV input service, you implement the following components:
availability for the TV input
input state and communicates with the hosting app
to the TV input
about a TV channel
with data such as program title and start time
track
for custom content rating schemes
app and manages the interaction with TV inputs and apps
>Your app manifest must declare your
Within that declaration, specify the
to allow the service to connect the TV input to the system. A system service (
system TV app sends requests to TV input services via the
The service declaration must also include an intent filter that specifies the
the action to perform with the intent. Also within the service declaration, declare the service meta data in a separate XML resource.
> The
a
implements
handle player state changes. With
the
the
the video content.
The
the
when the user selects a channel, and notifies the system TV app for changes in the content and content meta data. These
inControl Content and Handle
Track Selection further in this training.
The system TV app works with the setup activity you define for your TV input. The setup activity is required and must provide at least one channel record for the system database.
The system TV app will invoke the setup activity when it cannot find a channel for the TV input.
To provide your users a similar experience, use the TV Input Framework to create channels for publishing video or music content so that your media appears alongside traditional
TV channels in the programming guide.
Android supports receiving and playback of live video content through the TV Input Framework in Android 5.0 (API level 21). This framework provides a unified method for receiving
audio and video channel content from hardware sources, such as HDMI ports and built-in-tuners, and software sources, such as video streamed over the internet.The framework enables
developers to define live TV input sources by implementing a TV input service.
The TV Input Framework is designed to provide access to a wide variety of live TV input sources and bring them together in a single user interface for users to browse, view, and
enjoy content. Building a TV input service for your content can help make it more accessible on TV devices.
》Developing a TV Input Service
With the TV input service, you can provide parental controls, program guide information, and content ratings.
> To develop a TV input service, you implement the following components:
TvInputServiceprovides long-running and background
availability for the TV input
TvInputService.Sessionmaintains the TV
input state and communicates with the hosting app
TvContractdescribes the channels and programs available
to the TV input
TvContract.Channelsrepresents information
about a TV channel
TvContract.Programsdescribes a TV program
with data such as program title and start time
TvTrackInforepresents an audio, video, or subtitle
track
TvContentRatingdescribes a content rating, allows
for custom content rating schemes
TvInputManagerprovides an API to the system TV
app and manages the interaction with TV inputs and apps
>Your app manifest must declare your
TvInputService.
Within that declaration, specify the
BIND_TV_INPUTpermission
to allow the service to connect the TV input to the system. A system service (
TvInputManagerService) performs the binding and has that permission. The
system TV app sends requests to TV input services via the
TvInputManagerinterface.
The service declaration must also include an intent filter that specifies the
TvInputServiceas
the action to perform with the intent. Also within the service declaration, declare the service meta data in a separate XML resource.
<service android:name="com.example.sampletvinput.SampleTvInput" android:label="@string/sample_tv_input_label" android:permission="android.permission.BIND_TV_INPUT"> <intent-filter> <action android:name="android.media.tv.TvInputService" /> </intent-filter> <meta-data android:name="android.media.tv.input" android:resource="@xml/sample_tv_input" /> </service>
<tv-input xmlns:android="http://schemas.android.com/apk/res/android" android:setupActivity="com.example.sampletvinput.SampleTvInputSetupActivity" />
>the [code]onCreate()method initializes the
CaptioningManagerand prepares to handle the
ACTION_BLOCKED_RATINGS_CHANGEDand
ACTION_PARENTAL_CONTROLS_ENABLED_CHANGEDactions. These actions describe system intents fired when the user changes the parental control settings, and when there is a change on the list of blocked ratings.[/code]
@Override public void onCreate() { super.onCreate(); mHandlerThread = new HandlerThread(getClass() .getSimpleName()); mHandlerThread.start(); mDbHandler = new Handler(mHandlerThread.getLooper()); mHandler = new Handler(); mCaptioningManager = (CaptioningManager) getSystemService(Context.CAPTIONING_SERVICE); setTheme(android.R.style.Theme_Holo_Light_NoActionBar); mSessions = new ArrayList<BaseTvInputSessionImpl>(); IntentFilter intentFilter = new IntentFilter(); intentFilter.addAction(TvInputManager .ACTION_BLOCKED_RATINGS_CHANGED); intentFilter.addAction(TvInputManager .ACTION_PARENTAL_CONTROLS_ENABLED_CHANGED); registerReceiver(mBroadcastReceiver, intentFilter); }
> The
TvInputServicecreates
a
TvInputService.Sessionthat
implements
Handler.Callbackto
handle player state changes. With
onSetSurface(),
the
TvInputService.Sessionsets
the
Surfacewith
the video content.
The
TvInputService.Sessionhandles
the
onTune()event
when the user selects a channel, and notifies the system TV app for changes in the content and content meta data. These
notify()methods are described
inControl Content and Handle
Track Selection further in this training.
The system TV app works with the setup activity you define for your TV input. The setup activity is required and must provide at least one channel record for the system database.
The system TV app will invoke the setup activity when it cannot find a channel for the TV input.
相关文章推荐
- 【rabbitmq】 com.rabbitmq.client.AlreadyClosedException: channel is already closed due to channel erro
- android minSdkVersion maxSdkVersion targetSdkVersion build target
- [下载]微软公布Windows 10 TH2 Build 10586 ISO镜像
- java操作数据库增删改查的小工具2--TxQueryRunner
- iOS-CGRect、CGSize、CGPoint__UIEdgeInsets 介绍
- innerHTML、innerText、textContent和value属性
- POJ2533 Longest ordered subsequence
- 相机(摄像头)获取到的图片自动旋转90度解决办法
- MongoVUE查询备忘
- 咦,为DJANGO的ORM的QUERYSET增加数据列的样码,很好用哟
- UI知识点总结
- UI测试题
- UINavigationController和UINavigationControllerDelegate
- 蓝欧考试UI考试绝密
- POJ 2299 Ultra-QuickSort (求序列的逆序对数)
- 解决Android Studio导入项目一直停留在building "your project name" gradle project info的问题
- 《iOS Human Interface Guidelines》——AirPrint
- [caffe]prerequisites
- iOS UILabel高度的极限值
- SAP GUI740的PATCH7出来了