Exemplo n.º 1
0
        public void SurfaceDestroyed(ISurfaceHolder holder)
        {
            if (aNativeWindow != IntPtr.Zero)
                NativeMethods.ANativeWindow_release (aNativeWindow);

            aNativeWindow = IntPtr.Zero;
        }
Exemplo n.º 2
0
		public void SurfaceChanged (ISurfaceHolder holder, Android.Graphics.Format format, int w, int h)
		{
			// If your preview can change or rotate, take care of those events here.
			// Make sure to stop the preview before resizing or reformatting it.

			if (holder.Surface == null) {
				// preview surface does not exist
				CommonSampleLibrary.Log.Debug (TAG, "Preview surface does not exist");
				return;
			}

			// stop preview before making changes
			try {
				camera.StopPreview ();
				CommonSampleLibrary.Log.Debug (TAG, "Preview stopped.");
			} catch (Exception e) {
				// ignore: tried to stop a non-existent preview
				CommonSampleLibrary.Log.Debug(TAG, "Error starting camera preview: " + e.Message);
			}

			int orientation = CalculatePreviewOrientation (cameraInfo, displayOrientation);
			camera.SetDisplayOrientation (orientation);

			try {
				camera.SetPreviewDisplay (holder);
				camera.StartPreview ();
				CommonSampleLibrary.Log.Debug (TAG, "Camera preview started.");
			} catch (Exception e) {
				CommonSampleLibrary.Log.Debug (TAG, "Error starting camera preview: " + e.Message);
			}
		}
Exemplo n.º 3
0
 public DrawThread(ISurfaceHolder holder, PointVector screenCenter, Player player)
 {
     mHolder = holder;
     mPlayer = player;
     mScreenCenter = screenCenter;
     UpdateInterval = 1000 / 60;
 }
        void ISurfaceHolderCallback.SurfaceChanged(ISurfaceHolder holder, Android.Graphics.Format format, int width, int height)
        {
            if ((int)Android.OS.Build.VERSION.SdkInt >= 19)
            {
                if (!_isSurfaceChanged)
                {
                    _isSurfaceChanged = true;
                    _prevSurfaceWidth = width;
                    _prevSurfaceHeight = height;
                }
                else
                {
                    // Forcing reinitialization of the view if SurfaceChanged() is called more than once to fix shifted drawing on KitKat.
                    // See https://github.com/mono/MonoGame/issues/2492.
                    if (!ScreenReceiver.ScreenLocked && Game.Instance.Platform.IsActive &&
                        (_prevSurfaceWidth != width || _prevSurfaceHeight != height))
                    {
                        _prevSurfaceWidth = width;
                        _prevSurfaceHeight = height;

                        base.SurfaceDestroyed(holder);
                        base.SurfaceCreated(holder);
                    }
                }
            }

            SurfaceChanged(holder, format, width, height);
            Android.Util.Log.Debug("MonoGame", "MonoGameAndroidGameView.SurfaceChanged: format = " + format + ", width = " + width + ", height = " + height);

            if (_game.GraphicsDevice != null)
                _game.graphicsDeviceManager.ResetClientBounds();
        }
Exemplo n.º 5
0
        public void SurfaceChanged(ISurfaceHolder holder, [GeneratedEnum] Android.Graphics.Format format, int width, int height)
        {
            if (surfaceHolder.Surface == null) return;

            try
            {
                camera.StopPreview();
            }
            catch (Exception)
            {
                // ignored
            }

            try
            {
                camera.SetDisplayOrientation(90);
                camera.SetPreviewDisplay(surfaceHolder);
                camera.SetPreviewCallback(previewCallback);
                camera.StartPreview();

            }
            catch (Exception e)
            {
                Log.Debug("Cub.Xdroid.zbar", $"SurfaceChanged: error {e}");
            }

        }
