android TV-Building TV Channels,Developing a TV Input Service

》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:

  • TvInputService provides long-running and background availability for the TV input
  • TvInputService.Session maintains the TV input state and communicates with the hosting app
  • TvContract describes the channels and programs available to the TV input
  • TvContract.Channels represents information about a TV channel
  • TvContract.Programs describes a TV program with data such as program title and start time
  • TvTrackInfo represents an audio, video, or subtitle track
  • TvContentRating describes a content rating, allows for custom content rating schemes
  • TvInputManager provides 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_INPUT permission 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  TvInputManager  interface. The service declaration must also include an intent filter that specifies the  TvInputService  as 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 onCreate() method initializes theCaptioningManager and prepares to handle theACTION_BLOCKED_RATINGS_CHANGED andACTION_PARENTAL_CONTROLS_ENABLED_CHANGED actions. 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.
@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  TvInputService  creates a  TvInputService.Session  that implements  Handler.Callback  to handle player state changes. With  onSetSurface() , the  TvInputService.Session  sets the  Surface  with the video content.

 The TvInputService.Session handles 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.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
HbuilderX是一个用于开发多种应用的集成开发环境,包括H5应用。要使用HbuilderX打包H5 APP,可以按照以下步骤进行操作: 1. 下载并安装HbuilderX。 2. 在HbuilderX中新建一个项目,选择项目类型为H5 APP。 3. 选择项目的本地存放地址,并填写项目名称,然后点击创建。 4. 打开刚创建的项目,在项目文件中找到manifest.json文件。 5. 在manifest.json文件中填写你的H5项目地址。 6. 进行基本配置,根据你的需求进行设置。 7. 在SDK配置中,可以配置项目的appid、key和其他相关配置,比如定位功能的配置。 8. 填写完所有配置后,点击发行,选择云打包。 9. 等待云打包完成,HbuilderX会给出一个下载链接。 10. 点击下载链接,下载生成的安装包。 11. 将安装包安装到手机上,即可打开H5 APP。 以上是使用HbuilderX打包H5 APP的简要步骤,具体的操作细节可以参考HbuilderX的官方文档或者相关教程。 #### 引用[.reference_title] - *1* [hBuilderX将小程序打包h5](https://blog.csdn.net/weixin_33974433/article/details/91454803)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item] - *2* [HbuilderX打包appHbuilder怎么打包appH5打包appH5怎么打包app](https://blog.csdn.net/LIUAWEIO/article/details/88719446)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item] - *3* [HBuilderX H5 app打包以及加入个推](https://blog.csdn.net/zwx19921215/article/details/102918090)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值