android tv-Managing User Interaction
In the live TV experience the user changes channels and is presented with channel and program information briefly before the information disappears. Other types of information, such as messages ("DO NOT ATTEMPT AT HOME"), subtitles, or ads may need to persist. As with any TV app, such information should not interfere with the program content playing on the screen.
> Your TV input must render video onto a Surface
object,
which is passed by theTvInputService.Session.onSetSurface()
method.
Here's an example of how to use a MediaPlayer
instance
for playing content in the Surface
object:
@Override public boolean onSetSurface(Surface surface) { if (mPlayer != null) { mPlayer.setSurface(surface); } mSurface = surface; return true; } @Override public void onSetStreamVolume(float volume) { if (mPlayer != null) { mPlayer.setVolume(volume, volume); } mVolume = volume; }
Similarly, here's how to do it using ExoPlayer:
@Override public boolean onSetSurface(Surface surface) { if (mPlayer != null) { mPlayer.sendMessage(mVideoRenderer, MediaCodecVideoTrackRenderer.MSG_SET_SURFACE, surface); } mSurface = surface; return true; } @Override public void onSetStreamVolume(float volume) { if (mPlayer != null) { mPlayer.sendMessage(mAudioRenderer, MediaCodecAudioTrackRenderer.MSG_SET_VOLUME, volume); } mVolume = volume; }
> Use an overlay to display subtitles, messages, ads or MHEG-5 data broadcasts. By default,
the overlay is disabled. You can enable it when you create the session by callingTvInputService.Session.setOverlayViewEnabled(true)
,
as in the following example:
@Override public final Session onCreateSession(String inputId) { BaseTvInputSessionImpl session = onCreateSessionInternal(inputId); session.setOverlayViewEnabled(true); mSessions.add(session); return session; }
Use a View
object for the overlay, returned from TvInputService.Session.onCreateOverlayView()
,
as shown here:
@Override public View onCreateOverlayView() { LayoutInflater inflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE); View view = inflater.inflate(R.layout.overlayview, null); mSubtitleView = (SubtitleView) view.findViewById(R.id.subtitles); // Configure the subtitle view. CaptionStyleCompat captionStyle; float captionTextSize = getCaptionFontSize(); captionStyle = CaptionStyleCompat.createFromCaptionStyle( mCaptioningManager.getUserStyle()); captionTextSize *= mCaptioningManager.getFontScale(); mSubtitleView.setStyle(captionStyle); mSubtitleView.setTextSize(captionTextSize); return view; }
.> When you call TvInputService.Session.onTune()
,
you can prevent the video from being presented by calling TvInputService.Session.notifyVideoUnavailable()
and
passing the VIDEO_UNAVAILABLE_REASON_TUNING
constant,
as shown in the following example.
@Override public boolean onTune(Uri channelUri) { if (mSubtitleView != null) { mSubtitleView.setVisibility(View.INVISIBLE); } notifyVideoUnavailable(TvInputManager.VIDEO_UNAVAILABLE_REASON_TUNING); mUnblockedRatingSet.clear(); mDbHandler.removeCallbacks(mPlayCurrentProgramRunnable); mPlayCurrentProgramRunnable = new PlayCurrentProgramRunnable(channelUri); mDbHandler.post(mPlayCurrentProgramRunnable); return true; }
Then, when the content is rendered to the Surface
, you callTvInputService.Session.notifyVideoAvailable()
to
allow the video to display, like so:
@Override public void onDrawnToSurface(Surface surface) { mFirstFrameDrawn = true; notifyVideoAvailable(); }
相關文章
- jenkins使用shell命令打IOS包報錯:user interaction is not allowedJenkinsiOS
- antv f2 'interaction' is not a functionFunction
- pwn.college Fundementals Program interaction
- FATAL - Fatal error: Target Interaction Manager failed at StartupErrorAI
- 【譯】Learn D3 入門文件:Interaction
- android-Implementing Descendant Navigation,Notifying the UserAndroidNavigation
- 【Oculus Interaction SDK】(五)設定不同的抓握手勢
- 【Oculus Interaction SDK】(六)實體按鈕 && 按壓互動
- oracle user$Oracle
- 基於XR Interaction ToolKit與PUN實現VR多人協同功能VR
- 論文閱讀 A Data-Driven Graph Generative Model for Temporal Interaction Networks
- 【Oculus Interaction SDK】(九)使用控制器時顯示手的模型模型
- 【Oculus Interaction SDK】(三)限制可操作物體的移動 / 旋轉
- 【Oculus Interaction SDK】(七)使用射線進行互動(物體 & UI)UI
- [絕對原創] SAP Get User data by User ID
- Connection to x as user y failed: ERROR: Wrong password for userAIError
- user 和 user profile是聚合的關係嗎
- audit by user by table
- Vue @user 元件Vue元件
- net user命令
- HOW TO USER UNZIP
- MyBatis-maven-User例子-根據id查詢UserMyBatisMaven
- PRVF-4007 : User equivalence check failed for user "grid"UIAI
- Oracle中drop user和drop user cascade的區別Oracle
- call_user_func()與call_user_func_array函式函式
- user_tab_columns和user_tab_cols的區別!
- Django的User ModelDjango
- Oracle OCP(28):USEROracle
- Auth::user() 踩坑
- [Oracle Script] check userOracle
- oracle user privsOracle
- 【oracle】user_tablesOracle
- User Exits in FI/CO
- v_user_viewView
- mysql user qutoa toolMySql
- Hide the User MenuIDE
- @1-MYSQL當前使用者user()與current_user()MySql
- mysql5.5的一些函式_user()_current_user()MySql函式