Exemplo n.º 6
0
            public override void OnCreate(ISurfaceHolder surfaceHolder)
            {
                base.OnCreate (surfaceHolder);

                // By default we don't get touch events, so enable them.
                SetTouchEventsEnabled (true);
            }
        public void SurfaceCreated(ISurfaceHolder holder)
        {
            var outputFile = System.IO.Path.Combine(Android.OS.Environment.ExternalStorageDirectory.ToString(),
                                                    "myvideooutputfile.mp4");
            if (!recording)
            {
                mediaRecorder = new MediaRecorder();
                //correctCamera();
                //if (camera != null)
                //    mediaRecorder.SetCamera(camera);

                mediaRecorder.SetAudioSource(AudioSource.Mic);
                mediaRecorder.SetVideoSource(VideoSource.Camera);
                mediaRecorder.SetOutputFormat(OutputFormat.ThreeGpp);
                mediaRecorder.SetAudioEncoder(AudioEncoder.Aac);
                mediaRecorder.SetVideoEncoder(VideoEncoder.Mpeg4Sp);

                if (System.IO.File.Exists(outputFile))
                    System.IO.File.Delete(outputFile);
                System.IO.File.Create(outputFile);

                CamcorderProfile camProf = CamcorderProfile.Get(CamcorderQuality.Low);
                fps = camProf.VideoFrameRate;

                mediaRecorder.SetOutputFile(outputFile);
                mediaRecorder.SetPreviewDisplay(holder.Surface);
                mediaRecorder.Prepare();
            } else
            {
                mediaPlayer.SetDisplay(holder);
                mediaPlayer.SetDataSource(outputFile);
                mediaPlayer.Prepared += new EventHandler(mediaPlayer_Prepared);
                mediaPlayer.PrepareAsync();
            }
        }
Exemplo n.º 8
0
 public void SurfaceCreated(ISurfaceHolder holder)
 {
     mediaPlayer.SetDisplay(holder);
     mediaPlayer.SetDataSource(filename);
     mediaPlayer.Prepared += new EventHandler(mediaPlayer_Prepared);
     mediaPlayer.PrepareAsync();
 }
Exemplo n.º 9
0
        public MySurfaceView(Context context, IAttributeSet attr)
            : base(context, attr)
        {
            this.context = context;

            surfaceHolder = Holder;
            surfaceHolder.AddCallback(this);
        }
Exemplo n.º 10
0
 /// <summary>
 /// Default ctor
 /// </summary>
 public CameraPreview(Context context, Camera camera)
     : base(context)
 {
     this.camera = camera;
     surfaceHolder = GetHolder();
     surfaceHolder.AddCallback(this);
     surfaceHolder.SetType(ISurfaceHolderConstants.SURFACE_TYPE_PUSH_BUFFERS);
 }
Exemplo n.º 11
0
 public void SurfaceCreated(ISurfaceHolder holder)
 {
     Log.Info("PERSPEX", "Surface Created");
     _renderTarget =
         PerspexLocator.Current.GetService<IPlatformRenderInterface>()
             .CreateRenderer(new PlatformHandle(holder.Surface.Handle, "Surface"));
     Draw();
 }
        void Init ()
        {
            this.surfaceHolder = Holder;
            this.surfaceHolder.AddCallback (this);
            this.surfaceHolder.SetType (SurfaceType.PushBuffers);

            this.tokenSource = new CancellationTokenSource ();
        }
Exemplo n.º 13
0
        public void SurfaceCreated(ISurfaceHolder holder)
        {
            this.holder = holder;

            var canvas = holder.LockCanvas();
            canvas.DrawColor(Android.Graphics.Color.Aquamarine);
            holder.UnlockCanvasAndPost(canvas);
        }
        public AndroidFastRenderView(AndroidGame game, Bitmap framebuffer)
            : base(game)
        {
            this.game = game;
            this.framebuffer = framebuffer;
            this.holder = GetHolder();

        }
