public void OnSurfaceTextureAvailable(SurfaceTexture surface, int width, int height)
        {
            nn_surface = new Surface (surface);

            RelativeLayout.LayoutParams l;
            DisplayMetrics metrics = new DisplayMetrics();
            nn_activity.WindowManager.DefaultDisplay.GetMetrics(metrics);
            l = new RelativeLayout.LayoutParams(metrics.HeightPixels, metrics.WidthPixels);
            l.AddRule(LayoutRules.CenterInParent);
            float scale = (metrics.HeightPixels * 1.0f) / (metrics.WidthPixels * 1.0f);
            textureview.ScaleX = scale;
            textureview.LayoutParameters=l;

            try {
                nn_mediaplayer= new MediaPlayer();
                //String uriPath = "android.resource://"+nn_activity.PackageName+"/raw/Tap5050_About";
                nn_mediaplayer.SetDataSource(nn_activity,global::Android.Net.Uri.Parse("android.resource://"+nn_activity.PackageName +"/"+ Resource.Raw.Tap5050_About));
                nn_mediaplayer.SetSurface(nn_surface);
                nn_mediaplayer.Prepare();
                nn_mediaplayer.Prepared+= (object sender, EventArgs e) => {
                    (sender as MediaPlayer).Start ();
                };
                nn_mediaplayer.Completion+= (object sender, EventArgs e) => {
                    (sender as MediaPlayer).SeekTo (0);
                    (sender as MediaPlayer).Pause ();
                };

            }catch(Exception e){
                Toast.MakeText (nn_activity,"Sorry,Can not play the video",ToastLength.Long).Show();
            }
        }
        public bool OnSurfaceTextureDestroyed(Android.Graphics.SurfaceTexture surface)
        {
            _camera.StopPreview();
            _camera.Release();

            return(true);
        }
示例#3
0
        public async void OnSurfaceTextureUpdated(Android.Graphics.SurfaceTexture surface)
        {
            if (!skippedFirstFrame)
            {
                skippedFirstFrame = true;
                return;
            }
            if (processing)
            {
                return;
            }


            processing = true;
            Bitmap       bitmap           = _textureView.Bitmap;
            MemoryStream videoFrameStream = new MemoryStream();
            await bitmap.CompressAsync(Bitmap.CompressFormat.Jpeg, 100, videoFrameStream);

            videoFrameStream.Seek(0, SeekOrigin.Begin);
            await callbacks.Detect(videoFrameStream);

            await Task.Run(async() =>
            {
                await Task.Delay(100);
                videoFrameStream.Dispose();
                processing = false;
            });
        }
		private void PlayVideo(SurfaceTexture surfaceTexture)
		{
			DoCleanUp();
			try
			{

				path = "http://qthttp.apple.com.edgesuite.net/1010qwoeiuryfg/sl.m3u8";
				if (path == "")
				{
					// Tell the user to provide a media file URL.
					Toast.MakeText(this, "Please edit MediaPlayerDemo_setSurface Activity, " + "and set the path variable to your media file path." + " Your media file must be stored on sdcard.", ToastLength.Long).Show();
					return;
				}
				// Create a new media player and set the listeners
				mMediaPlayer = new MediaPlayer(this, true);
				mMediaPlayer.SetDataSource(path);
				if (surf == null)
				{
					surf = new Surface (surfaceTexture);
				}
				mMediaPlayer.SetSurface(surf);
				mMediaPlayer.PrepareAsync();
				mMediaPlayer.SetOnBufferingUpdateListener(this);
				mMediaPlayer.SetOnCompletionListener(this);
				mMediaPlayer.SetOnPreparedListener(this);
				VolumeControlStream = Stream.Music;

			}
			catch (Exception e)
			{
				Log.Error(TAG, "error: " + e.Message, e);
			}
		}
 public bool OnSurfaceTextureDestroyed(Android.Graphics.SurfaceTexture surface)
 {
     if (camera != null)
     {
         StopCamera();
     }
     return(true);
 }
        /// <summary>
        /// Starts the basic variables needed for the preview to start and then calls the concrete implementation
        /// </summary>
        /// <param name="surface"> Surface where the preview will be shown </param>
        /// <param name="width"> Width of the preview </param>
        /// <param name="height"> Height of the preview </param>
        internal void StartPreview(SurfaceTexture surface, int width, int height)
        {
            _width = width;
            _height = height;
            _surface = surface;

            StartPreview();
        }
