Ejemplo n.º 1
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            SetContentView(Resource.Layout.PlayerControls);

            youTubePlayerView = FindViewById <YouTubePlayerView>(Resource.Id.youtube_view);
            StateTextView     = FindViewById <TextView> (Resource.Id.state_text);
            videoChooser      = FindViewById <Spinner>(Resource.Id.video_chooser);
            playButton        = FindViewById <Button>(Resource.Id.play_button);
            pauseButton       = FindViewById <Button>(Resource.Id.pause_button);
            skipTo            = FindViewById <EditText>(Resource.Id.skip_to_text);
            EventLogTextView  = FindViewById <TextView>(Resource.Id.event_log);

            styleRadioGroup = FindViewById <RadioGroup>(Resource.Id.style_radio_group);
            (FindViewById <RadioButton> (Resource.Id.style_default)).CheckedChange   += HandleCheckedChange;
            (FindViewById <RadioButton>(Resource.Id.style_minimal)).CheckedChange    += HandleCheckedChange;
            (FindViewById <RadioButton>(Resource.Id.style_chromeless)).CheckedChange += HandleCheckedChange;

            // Initialize PlayerHelper - Used by Listeners
            LogString = new StringBuilder();


            videoAdapter = new ArrayAdapter <ListEntry>(this, Android.Resource.Layout.SimpleSpinnerItem, entries);
            videoAdapter.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem);
            videoChooser.Adapter = videoAdapter;

            videoChooser.ItemSelected += (object sender, AdapterView.ItemSelectedEventArgs e) => {
                currentlySelectedPosition = e.Position;
                PlayVideoAtSelection();
            };

            playButton.Click    += (sender, e) => Player.Play();
            pauseButton.Click   += (sender, e) => Player.Pause();
            skipTo.EditorAction += (sender, e) => {
                int skipToSecs;
                int.TryParse(skipTo.Text, out skipToSecs);
                Player.SeekToMillis(skipToSecs * 1000);
                InputMethodManager imm = (InputMethodManager)GetSystemService(Context.InputMethodService);
                imm.HideSoftInputFromWindow(skipTo.WindowToken, 0);
            };

            youTubePlayerView.Initialize(DeveloperKey.Key, this);

            playlistEventListener     = new MyPlaylistEventListener();
            playerStateChangeListener = new MyPlayerStateChangeListener();
            playbackEventListener     = new MyPlaybackEventListener();

            SetControlsEnabled(false);
        }
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate (bundle);

            SetContentView (Resource.Layout.PlayerControls);

            youTubePlayerView =  FindViewById<YouTubePlayerView>(Resource.Id.youtube_view);
            StateTextView = FindViewById<TextView> (Resource.Id.state_text);
            videoChooser = FindViewById<Spinner>(Resource.Id.video_chooser);
            playButton = FindViewById<Button>(Resource.Id.play_button);
            pauseButton = FindViewById<Button>(Resource.Id.pause_button);
            skipTo = FindViewById<EditText>(Resource.Id.skip_to_text);
            EventLogTextView = FindViewById<TextView>(Resource.Id.event_log);

            styleRadioGroup = FindViewById<RadioGroup>(Resource.Id.style_radio_group);
            (FindViewById<RadioButton> (Resource.Id.style_default)).CheckedChange += HandleCheckedChange;
            (FindViewById<RadioButton>(Resource.Id.style_minimal)).CheckedChange += HandleCheckedChange;
            (FindViewById<RadioButton>(Resource.Id.style_chromeless)).CheckedChange += HandleCheckedChange;

            // Initialize PlayerHelper - Used by Listeners
            LogString = new StringBuilder();

            videoAdapter = new ArrayAdapter<ListEntry>(this, Android.Resource.Layout.SimpleSpinnerItem, entries);
            videoAdapter.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem);
            videoChooser.Adapter = videoAdapter;

            videoChooser.ItemSelected += (object sender, AdapterView.ItemSelectedEventArgs e) => {
                currentlySelectedPosition = e.Position;
                PlayVideoAtSelection();
            };

            playButton.Click += (sender, e) => Player.Play ();
            pauseButton.Click += (sender, e) => Player.Pause();
            skipTo.EditorAction += (sender, e) => {
                    int skipToSecs;
                    int.TryParse(skipTo.Text, out skipToSecs);
                Player.SeekToMillis(skipToSecs * 1000);
                    InputMethodManager imm = (InputMethodManager)GetSystemService(Context.InputMethodService);
                    imm.HideSoftInputFromWindow(skipTo.WindowToken, 0);
            };

            youTubePlayerView.Initialize(DeveloperKey.Key, this);

            playlistEventListener = new MyPlaylistEventListener();
            playerStateChangeListener = new MyPlayerStateChangeListener();
            playbackEventListener = new MyPlaybackEventListener();

            SetControlsEnabled(false);
        }