Exemplo n.º 15
0
        void AcquireNativeWindow(ISurfaceHolder holder)
        {
            if (aNativeWindow != IntPtr.Zero)
                NativeMethods.ANativeWindow_release (aNativeWindow);

            aNativeWindow = NativeMethods.ANativeWindow_fromSurface (JniEnvironment.EnvironmentPointer, Holder.Surface.Handle);
            NativeWindowAcquired ();
        }
Exemplo n.º 16
0
 public void SurfaceDestroyed(ISurfaceHolder holder)
 {
     if (!isPhotoTaken)
     {
         camera.StopPreview();
         camera.Release();
         previewing = false;
     }
 }
Exemplo n.º 17
0
 public void SurfaceCreated (ISurfaceHolder holder)
 {
     if (camera == null) {
         this.camera = Android.Hardware.Camera.Open ();
         this.camera.SetPreviewDisplay (holder);
         this.camera.SetPreviewCallback (this);
         this.camera.StartPreview ();
     }
 }
Exemplo n.º 18
0
 public Preview(Context context)
     : base(context)
 {
     // Install a SurfaceHolder.Callback so we get notified when the
     // underlying surface is created and destroyed.
     surface_holder = Holder;
     surface_holder.AddCallback (this);
     surface_holder.SetType (SurfaceType.PushBuffers);
 }
Exemplo n.º 19
0
 public CameraController(SurfaceView surfaceView, CameraEventsListener cameraEventListener,
     MobileBarcodeScanningOptions scanningOptions)
 {
     _context = surfaceView.Context;
     _holder = surfaceView.Holder;
     _surfaceView = surfaceView;
     _cameraEventListener = cameraEventListener;
     _scanningOptions = scanningOptions;
 }
Exemplo n.º 20
0
        public void SurfaceChanged (ISurfaceHolder holder, Format format, int wx, int hx)
        {
            tcsSurfaceReady.TrySetResult (null);

            if (wasStarted) {
                SetupCamera ().ContinueWith (t => {
                    MobileBarcodeScanner.LogError ("SetupCamera Failed: {0}", t.Exception);
                }, TaskContinuationOptions.OnlyOnFaulted);
            }
        }
		public void SurfaceCreated (ISurfaceHolder holder)
		{
			try {
				if (Preview != null) {
					Preview.SetPreviewDisplay (holder);
				}
			} catch (Exception ex) {
				System.Diagnostics.Debug.WriteLine (@"			ERROR: ", ex.Message);
			}
		}
        void Init ()
        {
            CheckPermissions ();

            this.surface_holder = Holder;
            this.surface_holder.AddCallback (this);
            this.surface_holder.SetType (SurfaceType.PushBuffers);

            this.tokenSource = new System.Threading.CancellationTokenSource();
        }
Exemplo n.º 23
0
		public void SurfaceCreated (ISurfaceHolder holder)
		{
			// The Surface has been created, now tell the camera where to draw the preview.
			try {
				camera.SetPreviewDisplay (holder);
				camera.StartPreview ();
				CommonSampleLibrary.Log.Debug (TAG, "Camera preview started.");
			} catch (Exception e) {
				Log.Debug (TAG, "Error setting camera preview: " + e.Message);
			}
		}
	    protected ZXingSurfaceView(IntPtr javaReference, JniHandleOwnership transfer) 
            : base(javaReference, transfer) 
        {
            lastPreviewAnalysis = DateTime.Now.AddMilliseconds(options.InitialDelayBeforeAnalyzingFrames);

            this.surface_holder = Holder;
            this.surface_holder.AddCallback(this);
            this.surface_holder.SetType(SurfaceType.PushBuffers);

            this.tokenSource = new System.Threading.CancellationTokenSource();
	    }