示例#7
0
		public void OnSurfaceTextureAvailable (SurfaceTexture surface, int width, int height)
		{
			camera = global::Android.Hardware.Camera.Open ((int) cameraType);
			textureView.LayoutParameters = new FrameLayout.LayoutParams (width, height);
			surfaceTexture = surface;

			camera.SetPreviewTexture (surface);
			PrepareAndStartCamera ();
		}
 public bool OnSurfaceTextureDestroyed(SurfaceTexture surface)
 {
     if (_camera != null)
     {
         _camera.StopPreview();
         _camera.Release();
         _camera = null;
     }
     return true;
 }
示例#9
0
        // SurfaceViewが更新された時に呼び出される
        public void OnSurfaceTextureUpdated(Android.Graphics.SurfaceTexture surface)
        {
            if (NowOriantation == DetectScreenOrientation())
            {
                return;
            }

            NowOriantation = DetectScreenOrientation();
            SetScreenOrientation();
        }
示例#10
0
        public bool OnSurfaceTextureDestroyed(Android.Graphics.SurfaceTexture surface)
        {
            isDestroy = true;

            Thread.Sleep(1000);

            StopCamera();
            audiomgr.Clear();


            return(true);
        }
示例#11
0
        public override void Dispose()
        {
            if (Camera != null)
            {
                Stop();
                Camera.Release();
                Camera.Dispose();
                Camera = null;
            }

            if (Texture != null)
            {
                Texture.Release();
                Texture.Dispose();
                Texture = null;
            }
        }
示例#12
0
 //Camera stuff
 public void OnSurfaceTextureAvailable(Android.Graphics.SurfaceTexture surface, int w, int h)
 {
     if (ContextCompat.CheckSelfPermission(this, Manifest.Permission.Camera) == (int)Permission.Granted)
     {
         camera = Android.Hardware.Camera.Open();
         cameraSurfaceView.LayoutParameters = new RelativeLayout.LayoutParams(w, h);
         try
         {
             camera.SetPreviewTexture(surface);
             camera.SetDisplayOrientation(90);
             camera.StartPreview();
         }
         catch (Java.IO.IOException ex)
         {
             Console.WriteLine(ex.Message);
         }
     }
 }
        public void OnSurfaceTextureAvailable(Android.Graphics.SurfaceTexture surface, int w, int h)
        {
            _camera = Camera.Open();

            try
            {
                _camera.SetPreviewTexture(surface);

                _camera.SetDisplayOrientation(90);
                _camera.StartPreview();
            }
            catch (Java.IO.IOException ex)
            {
                Console.WriteLine(ex.Message);
            }
            Camera.Parameters tmp = _camera.GetParameters();
            tmp.FocusMode = Camera.Parameters.FocusModeContinuousPicture;
            _camera.SetParameters(tmp);
            DrawRectangle();
        }
示例#14
0
        public void OnSurfaceTextureAvailable(
            Android.Graphics.SurfaceTexture surface, int w, int h)
        {
            _camera = Android.Hardware.Camera.Open(1);


            _textureView.LayoutParameters =
                new FrameLayout.LayoutParams(w, h);

            try
            {
                _camera.SetDisplayOrientation(270);
                _camera.SetPreviewTexture(surface);
                _camera.StartPreview();
            }
            catch (Java.IO.IOException ex)
            {
                System.Console.WriteLine(ex.Message);
            }
        }
示例#15
0
        public void OnSurfaceTextureAvailable(Android.Graphics.SurfaceTexture surface, int w, int h)
        {
            bool landscape = isLandScapeMode();

            if (!landscape)
            {
                m_TextureView.LayoutParameters = new FrameLayout.LayoutParams(DisplayWidth, DisplayHeight);
            }
            else
            {
                m_TextureView.LayoutParameters = new FrameLayout.LayoutParams(DisplayHeight, DisplayWidth);
            }

            SetScreenOrientation();

            try {
                m_Camera.SetPreviewTexture(surface);
                m_Camera.StartPreview();
            } catch (Java.IO.IOException e) {
                System.Console.WriteLine(e.Message);
            }
        }
示例#16
0
 public void OnSurfaceTextureUpdated(Android.Graphics.SurfaceTexture surface)
 {
 }
		public bool OnSurfaceTextureDestroyed (SurfaceTexture surface)
		{
			return false;
		}
 public void OnSurfaceTextureUpdated(Android.Graphics.SurfaceTexture surface)
 {
     //Log.Error(TAG, "OnSurfaceTextureUpdated");  
     //Owner.PreviewFrame(surface);
 }
