private void Init()
        {
            try
            {
                #region initialize
                statusTitle = Intent.GetStringExtra("title");
                videoPath   = Intent.GetStringExtra("videoUrl");
                ID          = Intent.GetIntExtra("videoId", -1);

                TextView     videoTitle                 = FindViewById <TextView>(Resource.Id.toolbar_title);
                VideoView    videoView                  = FindViewById <VideoView>(Resource.Id.full_screen_video);
                LinearLayout btnShareVideo              = FindViewById <LinearLayout>(Resource.Id.btn_share);
                LinearLayout btnShareVideoWithWhatsapp  = FindViewById <LinearLayout>(Resource.Id.btn_share_whatsapp);
                LinearLayout btnShareVideoWithInstagram = FindViewById <LinearLayout>(Resource.Id.btn_share_instagram);
                LinearLayout btnShareVideoWithFacebook  = FindViewById <LinearLayout>(Resource.Id.btn_share_facebook);
                LinearLayout btnDownloadVideo           = FindViewById <LinearLayout>(Resource.Id.btn_download);
                LinearLayout btnLikeVideo               = FindViewById <LinearLayout>(Resource.Id.btn_like);
                progress = FindViewById <ProgressBar>(Resource.Id.loading);
                imgLike  = FindViewById <ImageView>(Resource.Id.img_like);
                imgCover = FindViewById <ImageView>(Resource.Id.img_cover);

                videoTitle.Text = statusTitle;
                Glide.With(this).Load(Intent.GetStringExtra("coverUrl")).Into(imgCover);

                if (Preferences.ContainsKey("favorites", ID.ToString()))
                {
                    imgLike.SetImageResource(Resource.Drawable.heart);
                }

                videoView.SetVideoPath(Intent.GetStringExtra("videoUrl"));
                videoView.SetMediaController(new MediaController(this));
                videoView.SetOnPreparedListener(this);
                videoView.SetOnCompletionListener(this);
                videoView.SetOnErrorListener(this);

                LoadAds();

                int catId = Intent.GetIntExtra("catId", -1);
                SupportFragmentManager.BeginTransaction().Replace(Resource.Id.frameLayout, new VideosFragment(catId != -1 ? catId : 3)).Commit();
                #endregion

                #region Buttons Click Events
                btnShareVideoWithWhatsapp.Click  += BtnShareOnWhatsapp_Click;
                btnShareVideoWithInstagram.Click += BtnShareOnInstagram_Click;
                btnShareVideoWithFacebook.Click  += BtnShareOnFacebook_Click;
                btnShareVideo.Click    += BtnShareVideo_Click;
                btnDownloadVideo.Click += BtnDownloadVideo_Click;
                btnLikeVideo.Click     += BtnLikeVideo_Click;
                #endregion
            }
            catch
            {
                Toast.MakeText(this, GetString(Resource.String.error), ToastLength.Short).Show();
            }
        }
Exemplo n.º 2
0
        protected override void OnElementChanged(ElementChangedEventArgs <VideoPlayer> args)
        {
            base.OnElementChanged(args);

            if (args.NewElement != null)
            {
                if (Control == null)
                {
                    videoView = new VideoView(Context);

                    // set background to hide default initial black screen until video is prepared
                    UpdateVideoBackground();

                    // Wrap in relative layout to keep video aspect ratio
                    ARelativeLayout relativeLayout = new ARelativeLayout(Context);
                    relativeLayout.AddView(videoView);

                    ARelativeLayout.LayoutParams layoutParams =
                        new ARelativeLayout.LayoutParams(LayoutParams.MatchParent, LayoutParams.MatchParent);
                    layoutParams.AddRule(LayoutRules.CenterInParent);
                    videoView.LayoutParameters = layoutParams;

                    videoView.Prepared += OnVideoViewPrepared;
                    videoView.SetOnErrorListener(this);

                    SetNativeControl(relativeLayout);
                }

                UpdateSource();
                UpdatePlayback();

                args.NewElement.ResetToStartRequested += OnResetToStartRequested;
            }

            if (args.OldElement != null)
            {
                args.OldElement.ResetToStartRequested -= OnResetToStartRequested;
            }
        }
