PlayerControl.xaml.cs 912 Bytes
Newer Older
Martin Finkel's avatar
Martin Finkel committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
using Xamarin.Forms;

namespace Gestures
{
    public partial class PlayerControl : ContentPage
    {
        MainViewModel _vm;

        public PlayerControl()
        {
            InitializeComponent();
        }

        protected override void OnAppearing()
        {
            base.OnAppearing();

            videoView.Loaded += VideoView_Loaded;

            _vm = BindingContext as MainViewModel;
            _vm.Initialize();
        }

        protected override void OnDisappearing()
        {
            base.OnDisappearing();

            videoView.Loaded -= VideoView_Loaded;

            _vm = BindingContext as MainViewModel;
            _vm.Stop();
        }

        private void VideoView_Loaded(object sender, System.EventArgs e)
        {
            _vm.MediaPlayer.Play();
        }
        
        void PanUpdated(object sender, PanUpdatedEventArgs e) => _vm.OnGesture(e);
    }
}