예제 #1
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            SetContentView(Resource.Layout.player_activity);
            var root = FindViewById(Resource.Id.root);

            root.Touch += (sender, args) =>
            {
                var motionEvent = args.Event;
                switch (motionEvent.Action)
                {
                case MotionEventActions.Down:
                    ToggleControlsVisibility();
                    break;

                case MotionEventActions.Up:
                    ((View)sender).PerformClick();
                    break;
                }
                args.Handled = true;
            };
            root.KeyPress += (sender, args) =>
            {
                var keyCode = args.KeyCode;
                if (keyCode == Keycode.Back || keyCode == Keycode.Escape ||
                    keyCode == Keycode.Menu)
                {
                    args.Handled = false;
                }
                else
                {
                    _mediaController.DispatchKeyEvent(args.Event);
                }
            };

            _shutterView   = FindViewById(Resource.Id.shutter);
            _debugRootView = FindViewById(Resource.Id.controls_root);

            _videoFrame  = FindViewById <AspectRatioFrameLayout>(Resource.Id.video_frame);
            _surfaceView = FindViewById <SurfaceView>(Resource.Id.surface_view);
            _surfaceView.Holder.AddCallback(this);
            _debugTextView = FindViewById <TextView>(Resource.Id.debug_text_view);

            _playerStateTextView = FindViewById <TextView>(Resource.Id.player_state_view);
            _subtitleLayout      = FindViewById <SubtitleLayout>(Resource.Id.subtitles);

            _mediaController = new MediaController(this);
            _mediaController.SetAnchorView(root);
            _retryButton = FindViewById <Button>(Resource.Id.retry_button);
            _retryButton.SetOnClickListener(this);
            _videoButton = FindViewById <Button>(Resource.Id.video_controls);
            _audioButton = FindViewById <Button>(Resource.Id.audio_controls);
            _textButton  = FindViewById <Button>(Resource.Id.text_controls);

            var currentHandler = CookieHandler.Default;

            if (currentHandler != DefaultCookieManager)
            {
                CookieHandler.Default = DefaultCookieManager;
            }

            _audioCapabilitiesReceiver = new AudioCapabilitiesReceiver(this, this);
            _audioCapabilitiesReceiver.Register();
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            SetContentView(Resource.Layout.player_activity);
            var root = FindViewById(Resource.Id.root);

            root.Touch += (sender, args) =>
            {
                var motionEvent = args.Event;
                switch (motionEvent.Action)
                {
                    case MotionEventActions.Down:
                        ToggleControlsVisibility();
                        break;
                    case MotionEventActions.Up:
                        ((View) sender).PerformClick();
                        break;
                }
                args.Handled = true;
            };
            root.KeyPress += (sender, args) =>
            {
                var keyCode = args.KeyCode;
                if (keyCode == Keycode.Back || keyCode == Keycode.Escape
                    || keyCode == Keycode.Menu)
                {
                    args.Handled = false;
                }
                else
                {
                    _mediaController.DispatchKeyEvent(args.Event);
                }
            };

            _shutterView = FindViewById(Resource.Id.shutter);
            _debugRootView = FindViewById(Resource.Id.controls_root);

            _videoFrame = FindViewById<AspectRatioFrameLayout>(Resource.Id.video_frame);
            _surfaceView = FindViewById<SurfaceView>(Resource.Id.surface_view);
            _surfaceView.Holder.AddCallback(this);
            _debugTextView = FindViewById<TextView>(Resource.Id.debug_text_view);

            _playerStateTextView = FindViewById<TextView>(Resource.Id.player_state_view);
            _subtitleLayout = FindViewById<SubtitleLayout>(Resource.Id.subtitles);

            _mediaController = new MediaController(this);
            _mediaController.SetAnchorView(root);
            _retryButton = FindViewById<Button>(Resource.Id.retry_button);
            _retryButton.SetOnClickListener(this);
            _videoButton = FindViewById<Button>(Resource.Id.video_controls);
            _audioButton = FindViewById<Button>(Resource.Id.audio_controls);
            _textButton = FindViewById<Button>(Resource.Id.text_controls);

            var currentHandler = CookieHandler.Default;
            if (currentHandler != DefaultCookieManager)
            {
                CookieHandler.Default = DefaultCookieManager;
            }

            _audioCapabilitiesReceiver = new AudioCapabilitiesReceiver(this, this);
            _audioCapabilitiesReceiver.Register();
        }