示例#19
0
		public void OnSurfaceTextureSizeChanged(SurfaceTexture surface, int width, int height)
		{
			PrepareAndStartCamera();
		}
 public void OnFrameAvailable(SurfaceTexture surfaceTexture)
 {
     mUpdateST = true;
     mView.RequestRender();
 }
 public bool OnSurfaceTextureDestroyed(Android.Graphics.SurfaceTexture surface)
 {
     Log.Error(TAG, "OnSurfaceTextureDestroyed!!!!!!!!!");
     return true;
 }
示例#22
0
 public bool OnSurfaceTextureDestroyed(SurfaceTexture surface)
 {
     if (_mp.IsPlaying)
         _mp.Stop();
     _mediaController.Dispose();
     _mp.Release();
     surface.Release();
     _wasRelease = true;
     return true;
 }
 public void OnSurfaceTextureSizeChanged(Android.Graphics.SurfaceTexture surface, int width, int height)
 {
     Fragment.ConfigureTransform(width, height);
     Fragment.StartPreview();
 }
 public void OnSurfaceTextureAvailable(Android.Graphics.SurfaceTexture surface, int width, int height)
 {
 }
示例#25
0
 public void OnSurfaceTextureAvailable(SurfaceTexture surface, int width, int height)
 {
     _mp.SetSurface(new Surface(surface));
 }
示例#26
0
 public void OnSurfaceTextureSizeChanged(SurfaceTexture surface_texture, int width, int height)
 {
     fragment.configureTransform (width, height);
 }
示例#27
0
 public bool OnSurfaceTextureDestroyed(SurfaceTexture surface_texture)
 {
     return true;
 }
示例#28
0
 public void OnSurfaceTextureAvailable(SurfaceTexture surface_texture,int width, int height)
 {
     fragment.openCamera (width,height);
 }
		public void OnSurfaceTextureUpdated (SurfaceTexture surface)
		{
			
		}
示例#30
0
 public bool OnSurfaceTextureDestroyed(Android.Graphics.SurfaceTexture surface)
 {
     return(true);
 }
示例#31
0
        private void StartCameraPreview(SurfaceTexture surface, int width, int height)
        {
            try
            {
                if (_camera != null)
                {
                    _camera.Release();
                    _camera.Reconnect();
                }
                else
                {
                    _camera = Camera.Open();
                    SetAutoFocus(_camera);
                }
            }
            catch (Exception ex)
            {
                return;
            }

            var cameraParameters = _camera.GetParameters();
            cameraParameters.SetRotation(90);
            //            var previewSize = GetOptimalPreviewSize(cameraParameters.SupportedPictureSizes, width, height);
            var previewSize = cameraParameters.PictureSize;
            cameraParameters.SetPreviewSize(previewSize.Width, previewSize.Height);
            _camera.SetParameters(cameraParameters);

            _textureView.LayoutParameters = new FrameLayout.LayoutParams(
                previewSize.Width, previewSize.Height, GravityFlags.Center);

            try
            {
                _camera.SetPreviewTexture(surface);
                _camera.StartPreview();
                _safeToTakePicture = true;
            }
            catch (IOException ex)
            {
                return;
            }

            _textureView.Rotation = 90.0f;
            _textureView.Alpha = 0.5f;
        }
		public void OnSurfaceTextureAvailable(SurfaceTexture surface_texture,int width, int height)
		{
			fragment.configureTransform (width, height);
			fragment.startPreview ();
		}
示例#33
0
        public bool OnSurfaceTextureDestroyed(SurfaceTexture surface)
        {
            if (nn_mediaplayer != null) {
                nn_mediaplayer.Release();
                nn_mediaplayer = null;
            }

            if (nn_surface != null) {
                nn_surface.Release();
                nn_surface= null;
            }
            return true;
        }
示例#34
0
 public void OnSurfaceTextureAvailable(SurfaceTexture surface, int width, int height)
 {
     StartCameraPreview(surface, width, height);
 }
 public void OnSurfaceTextureAvailable(SurfaceTexture surface, int width, int height) => _controller.StartPreview(surface, width, height);
示例#36
0
 public void OnSurfaceTextureAvailable(Android.Graphics.SurfaceTexture surface, int width, int height)
 {
     Fragment.StartPreview();
 }
 public void OnSurfaceTextureAvailable(Android.Graphics.SurfaceTexture surface, int width, int height)
 {
     Log.Error(TAG, "OpenCamera:" + width + "," + height);
     Owner.OpenCamera(width, height); 
 }
