导航抽屉位于视频下方

时间:2017-07-05 20:36:48

标签: android xamarin xamarin.android

我有以下实现,用户可以观看视频。我有导航抽屉,用户可以在其中导航到以下片段 - TutorialFragment

视频自动开始播放,我想导航到其他片段,然后点击导航抽屉图标启动导航菜单项。

它可以工作,但它保留在用户无法点击的视频下。

TutorialFragment.cs

VideoView videoView;
MediaPlayer mediaPlayer;
MediaController mediaController;
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
   var ignored = base.OnCreateView(inflater, container, savedInstanceState);
   var view = this.BindingInflate(Resource.Layout.TutorialView, null); 
   var toolbar = view.FindViewById<Toolbar>(Resource.Id.tutorial_toolbar);

   ((MainView)Activity).SetSupportActionBar(toolbar);
    toolbar.SetNavigationIcon(Resource.Drawable.ic_menu_black_24dp);
    toolbar.Title = "Tutorial";
    toolbar.InflateMenu(Resource.Menu.toolbar_menu);

    videoView = view.FindViewById<VideoView>(Resource.Id.myVideo);
    videoView.Prepared += OnVideoPlayerPrepared;
    mediaController = new MediaController(this.Activity, true);             

   return view;
}

private void StartVideo()
{
    mediaController.SetAnchorView(videoView);
    mediaController.SetMediaPlayer(videoView);
    String fileName = "android.resource://" + this.Activity.BaseContext.PackageName + "/raw/test";
    videoView.SetVideoURI(Uri.Parse(fileName));
    videoView.Start();
}

void OnVideoPlayerPrepared(object sender, EventArgs e)
{
  mediaController.Show(2000);
}

public override void OnStart()
{
   base.OnStart();
   StartVideo();
   videoView.SetOnPreparedListener(this);
   videoView.Touch += (sender, e) =>
   {
      if (!(e.Event.Action == MotionEventActions.Down))
          return;
      if (!mediaController.IsShown)
           mediaController.Show();
      else
           mediaController.Hide();
     };

    videoView.Completion += (sender, e) => {
            //base.OnBackPressed();
    };
}

public override void OnStop()
{
  base.OnStop();
  videoView.Prepared -= OnVideoPlayerPrepared;
}

0 个答案:

没有答案