Exemplo n.º 3
0
                public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
                {
                    if (container == null)
                    {
                        // Currently in a layout without a container, so no reason to create our view.
                        return(null);
                    }

                    MediaController = new MediaController(Rock.Mobile.PlatformSpecific.Android.Core.Context);

                    RelativeLayout view = new RelativeLayout(Rock.Mobile.PlatformSpecific.Android.Core.Context);

                    view.LayoutParameters = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent);
                    view.SetBackgroundColor(Android.Graphics.Color.Black);
                    view.SetOnTouchListener(this);

                    VideoPlayer = new VideoView(Activity);
                    VideoPlayer.SetMediaController(MediaController);
                    VideoPlayer.LayoutParameters = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent);
                    ((RelativeLayout.LayoutParams)VideoPlayer.LayoutParameters).AddRule(LayoutRules.CenterInParent);

                    ((view as RelativeLayout)).AddView(VideoPlayer);

                    VideoPlayer.SetOnPreparedListener(this);
                    VideoPlayer.SetOnErrorListener(this);

                    ProgressBar = new ProgressBar(Rock.Mobile.PlatformSpecific.Android.Core.Context);
                    ProgressBar.Indeterminate = true;
                    ProgressBar.SetBackgroundColor(Rock.Mobile.UI.Util.GetUIColor(0));
                    ProgressBar.LayoutParameters = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent);
                    ((RelativeLayout.LayoutParams)ProgressBar.LayoutParameters).AddRule(LayoutRules.CenterInParent);
                    view.AddView(ProgressBar);
                    ProgressBar.BringToFront();

                    ResultView = new UIResultView(view, new System.Drawing.RectangleF(0, 0, NavbarFragment.GetFullDisplayWidth( ), this.Resources.DisplayMetrics.HeightPixels), delegate { TryPlayMedia( ); });

                    return(view);
                }
Exemplo n.º 4
0
                public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
                {
                    if (container == null)
                    {
                        // Currently in a layout without a container, so no reason to create our view.
                        return null;
                    }

                    MediaController = new MediaController( Rock.Mobile.PlatformSpecific.Android.Core.Context );

                    RelativeLayout view = new RelativeLayout( Rock.Mobile.PlatformSpecific.Android.Core.Context );
                    view.LayoutParameters = new RelativeLayout.LayoutParams( ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent );
                    view.SetBackgroundColor( Android.Graphics.Color.Black );
                    view.SetOnTouchListener( this );

                    VideoPlayer = new VideoView( Activity );
                    VideoPlayer.SetMediaController( MediaController );
                    VideoPlayer.LayoutParameters = new RelativeLayout.LayoutParams( ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent );
                    ( (RelativeLayout.LayoutParams)VideoPlayer.LayoutParameters ).AddRule( LayoutRules.CenterInParent );

                    ( ( view as RelativeLayout ) ).AddView( VideoPlayer );

                    VideoPlayer.SetOnPreparedListener( this );
                    VideoPlayer.SetOnErrorListener( this );

                    ProgressBar = new ProgressBar( Rock.Mobile.PlatformSpecific.Android.Core.Context );
                    ProgressBar.Indeterminate = true;
                    ProgressBar.SetBackgroundColor( Rock.Mobile.UI.Util.GetUIColor( 0 ) );
                    ProgressBar.LayoutParameters = new RelativeLayout.LayoutParams( ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent );
                    ( (RelativeLayout.LayoutParams)ProgressBar.LayoutParameters ).AddRule( LayoutRules.CenterInParent );
                    view.AddView( ProgressBar );
                    ProgressBar.BringToFront();

                    ResultView = new UIResultView( view, new System.Drawing.RectangleF( 0, 0, NavbarFragment.GetFullDisplayWidth( ), this.Resources.DisplayMetrics.HeightPixels ), delegate { TryPlayMedia( ); } );

                    return view;
                }
Exemplo n.º 5
0
        protected override void OnCreate
        (
            Bundle bundle
        )
        {
            base.OnCreate(bundle);

            _audioPath = Intent.GetStringExtra(AudioPathExtra);

            if (_audioPath == null)
            {
                throw new InvalidOperationException(string.Format("'{0}' extra string missing.",
                                                                  AudioPathExtra));
            }

            _orientationListener = new AndroidCameraActivity.DeviceOrientationEventListener
                                   (
                this,
                SensorDelay.Normal,
                OrientationChanged
                                   );

            _orientationListener.Enable();

            SetContentView(Resource.Layout.PlayVideoLayout);

            _videoView = FindViewById <VideoView>(Resource.Id.PlayedVideo);

            _mediaController = new MediaController(this,
                                                   useFastForward: false);

            _mediaController.SetAnchorView(_videoView);
            _videoView.SetMediaController(_mediaController);

            _videoView.SetOnPreparedListener
            (
                new VideoPreparedListener
                (
                    () =>
            {
                _videoView.SeekTo(1);
                _mediaController.Show();
            }
                )
            );

            _videoView.SetOnCompletionListener
            (
                new VideoCompletionListener
                (
                    () => _mediaController.Show()
                )
            );

            _videoView.SetOnErrorListener
            (
                new VideoErrorListener
                (
                    this,
                    _audioPath,
                    getString: (resource) => { return(GetString(resource)); }
                )
            );

            //_imageView.Touch -= TouchImage;
            //_imageView.Touch += TouchImage;

            /*_videoView.Post // wait with image loading until view fully initialised
             * (
             * () => PlayVideoAsync()
             * );*/

            _videoView.SetVideoPath(_audioPath);
        }