示例#38
0
        protected override void OnStart()
        {
            try
            {
                if (Camera == null)
                {
                    Camera = Hardware.Camera.Open(cameraIndex);
                }

                if (Texture == null)
                {
                    Texture = new Graphics.SurfaceTexture(0);
                }

                CameraPreviewCallback callback = new CameraPreviewCallback();
                callback.PreviewUpdated += Callback_PreviewUpdated;

                Hardware.Camera.Parameters  parameter   = Camera.GetParameters();
                List <Hardware.Camera.Size> supportSize = parameter.SupportedPreviewSizes.OrderByDescending(x => x.Width).ToList();
                foreach (Hardware.Camera.Size size in supportSize)
                {
                    CvLogger.Log(this, $"Camera Support Size: W{size.Width},H{size.Height}");

                    if (size.Width == 960 && size.Height == 720)
                    {
                        parameter.SetPreviewSize(size.Width, size.Height);
                        CvLogger.Log(this, $"SET Camera Size: W{size.Width},H{size.Height}");
                    }
                }

                string[] supportedFocusMode = parameter.SupportedFocusModes.ToArray();
                if (supportedFocusMode.Contains(Hardware.Camera.Parameters.FocusModeContinuousVideo))
                {
                    parameter.FocusMode = Hardware.Camera.Parameters.FocusModeContinuousVideo;
                }
                else if (supportedFocusMode.Contains(Hardware.Camera.Parameters.FocusModeContinuousPicture))
                {
                    parameter.FocusMode = Hardware.Camera.Parameters.FocusModeContinuousPicture;
                }
                parameter.ColorEffect = Hardware.Camera.Parameters.EffectNone;

                width      = parameter.PreviewSize.Width;
                height     = parameter.PreviewSize.Height;
                fps        = parameter.PreviewFrameRate;
                cameraType = parameter.PreviewFormat;

                CvLogger.Log(this, string.Format("Camera is creating W{0} H{1} FPS{2}", width, height, fps));
                Camera.SetParameters(parameter);

                Camera.SetPreviewCallback(callback);
                Camera.SetPreviewTexture(Texture);
                Camera.StartPreview();

                cameraOn = true;
            }
            catch (Exception ex)
            {
                CvLogger.Log(this, "Camera Init Failed.\n" + ex.ToString());

                Dispose();

                throw new ArgumentException("Camera Exception", ex);
            }
        }
 public void OnSurfaceTextureSizeChanged(Android.Graphics.SurfaceTexture surface, int width, int height)
 {
     Log.Error(TAG, "ConfigureTransform:" + width + "," + height);
     Owner.ConfigureTransform(width, height);
 }
 public bool OnSurfaceTextureDestroyed(SurfaceTexture surface)
 {
     _controller.StopCamera();
     return true;
 }
示例#41
0
		public bool OnSurfaceTextureDestroyed(SurfaceTexture surface)
		{
			camera.StopPreview();
			camera.Release();

			return true;
		}
示例#42
0
 public bool OnSurfaceTextureDestroyed(Android.Graphics.SurfaceTexture surface)
 {
     StopCamera();
     audiomgr.Clear();
     return(true);
 }
示例#43
0
 public void OnSurfaceTextureSizeChanged(Android.Graphics.SurfaceTexture surface, int width, int height)
 {
 }
 public void OnSurfaceTextureAvailable(graphics.SurfaceTexture surface, int width, int height)
 {
     owner.OpenCamera(width, height);
 }
		public void OnSurfaceTextureAvailable (SurfaceTexture surface, int width, int height)
		{
			PlayVideo(surface);
		}
        public void OnSurfaceCreated(Javax.Microedition.Khronos.Opengles.IGL10 gl, Javax.Microedition.Khronos.Egl.EGLConfig config)
        {
            // Set the background frame color
            GLES20.GlClearColor(0.0f, 0.0f, 0.0f, 1.0f);

            initTex();
            mSTexture = new SurfaceTexture(hTex[0]);
            mSTexture.SetOnFrameAvailableListener(this);

            mCamera = Android.Hardware.Camera.Open();
            try
            {
                mCamera.SetPreviewTexture(mSTexture);
            }
            catch (Exception ioe)
            {
            }

            GLES20.GlClearColor(0.0f, 0.0f, 0.0f, 1.0f);

            hProgram = loadShader(vss, fss);

            mTriangle = new Triangle();
        }
		public void OnSurfaceTextureSizeChanged (SurfaceTexture surface, int width, int height)
		{
			
		}
 public void OnSurfaceTextureUpdated(graphics.SurfaceTexture surface)
 {
 }
 public void OnSurfaceTextureSizeChanged(graphics.SurfaceTexture surface, int width, int height)
 {
     owner.ConfigureTransform(width, height);
 }
 public void OnSurfaceTextureSizeChanged(Android.Graphics.SurfaceTexture surface, int width, int height)
 {
     // camera takes care of this
 }