Exemplo n.º 25
0
        public void SurfaceChanged(ISurfaceHolder holder, Android.Graphics.Format format, int width, int height)
        {
            var measuredWidth = View.MeasureSpec.MakeMeasureSpec(width, MeasureSpecMode.Exactly);
            var measuredHeight = View.MeasureSpec.MakeMeasureSpec(height, MeasureSpecMode.Exactly);

            _countDownView.Measure(measuredWidth, measuredHeight);
            _countDownView.Layout(0, 0, _countDownView.MeasuredWidth, _countDownView.MeasuredHeight);

            _chronometerView.Measure(measuredWidth, measuredHeight);
            _chronometerView.Layout(0, 0, _chronometerView.MeasuredWidth, _chronometerView.MeasuredHeight);
        }
Exemplo n.º 26
0
 public void SurfaceCreated(ISurfaceHolder holder)
 {
     try
     {
         camera.SetPreviewDisplay(surfaceHolder);
         camera.StartPreview();
     }
     catch 
     {
         // Ignore for now
     }
 }
Exemplo n.º 27
0
        void ISurfaceHolderCallback.SurfaceChanged(ISurfaceHolder holder, Format format, int width, int height)
        {
            var newSize = new Size(width, height);
            if (newSize != ClientSize)
            {
                MaxClientSize = newSize;
                ClientSize = newSize;
                Resized?.Invoke(ClientSize);
            }

            base.SurfaceChanged(holder, format, width, height);
        }
Exemplo n.º 28
0
      public CameraPreview(Context context, Camera.IPreviewCallback previewCallback, bool cameraPreviewCallbackWithBuffer)
         : base(context)
      {
         _cameraPreviewCallbackWithBuffer = cameraPreviewCallbackWithBuffer;

         // Install a SurfaceHolder.Callback so we get notified when the
         // underlying surface is created and destroyed.
         _surfaceHolder = Holder;
         _surfaceHolder.AddCallback(this);

         _cameraPreviewCallback = previewCallback;
      }
Exemplo n.º 29
0
 public void SurfaceChanged(ISurfaceHolder holder, [GeneratedEnum] Format format, int width, int height)
 {
     if (previewing)
     {
         camera.StopPreview();
         previewing = false;
     }
     if (camera != null)
     {
         startCamera();
     }
 }
		public CameraPreview (Context context)
			: base (context)
		{
			surfaceView = new SurfaceView (context);
			AddView (surfaceView);

			windowManager = Context.GetSystemService (Context.WindowService).JavaCast<IWindowManager> ();

			IsPreviewing = false;
			holder = surfaceView.Holder;
			holder.AddCallback (this);
		}
Exemplo n.º 31
0
 public void SurfaceDestroyed(ISurfaceHolder holder)
 {
     Element.IsEnabled = false;
 }
Exemplo n.º 32
0
 public void SurfaceChanged(ISurfaceHolder holder, [GeneratedEnum] Format format, int width, int height)
 {
     //nativeSurfaceInit(holder.Surface);
 }
Exemplo n.º 33
0
 public void SurfaceChanged(ISurfaceHolder holder, [GeneratedEnum] Format format, int width, int height)
 {
     UpdateVideoStretch(_currentStretch);
 }
Exemplo n.º 34
0
 void ISurfaceHolderCallback.SurfaceCreated(ISurfaceHolder holder)
 {
     base.SurfaceCreated(holder);
     Android.Util.Log.Debug("MonoGame", "AndroidGameWindow.SurfaceCreated: surfaceFrame = " + holder.SurfaceFrame.ToString());
 }
Exemplo n.º 35
0
 public void surfaceDestroyed(ISurfaceHolder holder)
 {
     mRenderer.Dispose();
     base.SurfaceDestroyed(holder);
 }
Exemplo n.º 36
0
 public void surfaceCreated(ISurfaceHolder holder)
 {
     base.SurfaceCreated(holder);
 }
Exemplo n.º 37
0
 public void SurfaceDestroyed(ISurfaceHolder holder)
 {
     Camera?.StopPreview();
 }
Exemplo n.º 38
0
 public void SurfaceDestroyed(ISurfaceHolder holder)
 {
     //_camera.Unlock();
     //_camera.StopPreview();
     //_camera.Release();
 }
