private void LoadDataVideo() { try { switch (Video) { case null: return; } LoadVideo_Data(Video); switch (string.IsNullOrEmpty(Video.Iframe)) { case false: { if (Video.Iframe.Contains("Youtube") || Video.Iframe.Contains("youtu")) { VideoIdYoutube = Video.Iframe.Split(new[] { "v=", "/" }, StringSplitOptions.None).LastOrDefault(); YouTubePlayerView youTubeView = new YouTubePlayerView(this); var youtubeView = FindViewById <FrameLayout>(Resource.Id.root); youtubeView.RemoveAllViews(); youtubeView.AddView(youTubeView); youTubeView.Initialize(GetText(Resource.String.google_key), this); VideoActionsController.SimpleExoPlayerView.Visibility = ViewStates.Gone; VideoActionsController.ReleaseVideo(); YoutubePlayer?.LoadVideo(VideoIdYoutube); } break; } default: { var dbDatabase = new SqLiteDatabase(); var dataVideos = dbDatabase.Get_WatchOfflineVideos_ById(Video.Id); if (dataVideos != null) { VideoActionsController.PlayVideo(dataVideos.Source, dataVideos); } else { VideoActionsController.PlayVideo(Video.Source, Video); } break; } } StartApiService(); } catch (Exception e) { Methods.DisplayReportResultTrack(e); } }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.playerview_demo); YouTubePlayerView youTubeView = FindViewById <YouTubePlayerView>(Resource.Id.youtube_view); youTubeView.Initialize(DeveloperKey.DEVELOPER_KEY, this); }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); // Create your application here SetContentView(Resource.Layout.PlayerView); YouTubePlayerView youTubeView = FindViewById <YouTubePlayerView>(Resource.Id.youtube_view); youTubeView.Initialize(DeveloperKey.Key, this); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); var intent = Intent; VideoId = intent?.GetStringExtra(ExtraUrlKey); SetContentView(Resource.Layout.activity_video_fullscreen); player = FindViewById <YouTubePlayerView>(Resource.Id.youtube_view); player.Initialize(DeveloperKey.Key, this); }
protected override void OnCreate(Bundle savedInstanceState) { RequestWindowFeature(WindowFeatures.NoTitle); base.OnCreate(savedInstanceState); // Set our view from the "main" layout resource SetContentView(Resource.Layout.Youtube_Player); idvideo = Intent.GetStringExtra("videoid"); // gets the previously created intent ;) youTubeView = FindViewById <YouTubePlayerView>(Resource.Id.videoplayeryoutube); youTubeView.Initialize(AppSettings.DEVELOPER_KEY, this); }
private void LoadDataVideo() { try { if (Video == null) { return; } if (!string.IsNullOrEmpty(Video.Iframe)) { TabVideosAbout.LoadVideo_Data(Video); if (Video.Iframe.Contains("Youtube") || Video.Iframe.Contains("youtu")) { var ft = SupportFragmentManager.BeginTransaction(); VideoIdYoutube = Video.Iframe.Split(new[] { "v=", "/" }, StringSplitOptions.None).LastOrDefault(); YouTubePlayerView youTubeView = new YouTubePlayerView(this); var youtubeView = FindViewById <FrameLayout>(Resource.Id.root); youtubeView.RemoveAllViews(); youtubeView.AddView(youTubeView); youTubeView.Initialize(AppSettings.YoutubeKey, this); VideoActionsController.SimpleExoPlayerView.Visibility = ViewStates.Gone; VideoActionsController.ReleaseVideo(); YoutubePlayer?.LoadVideo(VideoIdYoutube); } } else { var dbDatabase = new SqLiteDatabase(); var dataVideos = dbDatabase.Get_WatchOfflineVideos_ById(Video.Id); if (dataVideos != null) { VideoActionsController.PlayVideo(dataVideos.Source, dataVideos); } else { VideoActionsController.PlayVideo(Video.Source, Video); } } } catch (Exception e) { Methods.DisplayReportResultTrack(e); } }
protected override void OnCreate(Bundle bundle) { base.OnCreate (bundle); _videoId = Intent.GetStringExtra ("VIDEO_ID"); _playerView = new YouTubePlayerView (this); _playerView.Initialize ("AIzaSyAUine_14xO0zRGibiwFgK_jLdEtQZsvpQ", this); SetContentView (_playerView); // Create your application here }
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 savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.player); var intent = Intent; var extras = intent.Extras; if (extras != null) { var type = extras.GetString("url"); vedioId = type.Split('=').LastOrDefault(); youtube = this.FindViewById <YouTubePlayerView>(Resource.Id.youtube_view); youtube.Initialize("AIzaSyBAwFnF-qEiy-hOhH2ogkDTf7VsfWiwB14", this); } }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.player_controls_demo); youTubePlayerView = FindViewById <YouTubePlayerView>(Resource.Id.youtube_view); stateText = 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); eventLog = FindViewById <TextView>(Resource.Id.event_log); styleRadioGroup = (RadioGroup)FindViewById(Resource.Id.style_radio_group); FindViewById <RadioButton>(Resource.Id.style_default).CheckedChange += (sender, e) => player.SetPlayerStyle(YouTubePlayerPlayerStyle.Default); FindViewById <RadioButton>(Resource.Id.style_minimal).CheckedChange += (sender, e) => player.SetPlayerStyle(YouTubePlayerPlayerStyle.Minimal); FindViewById <RadioButton>(Resource.Id.style_chromeless).CheckedChange += (sender, e) => player.SetPlayerStyle(YouTubePlayerPlayerStyle.Chromeless); logString = new StringBuilder(); videoAdapter = new ArrayAdapter <ListEntry>(this, Android.Resource.Layout.SimpleSpinnerItem, Entries); videoAdapter.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem); videoChooser.ItemSelected += (sender, e) => { currentlySelectedPosition = e.Position; PlayVideoAtSelection(); }; videoChooser.Adapter = videoAdapter; playButton.Click += (sender, e) => player.Play(); pauseButton.Click += (sender, e) => player.Pause(); skipTo.EditorAction += (sender, e) => { int skipToSecs = ParseInt(skipTo.Text, 0); player.SeekToMillis(skipToSecs * 1000); var imm = InputMethodManager.FromContext(this); imm.HideSoftInputFromWindow(skipTo.WindowToken, 0); e.Handled = true; }; youTubePlayerView.Initialize(DeveloperKey.Key, this); SetControlsEnabled(false); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.fullscreen_demo); baseLayout = FindViewById <LinearLayout>(Resource.Id.layout); playerView = FindViewById <YouTubePlayerView>(Resource.Id.player); fullscreenButton = FindViewById <Button>(Resource.Id.fullscreen_button); checkbox = FindViewById <CompoundButton>(Resource.Id.landscape_fullscreen_checkbox); otherViews = FindViewById(Resource.Id.other_views); checkbox.SetOnCheckedChangeListener(this); // You can use your own button to switch to fullscreen too fullscreenButton.SetOnClickListener(this); playerView.Initialize(DeveloperKey.DEVELOPER_KEY, this); DoLayout(); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.fullscreen_demo); baseLayout = FindViewById <LinearLayout>(Resource.Id.layout); playerView = FindViewById <YouTubePlayerView>(Resource.Id.player); fullscreenButton = FindViewById <Button>(Resource.Id.fullscreen_button); checkbox = FindViewById <CompoundButton>(Resource.Id.landscape_fullscreen_checkbox); otherViews = FindViewById(Resource.Id.other_views); checkbox.CheckedChange += (sender, e) => { int controlFlags = player.FullscreenControlFlags; if (e.IsChecked) { // If you use the FULLSCREEN_FLAG_ALWAYS_FULLSCREEN_IN_LANDSCAPE, your activity's normal UI // should never be laid out in landscape mode (since the video will be fullscreen whenever the // activity is in landscape orientation). Therefore you should set the activity's requested // orientation to portrait. Typically you would do this in your AndroidManifest.xml, we do it // programmatically here since this activity demos fullscreen behavior both with and without // this flag). RequestedOrientation = PortraitOrientation; controlFlags |= YouTubePlayer.FullscreenFlagAlwaysFullscreenInLandscape; } else { RequestedOrientation = ScreenOrientation.Sensor; controlFlags &= ~YouTubePlayer.FullscreenFlagAlwaysFullscreenInLandscape; } player.FullscreenControlFlags = controlFlags; }; fullscreenButton.Click += (sender, e) => { player.SetFullscreen(!fullscreen); }; playerView.Initialize(DeveloperKey.Key, this); DoLayout(); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.activity_youtube_test); imgView1 = FindViewById <ImageView>(Resource.Id.imgView1); imgView2 = FindViewById <ImageView>(Resource.Id.imgView2); videoLayer = FindViewById <View>(Resource.Id.videoLayer); baseView = FindViewById <View>(Resource.Id.baseView); SetImages(); imgView1.Click += ImgView1_Click; imgView2.Click += ImgView2_Click; videoLayer.Click += VideoLayer_Click; youtubeView = FindViewById <YouTubePlayerView>(Resource.Id.youtubeView); youtubeView.Initialize(Constant.YoutubeApiKey, this); }
protected async override void OnElementChanged(ElementChangedEventArgs <YoutubePlayer> args) { base.OnElementChanged(args); YoutubeXamarin = args.NewElement; if (args.NewElement != null) { if (Control == null) { var activity = Plugin.CurrentActivity.CrossCurrentActivity.Current.Activity as MainActivity; // Save the VideoView for future reference youTubePlayerView = new YouTubePlayerView(Context); // Put the VideoView in a RelativeLayout ARelativeLayout relativeLayout = new ARelativeLayout(Context); relativeLayout.AddView(youTubePlayerView); // Center the VideoView in the RelativeLayout ARelativeLayout.LayoutParams layoutParams = new ARelativeLayout.LayoutParams(LayoutParams.MatchParent, LayoutParams.WrapContent); layoutParams.AddRule(LayoutRules.AlignParentTop); youTubePlayerView.LayoutParameters = layoutParams; youTubePlayerView.PlayerUiController.ShowYouTubeButton(false); youTubePlayerView.PlayerUiController.ShowFullscreenButton(YoutubeXamarin.FullscrennEnable); // Use the RelativeLayout as the native control SetNativeControl(relativeLayout); youTubePlayerView.AddYouTubePlayerListener(this); youTubePlayerView.AddFullScreenListener(this); while (tubePlayer == null) { await Task.Delay(100); } //tubePlayer.LoadVideo("fBg7xDeSxh0", 0); } } }
public void InitInterface() { youTubePlayerView = FindViewById <YouTubePlayerView>(Resource.Id.youtube_view); stateText = 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); eventLog = FindViewById <TextView>(Resource.Id.event_log); styleRadioGroup = FindViewById <RadioGroup>(Resource.Id.style_radio_group); (FindViewById <RadioButton>(Resource.Id.style_default)).SetOnCheckedChangeListener(this); (FindViewById <RadioButton>(Resource.Id.style_minimal)).SetOnCheckedChangeListener(this); (FindViewById <RadioButton>(Resource.Id.style_chromeless)).SetOnCheckedChangeListener(this); logString = new SpannableStringBuilder(); videoAdapter = new ArrayAdapter <ListEntry>(this, Android.Resource.Layout.SimpleSpinnerItem, ENTRIES); videoAdapter.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem); videoChooser.OnItemSelectedListener = this; videoChooser.Adapter = videoAdapter; playButton.SetOnClickListener(this); pauseButton.SetOnClickListener(this); skipTo.SetOnEditorActionListener(this); youTubePlayerView.Initialize(DeveloperKey.DEVELOPER_KEY, this); playlistEventListener = new MyPlaylistEventListener() { OnNextAction = () => { Log("NEXT VIDEO"); }, OnPlaylistEndedAction = () => { Log("PLAYLIST ENDED"); }, OnPreviousAction = () => { Log("PREVIOUS VIDEO"); } }; playerStateChangeListener = new MyPlayerStateChangeListener() { OnAdStartedAction = () => { UpdateText(); Log(playerStateChangeListener.playerState); }, OnErrorAction = (p0) => { if (p0 == YouTubePlayerErrorReason.UnexpectedServiceDisconnection) { // When this error occurs the player is released and can no longer be used. player = null; SetControlsEnabled(false); } UpdateText(); Log(playerStateChangeListener.playerState); }, OnLoadedAction = (p0) => { UpdateText(); Log(playerStateChangeListener.playerState); }, OnLoadingAction = () => { UpdateText(); Log(playerStateChangeListener.playerState); }, OnVideoEndedAction = () => { UpdateText(); Log(playerStateChangeListener.playerState); }, OnVideoStartedAction = () => { UpdateText(); Log(playerStateChangeListener.playerState); } }; playbackEventListener = new MyPlaybackEventListener() { OnPlayingAction = () => { UpdateText(); } }; 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); }
private void InitComponent() { try { MainView = FindViewById <CoordinatorLayout>(Resource.Id.main_content); SecondReactionButton = FindViewById <TextView>(Resource.Id.SecondReactionText); MainSectionButton = FindViewById <LinearLayout>(Resource.Id.linerSecondReaction); LikeButton = FindViewById <ReactButton>(Resource.Id.ReactButton); CommentCount = FindViewById <TextView>(Resource.Id.Commentcount); LikeCount = FindViewById <TextView>(Resource.Id.Likecount); TimeText = FindViewById <AppCompatTextView>(Resource.Id.time_text); PrivacyPostIcon = FindViewById <AppCompatTextView>(Resource.Id.privacyPost); MoreIcon = FindViewById <ImageView>(Resource.Id.moreicon); Username = FindViewById <TextViewWithImages>(Resource.Id.username); UserAvatar = FindViewById <CircleImageView>(Resource.Id.userAvatar); Description = FindViewById <SuperTextView>(Resource.Id.description); PostExtrasLayout = FindViewById <RelativeLayout>(Resource.Id.postExtras); ShareLinearLayout = FindViewById <LinearLayout>(Resource.Id.ShareLinearLayout); CommentLinearLayout = FindViewById <LinearLayout>(Resource.Id.CommentLinearLayout); SecondReactionLinearLayout = FindViewById <LinearLayout>(Resource.Id.SecondReactionLinearLayout); if (SecondReactionButton != null) { if (AppSettings.PostButton == PostButtonSystem.ReactionDefault || AppSettings.PostButton == PostButtonSystem.ReactionSubShine || AppSettings.PostButton == PostButtonSystem.Like) { MainSectionButton.WeightSum = 3; SecondReactionLinearLayout.Visibility = ViewStates.Gone; } else if (AppSettings.PostButton == PostButtonSystem.Wonder) { MainSectionButton.WeightSum = 4; SecondReactionLinearLayout.Visibility = ViewStates.Visible; SecondReactionButton.SetCompoundDrawablesWithIntrinsicBounds(Resource.Drawable.icon_post_wonder_vector, 0, 0, 0); SecondReactionButton.Text = Application.Context.GetText(Resource.String.Btn_Wonder); } else if (AppSettings.PostButton == PostButtonSystem.DisLike) { MainSectionButton.WeightSum = 4; SecondReactionLinearLayout.Visibility = ViewStates.Visible; SecondReactionButton.SetCompoundDrawablesWithIntrinsicBounds(Resource.Drawable.ic_action_dislike, 0, 0, 0); SecondReactionButton.Text = Application.Context.GetText(Resource.String.Btn_Dislike); } } LikeButton.SetTextColor(Color.White); //if (LikeButton?.GetCurrentReaction()?.GetReactType() == ReactConstants.Default) //{ // LikeButton.CompoundDrawableTintList = ColorStateList.ValueOf(Color.White); //} YouTubePlayerView youTubeView = new YouTubePlayerView(this); var youtubeView = FindViewById <FrameLayout>(Resource.Id.root); youtubeView.RemoveAllViews(); youtubeView.AddView(youTubeView); youTubeView.Initialize(AppSettings.YoutubeKey, this); } catch (Exception e) { Methods.DisplayReportResultTrack(e); } }
protected override void OnCreate(Bundle bundle) { base.OnCreate (bundle); SetContentView (Resource.Layout.FullScreen); baseLayout = FindViewById<LinearLayout>(Resource.Id.layout); playerView = FindViewById<YouTubePlayerView>(Resource.Id.player); fullscreenButton = FindViewById<Button>(Resource.Id.fullscreen_button); checkbox = FindViewById<CompoundButton>(Resource.Id.landscape_fullscreen_checkbox); otherViews = FindViewById<View>(Resource.Id.other_views); checkbox.CheckedChange += (sender, e) => { int controlFlags = player.FullscreenControlFlags; if (e.IsChecked) { // If you use the FULLSCREEN_FLAG_ALWAYS_FULLSCREEN_IN_LANDSCAPE, your activity's normal UI // should never be laid out in landscape mode (since the video will be fullscreen whenever the // activity is in landscape orientation). Therefore you should set the activity's requested // orientation to portrait. Typically you would do this in your AndroidManifest.xml, we do it // programmatically here since this activity demos fullscreen behavior both with and without // this flag). RequestedOrientation = PORTRAIT_ORIENTATION; controlFlags |= YouTubePlayer.FullscreenFlagAlwaysFullscreenInLandscape; } else { RequestedOrientation = ScreenOrientation.Sensor; controlFlags &= ~YouTubePlayer.FullscreenFlagAlwaysFullscreenInLandscape; } player.FullscreenControlFlags = controlFlags; }; fullscreenButton.Click += (sender, e) => OnFullscreen(!fullscreen); playerView.Initialize(DeveloperKey.Key, this); DoLayout(); }