我正在使用leanback-v17:27.1.0库,我尝试自定义VideoSupportFragmentGlueHost,我想在这里添加更多按钮,如重复或下一步按钮enter image description here我试图使用leanback.app.PlaybackOverlayFragment但是在leanback-v17:27它是没有像本教程那样的PlaybackOverlayFragment类http://corochann.com/android-tv-application-hands-on-tutorial-7-159.html#PlaybackOverlayFragment有人可以帮我添加更多按钮到这个VideoSupportFragmentGlueHost
public void initData(MovieSampleResult mObject)
{
try {
VideoSupportFragmentGlueHost glueHost =
new VideoSupportFragmentGlueHost(PlayFullScreenVideoFragment.this);
MediaPlayerAdapter playerAdapter = new MediaPlayerAdapter(getContext());
playerAdapter.setRepeatAction(PlaybackControlsRow.RepeatAction.INDEX_NONE);
mTransportControlGlue = new PlaybackTransportControlGlue<>(getContext(), playerAdapter);
mTransportControlGlue.setHost(glueHost);
mTransportControlGlue.setTitle(mObject.getName());
//mTransportControlGlue.setSubtitle(mObject.getDescription());
playerAdapter.setDataSource(Uri.parse(mObject.getVideo()));
Log.e("TAG PLAY FULL",mObject.getVideo());
MyTrackApplication myTrackApplication = MyTrackApplication.getInstance();
myTrackApplication.trackScreenView(TAGSCREEN,
mObject.getName(),
"Watch Video on FullScreen Mode",0);
} catch (Exception e) {
e.printStackTrace();
Log.e(TAG,e.getMessage());
}
}
如果要向默认传输控件布局添加其他操作,则需要扩展PlaybackTransportControlGlue
类并覆盖添加操作的方法。
下面是一个示例,显示如何添加其他主要操作(顶部行,搜索栏上方)以跳过下一段内容,以及辅助操作(搜索栏下方)以启用隐藏式字幕。这个例子使用MediaPlayerAdapter
类,就像你在问题中使用的那样,但这可以适用于任何PlayerAdapter
实现。
public class VideoPlayerGlue extends PlaybackTransportControlGlue<MediaPlayerAdapter> {
private PlaybackControlsRow.SkipNextAction skipNextAction;
private PlaybackControlsRow.ClosedCaptioningAction closedCaptioningAction;
public VideoPlayerGlue(Context context, MediaPlayerAdapter impl) {
super(context, impl);
closedCaptioningAction = new PlaybackControlsRow.ClosedCaptioningAction(context);
skipNextAction = new PlaybackControlsRow.SkipNextAction(context);
}
@Override
protected void onCreatePrimaryActions(ArrayObjectAdapter primaryActionsAdapter) {
super.onCreatePrimaryActions(primaryActionsAdapter); // Adds play/pause first.
primaryActionsAdapter.add(skipNextAction); // Adds skip next second. Order matters.
}
@Override
protected void onCreateSecondaryActions(ArrayObjectAdapter secondaryActionsAdapter) {
secondaryActionsAdapter.add(closedCaptioningAction); // Adds CC to row below seek bar.
}
@Override
public void onActionClicked(Action action) {
// Handle your action clicks here to allow them to interface with
// the player and/or the PlayerAdapter.
super.onActionClicked(action); // Allows for built-in play/pause and seek bar clicks.
}
}