Exemplo n.º 39
0
 public void SurfaceDestroyed(ISurfaceHolder holder)
 {
     Console.WriteLine("SurfaceDestroyed");
 }
Exemplo n.º 40
0
 public virtual void SurfaceDestroyed(ISurfaceHolder holder)
 {
     FreeBitmap();
 }
Exemplo n.º 41
0
 public virtual void SurfaceCreated(ISurfaceHolder holder)
 {
     CreateBitmap(holder.SurfaceFrame.Width(), holder.SurfaceFrame.Height());
 }
Exemplo n.º 42
0
 public void SurfaceChanged(ISurfaceHolder holder, [GeneratedEnum] Format format, int width, int height)
 {
     SetCameraDisplayOrientation(_cameraId);
 }
Exemplo n.º 43
0
        // ISurfaceHolderCallback

        public virtual void SurfaceChanged(ISurfaceHolder holder, [GeneratedEnum] Format format, int width, int height)
        {
            CreateBitmap(width, height);
        }
Exemplo n.º 44
0
 public void surfaceChanged(ISurfaceHolder holder, Android.Graphics.Format format, int w, int h)
 {
     base.SurfaceChanged(holder, format, w, h);
 }
Exemplo n.º 45
0
 void ISurfaceHolderCallback.SurfaceDestroyed(ISurfaceHolder holder)
 {
     base.SurfaceDestroyed(holder);
     Android.Util.Log.Debug("MonoGame", "AndroidGameWindow.SurfaceDestroyed");
 }
Exemplo n.º 46
0
 public void SurfaceDestroyed(ISurfaceHolder holder)
 {
     // empty. Take care of releasing the Camera preview in your activity.
 }
 public void SurfaceDestroyed(ISurfaceHolder holder)
 {
     cameraSource.Stop();
 }
Exemplo n.º 48
0
 public void SurfaceChanged(ISurfaceHolder holder, [GeneratedEnum] Format format, int width, int height)
 {
 }
Exemplo n.º 49
0
 public void SurfaceDestroyed(ISurfaceHolder holder)
 {
     _player?.SetDisplay(null);
     _hasValidHolder = false;
 }
Exemplo n.º 50
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            try
            {
                base.OnCreate(savedInstanceState);
                SetContentView(Resource.Layout.VideoPlayer);
                Toolbar  toolbar       = (Toolbar)FindViewById(Resource.Id.toolbar);
                TextView toolbar_title = (TextView)FindViewById(Resource.Id.toolbar_title);
                pDialog = FindViewById <ProgressBar>(Resource.Id.progessbar);
                SetSupportActionBar(toolbar);

                Window.SetSoftInputMode(SoftInput.StateAlwaysHidden);

                if (Build.VERSION.SdkInt >= Android.OS.BuildVersionCodes.Lollipop)
                {
                    Window.AddFlags(WindowManagerFlags.DrawsSystemBarBackgrounds);
                    Window.SetStatusBarColor(new Android.Graphics.Color(Android.Support.V4.Content.ContextCompat.GetColor(this, Resource.Color.primaryDark)));
                }

                SupportActionBar.SetDisplayHomeAsUpEnabled(true);
                SupportActionBar.SetHomeButtonEnabled(true);

                var url          = Intent.GetStringExtra("VideoUrl") ?? null;
                var urlFromEvent = Intent.GetStringExtra("VideoUrlFromEvent") ?? null;
                urlFromTheme = Intent.GetStringExtra("VideoUrlFromTheme") ?? null;


                if (url != null && url != "")
                {
                    SupportActionBar.Title = "";
                    toolbar_title.Text     = "WeClip";
                    videoInfo     = JsonConvert.DeserializeObject <WeClipVideo>(url);
                    videoUri      = Android.Net.Uri.Parse(videoInfo.VideoFileUrl);
                    EventName     = videoInfo.EventName;
                    EventDate     = videoInfo.EventDate;
                    videoFileName = videoInfo.VideoFileName;
                    videoUrl      = videoInfo.VideoFileUrl;

                    shareTitle = videoInfo.EventName;
                    shareDate  = videoInfo.EventDate != null?videoInfo.EventDate.ToString() : "";

                    sharePath = videoInfo.VideoFileUrl;
                }
                else if (!string.IsNullOrEmpty(urlFromEvent))
                {
                    SupportActionBar.Title = "";
                    toolbar_title.Text     = "Event Video";
                    EventvideoInfo         = JsonConvert.DeserializeObject <EventFiles>(urlFromEvent);
                    videoUri      = Android.Net.Uri.Parse(EventvideoInfo.FileUrl);
                    EventName     = EventvideoInfo.EventName;
                    videoFileName = EventvideoInfo.FileName;
                    videoUrl      = EventvideoInfo.FileUrl;
                    shareTitle    = EventvideoInfo.EventName;
                    shareDate     = "";
                    sharePath     = EventvideoInfo.FileUrl;
                }

                else if (!string.IsNullOrEmpty(urlFromTheme))
                {
                    SupportActionBar.Title = "";
                    videoInfo          = JsonConvert.DeserializeObject <WeClipVideo>(urlFromTheme);
                    toolbar_title.Text = videoInfo.EventName;
                    videoUri           = Android.Net.Uri.Parse(videoInfo.VideoFileUrl);
                    videoFileName      = videoInfo.VideoFileName;
                    videoUrl           = videoInfo.VideoFileUrl;

                    shareTitle = videoInfo.EventName;
                    shareDate  = videoInfo.EventDate != null?videoInfo.EventDate.ToString() : "";

                    sharePath = videoInfo.VideoFileUrl;
                }

                if (videoUri == null)
                {
                    AlertBox.Create("Alert", "Error in WeClip source.", this);
                    return;
                }
                if (getfileFromPath(videoFileName))
                {
                    videoUri = localFileUrl;
                }

                llVideoView   = FindViewById <LinearLayout>(Resource.Id.llVideoView);
                playerSurface = FindViewById <SurfaceView>(Resource.Id.playerSurface);

                vidHolder = playerSurface.Holder;
                vidHolder.AddCallback(this);

                pDialog.Visibility = ViewStates.Visible;

                mediaController = new Android.Widget.MediaController(this);
            }
            catch (System.Exception ex)
            {
            }
        }
Exemplo n.º 51
0
 public void SurfaceDestroyed(ISurfaceHolder holder)
 {
     //nativeSurfaceFinalize();
 }
Exemplo n.º 52
0
 public void SurfaceChanged(ISurfaceHolder holder, int format, int width, int height)
 {
     thread.SetSurfaceSize(width, height);
 }
Exemplo n.º 53
0
 public void SurfaceCreated(ISurfaceHolder holder)
 {
 }
Exemplo n.º 54
0
 public void SurfaceCreated(ISurfaceHolder holder)
 {
     hldr = holder;
 }
Exemplo n.º 55
0
 public void SurfaceDestroyed(ISurfaceHolder holder)
 {
     //Камеру закрывает Activity
 }
Exemplo n.º 56
0
 public void SurfaceDestroyed(ISurfaceHolder holder)
 {
 }
Exemplo n.º 57
0
 public async void SurfaceCreated(ISurfaceHolder holder)
 {
     // Nothing to do.
 }
Exemplo n.º 58
0
 public void SurfaceCreated(ISurfaceHolder holder)
 {
     Console.WriteLine("SurfaceCreated");
     mediaPlayer.SetDisplay(holder);
 }
Exemplo n.º 59
0
 public void SurfaceChanged(ISurfaceHolder holder, Format format, int width, int height)
 {
     //throw new NotImplementedException();
 }
Exemplo n.º 60
0
 public void SurfaceChanged(ISurfaceHolder holder, Android.Graphics.Format format, int w, int h)
 {
     Console.WriteLine("SurfaceChanged");
 }