Java Code Examples for android.view.TextureView

The following are top voted examples for showing how to use android.view.TextureView. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: ZxingForAndroid   File: CameraPreview.java   Source Code and License 8 votes vote down vote up
@SuppressWarnings("deprecation")
@SuppressLint("NewAPI")
private void setupSurfaceView() {
    if(useTextureView && Build.VERSION.SDK_INT >= 14) {
        textureView = new TextureView(getContext());
        textureView.setSurfaceTextureListener(surfaceTextureListener());
        addView(textureView);
    } else {
        surfaceView = new SurfaceView(getContext());
        if (Build.VERSION.SDK_INT < 11) {
            surfaceView.getHolder().setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
        }
        surfaceView.getHolder().addCallback(surfaceCallback);
        addView(surfaceView);
    }
}
 
Example 2
Project: habpanelviewer   File: AbstractMotionDetector.java   Source Code and License 8 votes vote down vote up
@Override
public synchronized void updateFromPreferences(SharedPreferences prefs) {
    boolean newEnabled = prefs.getBoolean("pref_motion_detection_enabled", false);
    int newBoxes = Integer.parseInt(prefs.getString("pref_motion_detection_granularity", "20"));
    int newLeniency = Integer.parseInt(prefs.getString("pref_motion_detection_leniency", "20"));
    int newDeviceRotation = mContext.getWindowManager().getDefaultDisplay().getRotation();

    if (newEnabled) {
        mListener.updateFromPreferences(prefs);

        boolean changed = newBoxes != mBoxes || newLeniency != mLeniency || newDeviceRotation != mDeviceRotation;

        if (changed && mEnabled) {
            stopDetection();
        }

        if (ContextCompat.checkSelfPermission(mContext, Manifest.permission.CAMERA) == PackageManager.PERMISSION_GRANTED) {
            try {
                mBoxes = newBoxes;
                mLeniency = newLeniency;
                mDeviceRotation = newDeviceRotation;

                startDetection((TextureView) mContext.findViewById(R.id.previewView), newDeviceRotation * 90);
                mEnabled = true;
            } catch (CameraException e) {
                Log.e(TAG, "Could not enable MotionDetector", e);
            }
        } else {
            ActivityCompat.requestPermissions(mContext, new String[]{Manifest.permission.CAMERA},
                    MY_PERMISSIONS_MOTION_REQUEST_CAMERA);
        }
    } else if (mEnabled) {
        stopDetection();
        mEnabled = false;
    }
}
 
Example 3
Project: androidtv-sample   File: PlaybackOverlayFragment.java   Source Code and License 8 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mAudioManager = (AudioManager) getActivity().getSystemService(Context.AUDIO_SERVICE);

    // Initialize instance variables.
    TextureView textureView = (TextureView) getActivity().findViewById(R.id.texture_view);
    textureView.setSurfaceTextureListener(this);

    setBackgroundType(BACKGROUND_TYPE);

    // Set up listener.
    setOnItemViewClickedListener(new ItemViewClickedListener());
}
 
Example 4
Project: VideoRecorder-master   File: FFmpegPreviewActivity.java   Source Code and License 8 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.activity_ffmpeg_preview);

	cancelBtn = (Button) findViewById(R.id.play_cancel);
	cancelBtn.setOnClickListener(this);
	
	DisplayMetrics displaymetrics = new DisplayMetrics();
	getWindowManager().getDefaultDisplay().getMetrics(displaymetrics);
	surfaceView = (TextureView) findViewById(R.id.preview_video);
	
	RelativeLayout previewVideoParent = (RelativeLayout)findViewById(R.id.preview_video_parent);
	LayoutParams layoutParams = (LayoutParams) previewVideoParent
			.getLayoutParams();
	layoutParams.width = displaymetrics.widthPixels;
	layoutParams.height = displaymetrics.widthPixels;
	previewVideoParent.setLayoutParams(layoutParams);
	
	surfaceView.setSurfaceTextureListener(this);
	surfaceView.setOnClickListener(this);
	
	path = getIntent().getStringExtra("path");
	
	imagePlay = (ImageView) findViewById(R.id.previre_play);
	imagePlay.setOnClickListener(this);
	
	mediaPlayer = new MediaPlayer();
	mediaPlayer.setOnCompletionListener(this);
}
 
Example 5
Project: EditorImageAndText   File: VideoActivity.java   Source Code and License 8 votes vote down vote up
@Override
public void initViews() {
    surfaceView = (TextureView) findViewById(R.id.preview_video);
    image_back = (ImageView) findViewById(R.id.image_back);
    image_button = (ImageView) findViewById(R.id.image_button);
    progress_bar = (ProgressBar) findViewById(R.id.progress_bar);
}
 
Example 6
Project: react-native-webgl-view-shot   File: RNWebGLTextureView.java   Source Code and License 7 votes vote down vote up
private Bitmap captureView (View view) {
    int w = view.getWidth();
    int h = view.getHeight();
    if (w <= 0 || h <= 0) {
        throw new RuntimeException("Impossible to snapshot the view: view is invalid");
    }

    Bitmap bitmap = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888);
    Bitmap childBitmapBuffer;
    Canvas c = new Canvas(bitmap);
    view.draw(c);
    List<View> childrenList = getAllChildren(view);
    for (View child : childrenList) {
        if(child instanceof TextureView) {
            ((TextureView) child).setOpaque(false);
            childBitmapBuffer = ((TextureView) child).getBitmap(child.getWidth(), child.getHeight());
            c.drawBitmap(childBitmapBuffer, child.getLeft() + ((ViewGroup)child.getParent()).getLeft() +  child.getPaddingLeft(), child.getTop() + ((ViewGroup)child.getParent()).getTop() + child.getPaddingTop(), null);
        }
    }
    if (bitmap == null) {
        throw new RuntimeException("Impossible to snapshot the view");
    }
    return bitmap;
}
 
Example 7
Project: react-native-videoplayer   File: ExoPlayerView.java   Source Code and License 6 votes vote down vote up
/**
 * Set the {@link SimpleExoPlayer} to use. The {@link SimpleExoPlayer#setTextOutput} and
 * {@link SimpleExoPlayer#setVideoListener} method of the player will be called and previous
 * assignments are overridden.
 *
 * @param player The {@link SimpleExoPlayer} to use.
 */
public void setPlayer(SimpleExoPlayer player) {
    if (this.player == player) {
        return;
    }
    if (this.player != null) {
        this.player.setTextOutput(null);
        this.player.setVideoListener(null);
        this.player.removeListener(componentListener);
        this.player.setVideoSurface(null);
    }
    this.player = player;
    shutterView.setVisibility(VISIBLE);
    if (player != null) {
        if (surfaceView instanceof TextureView) {
            player.setVideoTextureView((TextureView) surfaceView);
        } else if (surfaceView instanceof SurfaceView) {
            player.setVideoSurfaceView((SurfaceView) surfaceView);
        }
        player.setVideoListener(componentListener);
        player.addListener(componentListener);
        player.setTextOutput(componentListener);
    }
}
 
Example 8
Project: PXLSRT   File: CameraViewTest.java   Source Code and License 6 votes vote down vote up
private static ViewAssertion showingPreview() {
    return new ViewAssertion() {
        @Override
        public void check(View view, NoMatchingViewException noViewFoundException) {
            if (android.os.Build.VERSION.SDK_INT < 14) {
                return;
            }
            CameraView cameraView = (CameraView) view;
            TextureView textureView = (TextureView) cameraView.findViewById(R.id.texture_view);
            Bitmap bitmap = textureView.getBitmap();
            int topLeft = bitmap.getPixel(0, 0);
            int center = bitmap.getPixel(bitmap.getWidth() / 2, bitmap.getHeight() / 2);
            int bottomRight = bitmap.getPixel(
                    bitmap.getWidth() - 1, bitmap.getHeight() - 1);
            assertFalse("Preview possibly blank: " + Integer.toHexString(topLeft),
                    topLeft == center && center == bottomRight);
        }
    };
}
 
Example 9
Project: grid-video-viewer   File: VideoGridFragment.java   Source Code and License 6 votes vote down vote up
/**
 * ピックアップ再生用のViewとMediaPlayerを初期化する
 */
private void initPickupPlayer() {
    mPlayer = new MediaPlayer();
    mPlayer.setOnPreparedListener(this);
    mPlayer.setOnCompletionListener(this);

    RelativeLayout.LayoutParams videoLayoutParams = new RelativeLayout.LayoutParams(
            LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    videoLayoutParams.addRule(RelativeLayout.CENTER_IN_PARENT);

    Context context = getActivity().getApplicationContext();

    mPickedVideoView = new TextureView(context);
    mPickedVideoView.setSurfaceTextureListener(this);
    mPickedVideoView.setVisibility(View.GONE);

    mRootView.addView(mPickedVideoView, videoLayoutParams);
}
 
Example 10
Project: grafika   File: PlayMovieActivity.java   Source Code and License 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_play_movie);

    mTextureView = (TextureView) findViewById(R.id.movie_texture_view);
    mTextureView.setSurfaceTextureListener(this);

    // Populate file-selection spinner.
    Spinner spinner = (Spinner) findViewById(R.id.playMovieFile_spinner);
    // Need to create one of these fancy ArrayAdapter thingies, and specify the generic layout
    // for the widget itself.
    mMovieFiles = MiscUtils.getFiles(getFilesDir(), "*.mp4");
    ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
            android.R.layout.simple_spinner_item, mMovieFiles);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    // Apply the adapter to the spinner.
    spinner.setAdapter(adapter);
    spinner.setOnItemSelectedListener(this);

    updateControls();
}
 
Example 11
Project: grafika   File: DoubleDecodeActivity.java   Source Code and License 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_double_decode);

    if (!sVideoRunning) {
        sBlob[0] = new VideoBlob((TextureView) findViewById(R.id.double1_texture_view),
                ContentManager.MOVIE_SLIDERS, 0);
        sBlob[1] = new VideoBlob((TextureView) findViewById(R.id.double2_texture_view),
                ContentManager.MOVIE_EIGHT_RECTS, 1);
        sVideoRunning = true;
    } else {
        sBlob[0].recreateView((TextureView) findViewById(R.id.double1_texture_view));
        sBlob[1].recreateView((TextureView) findViewById(R.id.double2_texture_view));
    }
}
 
Example 12
Project: habpanelviewer   File: MotionDetectorCamera2.java   Source Code and License 6 votes vote down vote up
private void configureTransform(TextureView textureView) {
    if (null == textureView || null == mPreviewSize || null == mActivity) {
        return;
    }
    int rotation = mActivity.getWindowManager().getDefaultDisplay().getRotation();
    Matrix matrix = new Matrix();
    RectF viewRect = new RectF(0, 0, textureView.getWidth(), textureView.getHeight());
    RectF bufferRect = new RectF(0, 0, mPreviewSize.y, mPreviewSize.x);
    float centerX = viewRect.centerX();
    float centerY = viewRect.centerY();
    if (Surface.ROTATION_90 == rotation || Surface.ROTATION_270 == rotation) {
        bufferRect.offset(centerX - bufferRect.centerX(), centerY - bufferRect.centerY());
        matrix.setRectToRect(viewRect, bufferRect, Matrix.ScaleToFit.FILL);
        float scale = Math.max(
                (float) textureView.getHeight() / mPreviewSize.y,
                (float) textureView.getWidth() / mPreviewSize.x);
        matrix.postScale(scale, scale, centerX, centerY);
    }
    matrix.postRotate(-90 * rotation, centerX, centerY);
    textureView.setTransform(matrix);
}
 
Example 13
Project: sdl_video_streaming_android_sample   File: InputSurface.java   Source Code and License 6 votes vote down vote up
/**
 * Creates instances of TextureRender and SurfaceTexture, and a Surface associated
 * with the SurfaceTexture.
 */
private void setup() {
	mTextureView = new TextureView(mContext);
    mTextureRender = new TextureRender();
    mTextureRender.surfaceCreated();
    // Even if we don't access the SurfaceTexture after the constructor returns, we
    // still need to keep a reference to it.  The Surface doesn't retain a reference
    // at the Java level, so if we don't either then the object can get GCed, which
    // causes the native finalizer to run.
    if (VERBOSE) Log.d(TAG, "textureID=" + mTextureRender.getTextureId());
    mSurfaceTexture = new SurfaceTexture(mTextureRender.getTextureId());
    mTextureView.setSurfaceTexture(mSurfaceTexture);
    
    task = new TimerTask() {
        public void run() {
          if (VERBOSE) Log.d(TAG, "new frame available");
          synchronized (mFrameSyncObject) {
              mFrameSyncObject.notifyAll();
          }
        }
    };
    timer = new Timer();
    timer.scheduleAtFixedRate(task, 25, 25);
}
 
Example 14
Project: KrGallery   File: CameraView.java   Source Code and License 6 votes vote down vote up
public CameraView(Context context, boolean frontface) {
    super(context, null);
    isFrontface = frontface;
    textureView = new TextureView(context);
    textureView.setSurfaceTextureListener(this);
    addView(textureView);
    focusAreaSize = AndroidUtilities.dp(96);
    outerPaint.setColor(0xffffffff);
    outerPaint.setStyle(Paint.Style.STROKE);
    outerPaint.setStrokeWidth(AndroidUtilities.dp(2));
    innerPaint.setColor(0x7fffffff);
}
 
Example 15
Project: aos-Video   File: FirstScreenPresentation.java   Source Code and License 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.floating_player);
    mFirstScreenSurfaceView = (TextureView)
            findViewById(R.id.gl_surface_view);
    mCallback.onFirstScreenPresentationCreated(findViewById(R.id.root));
}
 
Example 16
Project: aos-Video   File: SurfaceController.java   Source Code and License 6 votes vote down vote up
public SurfaceController(View rootView) {
    ViewGroup mLp = (ViewGroup)rootView;
 
    mEffectView =  (TextureView) mLp.findViewById(R.id.gl_surface_view);
    mSurfaceView =  (SurfaceView) mLp.findViewById(R.id.surface_view);
    if (mEffectEnable) {
        mView = mEffectView;
        mSurfaceView.setVisibility(View.GONE);
     } else {
         mView = mSurfaceView;
         mEffectView.setVisibility(View.GONE);
    }
}
 
Example 17
Project: buildAPKsSamples   File: FoldingLayoutActivity.java   Source Code and License 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_fold);

    mImageView = (ImageView)findViewById(R.id.image_view);
    mImageView.setPadding(ANTIALIAS_PADDING, ANTIALIAS_PADDING, ANTIALIAS_PADDING,
            ANTIALIAS_PADDING);
    mImageView.setScaleType(ImageView.ScaleType.FIT_XY);
    mImageView.setImageDrawable(getResources().getDrawable(R.drawable.image));

    mTextureView = new TextureView(this);
    mTextureView.setSurfaceTextureListener(mSurfaceTextureListener);

    mAnchorSeekBar = (SeekBar)findViewById(R.id.anchor_seek_bar);
    mFoldLayout = (FoldingLayout)findViewById(R.id.fold_view);
    mFoldLayout.setBackgroundColor(Color.BLACK);
    mFoldLayout.setFoldListener(mOnFoldListener);

    mTouchSlop = ViewConfiguration.get(this).getScaledTouchSlop();

    mAnchorSeekBar.setOnSeekBarChangeListener(mSeekBarChangeListener);

    mScrollGestureDetector = new GestureDetector(this, new ScrollGestureDetector());
    mItemSelectedListener = new ItemSelectedListener();

    mDefaultPaint = new Paint();
    mSepiaPaint = new Paint();

    ColorMatrix m1 = new ColorMatrix();
    ColorMatrix m2 = new ColorMatrix();
    m1.setSaturation(0);
    m2.setScale(1f, .95f, .82f, 1.0f);
    m1.setConcat(m2, m1);
    mSepiaPaint.setColorFilter(new ColorMatrixColorFilter(m1));
}
 
Example 18
Project: Croprotector   File: Shoot_fragment.java   Source Code and License 6 votes vote down vote up
private void findview(View v) {
    mTextureView = (TextureView) v.findViewById(R.id.tv_textview);
    mButton = (Button) v.findViewById(R.id.btn_takepic);
    mThumbnail = (ImageView) v.findViewById(R.id.iv_Thumbnail);
    mThumbnail.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Toast.makeText(getActivity(), "别戳了,那个页面还没写", Toast.LENGTH_SHORT).show();
        }
    });
}
 
Example 19
Project: okwallet   File: ScanActivity.java   Source Code and License 6 votes vote down vote up
@Override
public void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    vibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);

    setContentView(R.layout.scan_activity);
    scannerView = (ScannerView) findViewById(R.id.scan_activity_mask);
    previewView = (TextureView) findViewById(R.id.scan_activity_preview);
    previewView.setSurfaceTextureListener(this);

    cameraThread = new HandlerThread("cameraThread", Process.THREAD_PRIORITY_BACKGROUND);
    cameraThread.start();
    cameraHandler = new Handler(cameraThread.getLooper());

    if (ContextCompat.checkSelfPermission(this, Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED)
        ActivityCompat.requestPermissions(this, new String[] { Manifest.permission.CAMERA }, 0);
}
 
Example 20
Project: xbot_head   File: CameraActivity.java   Source Code and License 6 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_take_head_photo);

    linearLayout = (LinearLayout) findViewById(R.id.bottom_linear_layout);
    bt_ok = (Button) findViewById(R.id.id_bt_ok);
    bt_reCapture = (Button) findViewById(R.id.id_bt_again);
    bt_home = (Button) findViewById(R.id.id_bt_home);
    tv_shoot = (TextView) findViewById(R.id.id_tv_oval);
    iv_show = (ImageView) findViewById(R.id.id_iv_show_picture);
    mTextureView = (TextureView) findViewById(R.id.id_texture_view);

    initView();

    initCamera();

    initOnClickListener();
}
 
Example 21
Project: renderscript_examples   File: MainActivity.java   Source Code and License 6 votes vote down vote up
void resetRenderHolder(Point renderInSize) {
    TextureView textureView = (TextureView) findViewById(R.id.textureView);

    // These two functions are a simple hack to help TextureView behave like we want it to:
    // If we are on landscape mode, it will rotate accordingly. Otherwise, a badly stretched image would be shown.
    textureView.requestLayout();
    textureView.invalidate();

    // Scales down preview size by 2 times, for performance reasons.
    Point renderOutSize = new Point(Math.round(renderInSize.x * 0.5f), Math.round(renderInSize.y * 0.5f));

    // Instantiates a new custom compute class, passing information about input image size (camera preview)
    // and output size (render holder surface scaled size)
    rsCompute = new RSCompute(mRS, renderInSize, renderOutSize);

    // Sets TextureView to display output
    rsCompute.setRenderTextureView(textureView);
}
 
Example 22
Project: RoadLab-Pro   File: CustomMapView.java   Source Code and License 6 votes vote down vote up
private View searchAndFindDrawingView(ViewGroup group) {
    int childCount = group.getChildCount();
    for (int i = 0; i < childCount; i++) {
        View child = group.getChildAt(i);
        if (child instanceof ViewGroup) {
            View view = searchAndFindDrawingView((ViewGroup) child);

            if (view != null) {
                return view;
            }
        }

        if (child instanceof SurfaceView) {
            return child;
        }

        if (hasTextureViewSupport) { // if we have support for texture view
            if (child instanceof TextureView) {
                return child;
            }
        }
    }
    return null;
}
 
Example 23
Project: mimi-reader   File: VideoDialog.java   Source Code and License 6 votes vote down vote up
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);

    final ImageView closeButton = (ImageView) view.findViewById(R.id.close_vide_button);
    closeButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            dismiss();
        }
    });

    textureView = (TextureView) view.findViewById(R.id.video_surface);
    textureView.setSurfaceTextureListener(this);

}
 
Example 24
Project: mediacodec   File: PlayMovieActivity.java   Source Code and License 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_play_movie);

    mTextureView = (TextureView) findViewById(R.id.movie_texture_view);
    mTextureView.setSurfaceTextureListener(this);

    // Populate file-selection spinner.
    Spinner spinner = (Spinner) findViewById(R.id.playMovieFile_spinner);
    // Need to create one of these fancy ArrayAdapter thingies, and specify the generic layout
    // for the widget itself.
    mMovieFiles = MiscUtils.getFiles(getFilesDir(), "*.mp4");
    ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
            android.R.layout.simple_spinner_item, mMovieFiles);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    // Apply the adapter to the spinner.
    spinner.setAdapter(adapter);
    spinner.setOnItemSelectedListener(this);

    updateControls();
}
 
Example 25
Project: mediacodec   File: DoubleDecodeActivity.java   Source Code and License 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_double_decode);

    if (!sVideoRunning) {
        sBlob[0] = new VideoBlob((TextureView) findViewById(R.id.double1_texture_view),
                ContentManager.MOVIE_SLIDERS, 0);
        sBlob[1] = new VideoBlob((TextureView) findViewById(R.id.double2_texture_view),
                ContentManager.MOVIE_EIGHT_RECTS, 1);
        sVideoRunning = true;
    } else {
        sBlob[0].recreateView((TextureView) findViewById(R.id.double1_texture_view));
        sBlob[1].recreateView((TextureView) findViewById(R.id.double2_texture_view));
    }
}
 
Example 26
Project: luxunPro   File: MatrixManager.java   Source Code and License 6 votes vote down vote up
@SuppressWarnings("SuspiciousNameCombination")
public void rotate(@NonNull TextureView view, @IntRange(from = 0, to = 359) int rotation) {
    if (!ready()) {
        requestedRotation = rotation;
        requestedModificationView = new WeakReference<>(view);
        return;
    }

    boolean swapWidthHeight = ((rotation / QUARTER_ROTATION) % 2) == 1;
    boolean currentWidthHeightSwapped = ((currentRotation / QUARTER_ROTATION) % 2) == 1;

    //Makes sure the width and height are correctly swapped
    if (swapWidthHeight != currentWidthHeightSwapped) {
        int tempX = intrinsicVideoSize.x;
        intrinsicVideoSize.x = intrinsicVideoSize.y;
        intrinsicVideoSize.y = tempX;

        //We re-apply the scale to make sure it is correct
        scale(view, currentScaleType);
    }

    currentRotation = rotation;
    view.setRotation(rotation);
}
 
Example 27
Project: SimpleCamera   File: CameraViewTest.java   Source Code and License 6 votes vote down vote up
private static ViewAssertion showingPreview() {
    return new ViewAssertion() {
        @Override
        public void check(View view, NoMatchingViewException noViewFoundException) {
            if (android.os.Build.VERSION.SDK_INT < 14) {
                return;
            }
            CameraView cameraView = (CameraView) view;
            TextureView textureView = (TextureView) cameraView.findViewById(com.google.android.cameraview.test.R.id.texture_view);
            Bitmap bitmap = textureView.getBitmap();
            int topLeft = bitmap.getPixel(0, 0);
            int center = bitmap.getPixel(bitmap.getWidth() / 2, bitmap.getHeight() / 2);
            int bottomRight = bitmap.getPixel(
                    bitmap.getWidth() - 1, bitmap.getHeight() - 1);
            assertFalse("Preview possibly blank: " + Integer.toHexString(topLeft),
                    topLeft == center && center == bottomRight);
        }
    };
}
 
Example 28
Project: DragVideo   File: MainActivity.java   Source Code and License 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    mProgramListView = (ListView) findViewById(R.id.lv_program);
    mProgramListView.setAdapter(ArrayAdapter.createFromResource(this, R.array.program_list, android.R.layout.simple_list_item_1));
    mProgramListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            mProgramListView.setVisibility(View.GONE);
            playVideo();
        }
    });
    mVideoView = (TextureView) findViewById(R.id.video_view);
    mVideoView.setSurfaceTextureListener(this);
    mMediaPlayer = MediaPlayer.create(this,R.raw.test_4);
    mMediaPlayer.setOnPreparedListener(this);
    mDragVideoView = (DragVideoView) findViewById(R.id.drag_view);
    mDragVideoView.setCallback(this);
    mDetailInfoListView = (ListView) findViewById(R.id.lv_info);
    mDetailInfoListView.setAdapter(ArrayAdapter.createFromResource(this, R.array.info_list, android.R.layout.simple_list_item_1));
}
 
Example 29
Project: cameraview   File: CameraViewTest.java   Source Code and License 6 votes vote down vote up
private static ViewAssertion showingPreview() {
    return new ViewAssertion() {
        @Override
        public void check(View view, NoMatchingViewException noViewFoundException) {
            if (android.os.Build.VERSION.SDK_INT < 14) {
                return;
            }
            CameraView cameraView = (CameraView) view;
            TextureView textureView = (TextureView) cameraView.findViewById(R.id.texture_view);
            Bitmap bitmap = textureView.getBitmap();
            int topLeft = bitmap.getPixel(0, 0);
            int center = bitmap.getPixel(bitmap.getWidth() / 2, bitmap.getHeight() / 2);
            int bottomRight = bitmap.getPixel(
                    bitmap.getWidth() - 1, bitmap.getHeight() - 1);
            assertFalse("Preview possibly blank: " + Integer.toHexString(topLeft),
                    topLeft == center && center == bottomRight);
        }
    };
}
 
Example 30
Project: react-native-videoplayer   File: ExoPlayerView.java   Source Code and License 5 votes vote down vote up
public ExoPlayerView(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);

    boolean useTextureView = false;

    ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT);

    componentListener = new ComponentListener();

    FrameLayout.LayoutParams aspectRatioParams = new FrameLayout.LayoutParams(
            FrameLayout.LayoutParams.MATCH_PARENT,
            FrameLayout.LayoutParams.MATCH_PARENT);
    aspectRatioParams.gravity = Gravity.CENTER;
    layout = new AspectRatioFrameLayout(context);
    layout.setLayoutParams(aspectRatioParams);

    shutterView = new View(getContext());
    shutterView.setLayoutParams(params);
    shutterView.setBackgroundColor(ContextCompat.getColor(context, android.R.color.black));

    subtitleLayout = new SubtitleView(context);
    subtitleLayout.setLayoutParams(params);
    subtitleLayout.setUserDefaultStyle();
    subtitleLayout.setUserDefaultTextSize();

    View view = useTextureView ? new TextureView(context) : new SurfaceView(context);
    view.setLayoutParams(params);
    surfaceView = view;

    layout.addView(surfaceView, 0, params);
    layout.addView(shutterView, 1, params);
    layout.addView(subtitleLayout, 2, params);

    addViewInLayout(layout, 0, aspectRatioParams);
}
 
Example 31
Project: yjPlay   File: VideoPlayerView.java   Source Code and License 5 votes vote down vote up
@Override
public void showReplayView(int visibility) {
    if (playerView != null && playerView.getVideoSurfaceView() instanceof TextureView) {
        TextureView surfaceView = (TextureView) playerView.getVideoSurfaceView();
        showBottomView(VISIBLE, surfaceView.getBitmap());
    }
    showReplay(visibility);
}
 
Example 32
Project: yjPlay   File: SimpleExoPlayerView.java   Source Code and License 5 votes vote down vote up
/**
 * Set the {@link SimpleExoPlayer} to use.
 * <p>
 * To transition a {@link SimpleExoPlayer} from targeting one view to another, it's recommended to
 * use {@link #switchTargetView(SimpleExoPlayer, SimpleExoPlayerView, SimpleExoPlayerView)} rather
 * than this method. If you do wish to use this method directly, be sure to attach the player to
 * the new view <em>before</em> calling {@code setPlayer(null)} to detach it from the old one.
 * This ordering is significantly more efficient and may allow for more seamless transitions.
 *
 * @param player The {@link SimpleExoPlayer} to use.
 */
public void setPlayer(SimpleExoPlayer player) {
    if (this.player == player) {
        return;
    }
    if (this.player != null) {
        this.player.removeListener(componentListener);
        this.player.removeTextOutput(componentListener);
        this.player.removeVideoListener(componentListener);
        if (surfaceView instanceof TextureView) {
            this.player.clearVideoTextureView((TextureView) surfaceView);
        } else if (surfaceView instanceof SurfaceView) {
            this.player.clearVideoSurfaceView((SurfaceView) surfaceView);
        }
    }
    this.player = player;
    if (useController) {
        controller.setPlayer(player);
    }
    if (shutterView != null) {
        shutterView.setVisibility(VISIBLE);
    }
    if (player != null) {
        if (surfaceView instanceof TextureView) {
            player.setVideoTextureView((TextureView) surfaceView);
        } else if (surfaceView instanceof SurfaceView) {
            player.setVideoSurfaceView((SurfaceView) surfaceView);
        }
        player.addVideoListener(componentListener);
        player.addTextOutput(componentListener);
        player.addListener(componentListener);
        maybeShowController(false);
        updateForCurrentTrackSelections();
    } else {
        hideController();
        hideArtwork();
    }
}
 
Example 33
Project: TubiPlayer   File: TubiExoPlayerView.java   Source Code and License 5 votes vote down vote up
/**
     * Set the {@link SimpleExoPlayer} to use. The {@link SimpleExoPlayer#setTextOutput} and
     * {@link SimpleExoPlayer#setVideoListener} method of the player will be called and previous
     * assignments are overridden.
     * <p>
     * @param player The {@link SimpleExoPlayer} to use.
     */
    public void setPlayer(SimpleExoPlayer player, @NonNull TubiPlaybackInterface playbackInterface) {
        setPlaybackInterface(playbackInterface);
        if (this.player == player) {
            return;
        }
        if (this.player != null) {
            this.player.removeListener(componentListener);
            this.player.clearTextOutput(componentListener);
            this.player.clearVideoListener(componentListener);
            if (surfaceView instanceof TextureView) {
                this.player.clearVideoTextureView((TextureView) surfaceView);
            } else if (surfaceView instanceof SurfaceView) {
                this.player.clearVideoSurfaceView((SurfaceView) surfaceView);
            }
        }
        this.player = player;
        if (useController) {
            controller.setPlayer(player,this, playbackInterface);
        }
        if (shutterView != null) {
            shutterView.setVisibility(VISIBLE);
        }
        if (player != null) {
            if (surfaceView instanceof TextureView) {
                player.setVideoTextureView((TextureView) surfaceView);
            } else if (surfaceView instanceof SurfaceView) {
                player.setVideoSurfaceView((SurfaceView) surfaceView);
            }
            player.setVideoListener(componentListener);
            player.setTextOutput(componentListener);
            player.addListener(componentListener);
//            maybeShowController(false);
            updateForCurrentTrackSelections();
        } else {
            hideController();
            hideArtwork();
        }
    }
 
Example 34
Project: android-imaging-utils   File: CameraController.java   Source Code and License 5 votes vote down vote up
private void _startPreview(TextureView preview, PreviewSize size)
{
    if (mState == CameraState.Opened)
    {
        mState = CameraState.PreviewStarted;

        mCurrentPreviewSize = size;

        preview.setSurfaceTextureListener(this);

        synchronized (mCameraLock)
        {

            Camera.Parameters p = mCamera.getParameters();
            p.setPreviewSize(size.width, size.height);

            mCamera.setParameters(p);
        }

        mTargetTexture = preview;

        Log.d(ImagingUtils.TAG, "Camera preview is avalable: " + preview.isAvailable());

        if (preview.isAvailable())
        {
            onSurfaceTextureAvailable(mTargetTexture.getSurfaceTexture(), mTargetTexture.getWidth(), mTargetTexture.getHeight());
        }
    }

}
 
Example 35
Project: grid-video-viewer   File: DecoderSurface.java   Source Code and License 5 votes vote down vote up
/**
 * @param surfaceNumber 識別用番号
 * @param imageView ImageView
 */
DecoderSurface(int surfaceNumber, ImageView imageView, TextureView textureView) {
    this.mImageView = imageView;
    this.mTextureView = textureView;
    this.mSurfaceNumber = surfaceNumber;
    mManager = DecodeQueueManager.getInstance();
}
 
Example 36
Project: grafika   File: DoubleDecodeActivity.java   Source Code and License 5 votes vote down vote up
/**
 * Constructs the VideoBlob.
 *
 * @param view The TextureView object we want to draw into.
 * @param movieTag Which movie to play.
 * @param ordinal The blob's ordinal (only used for log messages).
 */
public VideoBlob(TextureView view, int movieTag, int ordinal) {
    LTAG = TAG + ordinal;
    Log.d(LTAG, "VideoBlob: tag=" + movieTag + " view=" + view);
    mMovieTag = movieTag;

    mCallback = new SpeedControlCallback();

    recreateView(view);
}
 
Example 37
Project: grafika   File: DoubleDecodeActivity.java   Source Code and License 5 votes vote down vote up
/**
 * Performs partial construction.  The VideoBlob is already created, but the Activity
 * was recreated, so we need to update our view.
 */
public void recreateView(TextureView view) {
    Log.d(LTAG, "recreateView: " + view);
    mTextureView = view;
    mTextureView.setSurfaceTextureListener(this);
    if (mSavedSurfaceTexture != null) {
        Log.d(LTAG, "using saved st=" + mSavedSurfaceTexture);
        view.setSurfaceTexture(mSavedSurfaceTexture);
    }
}
 
Example 38
Project: grafika   File: LiveCameraActivity.java   Source Code and License 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    mTextureView = new TextureView(this);
    mTextureView.setSurfaceTextureListener(this);

    setContentView(mTextureView);
}
 
Example 39
Project: grafika   File: TextureViewCanvasActivity.java   Source Code and License 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    Log.d(TAG, "onCreate");
    super.onCreate(savedInstanceState);

    // Start up the Renderer thread.  It'll sleep until the TextureView is ready.
    mRenderer = new Renderer();
    mRenderer.start();

    setContentView(R.layout.activity_texture_view_canvas);
    mTextureView = (TextureView) findViewById(R.id.canvasTextureView);
    mTextureView.setSurfaceTextureListener(mRenderer);
}
 
Example 40
Project: grafika   File: TextureViewGLActivity.java   Source Code and License 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    Log.d(TAG, "onCreate");
    super.onCreate(savedInstanceState);

    // Start up the Renderer thread.  It'll sleep until the TextureView is ready.
    mRenderer = new Renderer();
    mRenderer.start();

    setContentView(R.layout.activity_texture_view_gl);
    mTextureView = (TextureView) findViewById(R.id.glTextureView);
    mTextureView.setSurfaceTextureListener(mRenderer);
}
 
Example 41
Project: rtmp-rtsp-stream-client-java   File: Camera2Base.java   Source Code and License 5 votes vote down vote up
public Camera2Base(TextureView textureView, Context context) {
  this.textureView = textureView;
  this.context = context;
  cameraManager = new Camera2ApiManager(context);
  videoEncoder = new VideoEncoder(this);
  microphoneManager = new MicrophoneManager(this);
  audioEncoder = new AudioEncoder(this);
  streaming = false;
}
 
Example 42
Project: rtmp-rtsp-stream-client-java   File: Camera1Base.java   Source Code and License 5 votes vote down vote up
public Camera1Base(TextureView textureView) {
  cameraManager = new Camera1ApiManager(textureView, this);
  videoEncoder = new VideoEncoder(this);
  microphoneManager = new MicrophoneManager(this);
  audioEncoder = new AudioEncoder(this);
  streaming = false;
}
 
Example 43
Project: chilly   File: PlaybackOverlayFragment.java   Source Code and License 5 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mAudioManager = (AudioManager) getActivity().getSystemService(Context.AUDIO_SERVICE);

    // Initialize instance variables.
    TextureView textureView = (TextureView) getActivity().findViewById(R.id.texture_view);
    textureView.setSurfaceTextureListener(this);

    setBackgroundType(BACKGROUND_TYPE);

    // Set up listener.
    setOnItemViewClickedListener(new ItemViewClickedListener());
}
 
Example 44
Project: shortrain   File: TutorialFragment.java   Source Code and License 5 votes vote down vote up
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    if (mediaPlayer == null) {
        TextureView textureView = (TextureView) view.findViewById(R.id.tutorial_view_texture_view);
        textureView.setSurfaceTextureListener(this);
    }

    int textId = getArguments().getInt(TEXT_RES_ID);
    TextView textView = (TextView) view.findViewById(R.id.tutorial_view_text_view);
    textView.setOnClickListener((OnNextSlideClicked) getActivity());
    textView.setText(textId);
}
 
Example 45
Project: PlusGram   File: AspectRatioFrameLayout.java   Source Code and License 5 votes vote down vote up
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    super.onMeasure(widthMeasureSpec, heightMeasureSpec);
    if (videoAspectRatio == 0) {
        // Aspect ratio not set.
        return;
    }

    int width = getMeasuredWidth();
    int height = getMeasuredHeight();
    float viewAspectRatio = (float) width / height;
    float aspectDeformation = videoAspectRatio / viewAspectRatio - 1;
    if (Math.abs(aspectDeformation) <= MAX_ASPECT_RATIO_DEFORMATION_FRACTION) {
        // We're within the allowed tolerance.
        return;
    }

    if (aspectDeformation > 0) {
        height = (int) (width / videoAspectRatio);
    } else {
        width = (int) (height * videoAspectRatio);
    }
    super.onMeasure(MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY));
    int count = getChildCount();
    for (int a = 0; a < count; a++) {
        View child = getChildAt(a);
        if (child instanceof TextureView) {
            matrix.reset();
            int px = getWidth() / 2;
            int py = getHeight() / 2;
            matrix.postRotate(rotation, px, py);
            if (rotation == 90 || rotation == 270) {
                float ratio = (float) getHeight() / getWidth();
                matrix.postScale(1 / ratio, ratio, px, py);
            }
            ((TextureView) child).setTransform(matrix);
            break;
        }
    }
}
 
Example 46
Project: PlayerBase   File: PlayerActivity.java   Source Code and License 5 votes vote down vote up
private void screenShot(){
    View renderView = mPlayer.getRenderView();
    if(renderView instanceof TextureView){
        Bitmap bitmap = ((TextureView) renderView).getBitmap();
        if(bitmap!=null){
            String info = FileEngine.bitmapToFile(bitmap, getExternalCacheDir(), System.currentTimeMillis() + ".png");
            System.out.println(info);
        }
    }

}
 
Example 47
Project: FaceDetector   File: CameraOverlayLayout.java   Source Code and License 5 votes vote down vote up
private View findTextureView(View view) {
    View queryView = view;
    while (queryView instanceof ViewGroup) {
        queryView = ((ViewGroup) queryView).getChildAt(0);

        if (queryView instanceof TextureView) {
            return queryView;
        }
    }

    throw new IllegalStateException("Can't find TextureView");
}
 
Example 48
Project: Croprotector   File: UAVControllerActivity.java   Source Code and License 5 votes vote down vote up
private void initUI() {
    // init mVideoSurface
    mVideoSurface = (TextureView)findViewById(R.id.video_previewer_surface);

    recordingTime = (TextView) findViewById(R.id.timer);
    mCaptureBtn = (Button) findViewById(R.id.btn_capture);
    mRecordBtn = (ToggleButton) findViewById(R.id.btn_record);
    mShootPhotoModeBtn = (Button) findViewById(R.id.btn_shoot_photo_mode);
    mRecordVideoModeBtn = (Button) findViewById(R.id.btn_record_video_mode);
    mWayPointBtn=(Button)findViewById(R.id.btn_wayPoint);

    if (null != mVideoSurface) {
        mVideoSurface.setSurfaceTextureListener(this);
    }

    mCaptureBtn.setOnClickListener(this);
    mRecordBtn.setOnClickListener(this);
    mShootPhotoModeBtn.setOnClickListener(this);
    mRecordVideoModeBtn.setOnClickListener(this);
    mWayPointBtn.setOnClickListener(this);

    recordingTime.setVisibility(View.INVISIBLE);

    mRecordBtn.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            if (isChecked) {
                startRecord();
            } else {
                stopRecord();
            }
        }
    });
}
 
Example 49
Project: xbot_head   File: SignInFragment.java   Source Code and License 5 votes vote down vote up
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.fragment_sign, container, false);
    textureView = (TextureView)v.findViewById(R.id.texture_view);
    headTextView = (TextView) v.findViewById(R.id.head_text_view);
    lottieAnimationView = (LottieAnimationView) v.findViewById(R.id.lottie_view);
    return v;
}
 
Example 50
Project: xbot_head   File: CommentaryFragment.java   Source Code and License 5 votes vote down vote up
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_commentary, container, false);
    textureView = (TextureView) view.findViewById(R.id.texture_view);
    stateImageView = (ImageView) view.findViewById(R.id.background_face_state);
    recyclerView = (RecyclerView) view.findViewById(R.id.face_recyclerview);
    coordinatorLayout = (CoordinatorLayout) view.findViewById(R.id.coordinatorLayout);

    initView();
    return view;
}
 
Example 51
Project: xbot_head   File: InteractionFragment.java   Source Code and License 5 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_interaction, container, false);
    waveView = (WaveView) view.findViewById(R.id.id_wave_view);
    textureView = (TextureView) view.findViewById(R.id.texture_view);
    imageView = (ImageView) view.findViewById(R.id.talker_img);
    commentaryButton = (WaveView) view.findViewById(R.id.id_commentary_button);
    return view;
}
 
Example 52
Project: renderscript_examples   File: RSCompute.java   Source Code and License 5 votes vote down vote up
public void setRenderTextureView(TextureView textureView) {
    // If a previous surface was already defined, destroy it and
    // its associated RS allocation
    if (isValidHolder()) {
        destroyHolder();
    }

    textureView.setSurfaceTextureListener(mSurfaceTextureListener);
}
 
Example 53
Project: renderscript_examples   File: MainActivity.java   Source Code and License 5 votes vote down vote up
private void example() {
    // Prevent window dimming
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

    // Here we use the camera preview as below surface and rendering surface as upper one
    SurfaceView surfaceView = (SurfaceView) findViewById(R.id.surfaceView);
    surfaceView.setZOrderOnTop(false);

    // Rendering surface
    TextureView textureView = (TextureView) findViewById(R.id.textureView);
    // Enables support for alpha value in pixels (0 is transparent pixel)
    textureView.setOpaque(false);

    // Creates a new RenderScript context and enables our custom render holder
    mRS = RenderScript.create(this);

    // Enables surface callback to init the entire process.
    // When surface gets initialized, camera preview is enabled
    surfaceView.getHolder().addCallback(mSurfaceHolderCallback);

    textureView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            System.exit(0); // Terminates app when surface is clicked
        }
    });

}
 
Example 54
Project: Exoplayer2Radio   File: SimpleExoPlayer.java   Source Code and License 5 votes vote down vote up
/**
 * Sets the {@link TextureView} onto which video will be rendered. The player will track the
 * lifecycle of the surface automatically.
 *
 * @param textureView The texture view.
 */
public void setVideoTextureView(TextureView textureView) {
  removeSurfaceCallbacks();
  this.textureView = textureView;
  if (textureView == null) {
    setVideoSurfaceInternal(null, true);
  } else {
    if (textureView.getSurfaceTextureListener() != null) {
      Log.w(TAG, "Replacing existing SurfaceTextureListener.");
    }
    SurfaceTexture surfaceTexture = textureView.getSurfaceTexture();
    setVideoSurfaceInternal(surfaceTexture == null ? null : new Surface(surfaceTexture), true);
    textureView.setSurfaceTextureListener(componentListener);
  }
}
 
Example 55
Project: FloatingNew   File: CameraPreviewService.java   Source Code and License 5 votes vote down vote up
@Override
    public void onCreate() {
        super.onCreate();

        //   positionPreference = getSharedPreferences("Position", Context.MODE_PRIVATE);
      /*  windowManager = (WindowManager) getSystemService(WINDOW_SERVICE);*/

        p = new Point();
        Display d = ((WindowManager) getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
        d.getSize(p);
        mFloatingView = LayoutInflater.from(this).inflate(R.layout.camera_preview, null);
        textureView = (TextureView) mFloatingView.findViewById(R.id.texture);

        params = new WindowManager.LayoutParams(
                WindowManager.LayoutParams.WRAP_CONTENT,
                WindowManager.LayoutParams.WRAP_CONTENT,
                WindowManager.LayoutParams.TYPE_PHONE,
                WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE,
                PixelFormat.TRANSLUCENT);


        params.gravity = Gravity.TOP | Gravity.START;        //Initially view will be added to top-left corner
        params.x = 0; //-60;
        params.y = 100;


        setPreview();

        //Add the view to the window
        mWindowManager = (WindowManager) getSystemService(WINDOW_SERVICE);

        mWindowManager.addView(mFloatingView, params);

        mFloatingView.findViewById(R.id.root_container).setOnTouchListener(new Movement());
        mFloatingView.findViewById(R.id.root_container).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (movmentFlag) {
                    if (!cameraFlag) {
                        textureView.setVisibility(View.INVISIBLE);
                      //  closeCamera();
                       // stopBackgroundThread();
                        cameraFlag = true;
                    } else {
                        textureView.setVisibility(View.VISIBLE);
                       // setPreview();
                        cameraFlag = false;
                    }

                }
            }
        });

/*\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/

    }
 
Example 56
Project: vlc-example-streamplayer   File: AWindow.java   Source Code and License 5 votes vote down vote up
private void setView(int id, TextureView view) {
    if (!AndroidUtil.isICSOrLater)
        throw new IllegalArgumentException("TextureView not implemented in this android version");
    ensureInitState();
    if (view == null)
        throw new NullPointerException("view is null");
    final SurfaceHelper surfaceHelper = mSurfaceHelpers[id];
    if (surfaceHelper != null)
        surfaceHelper.release();

    mSurfaceHelpers[id] = new SurfaceHelper(id, view);
}
 
Example 57
Project: UVCCameraZxing   File: QRScanFragment.java   Source Code and License 5 votes vote down vote up
@Override
public void onSurfaceUpdate(Surface surface) {
	time2Scan++;

	//从TextureView获得 Bitmap
	final Bitmap bitmap = ((TextureView) mCameraView).getBitmap();

	if (time2Scan > SCAN_TIME) {
		time2Scan = 0;

		mHandler.post(new Runnable() {
			@Override
			public void run() {

				//识别二维码/条形码
				CodeUtils.analyzeBitmap(bitmap, new CodeUtils.AnalyzeCallback() {
					@Override
					public void onAnalyzeSuccess(Bitmap mBitmap, String result) {
						Log.w(TAG, "发现二维码: " + result);

						mQRString = result;
						mHandler.sendEmptyMessage(MESSAGE_QR_SUCCESS);

					}

					@Override
					public void onAnalyzeFailed() {
						Log.w(TAG, "二维码有误");
					}
				});
			}
		});
	}
}
 
Example 58
Project: ListVideoViewBaseOnVitamio   File: VideoViewLayout.java   Source Code and License 5 votes vote down vote up
public void afterView() {
    inflate(getContext(), R.layout.video_view_layout, this);
    surfaceView = (TextureView) findViewById(R.id.texture_view);
    surfaceView.setSurfaceTextureListener(new MyTextureListener());
    //设置声音的模式
    if (getContext() instanceof Activity)
        ((Activity) getContext()).setVolumeControlStream(AudioManager.STREAM_MUSIC);
}
 
Example 59
Project: libvlc-sdk-android   File: AWindow.java   Source Code and License 5 votes vote down vote up
private void setView(int id, TextureView view) {
    if (!AndroidUtil.isICSOrLater)
        throw new IllegalArgumentException("TextureView not implemented in this android version");
    ensureInitState();
    if (view == null)
        throw new NullPointerException("view is null");
    final SurfaceHelper surfaceHelper = mSurfaceHelpers[id];
    if (surfaceHelper != null)
        surfaceHelper.release();

    mSurfaceHelpers[id] = new SurfaceHelper(id, view);
}
 
Example 60
Project: luxunPro   File: MatrixManager.java   Source Code and License 5 votes vote down vote up
/**
 * Applies the specified scale modification to the view
 *
 * @param view The view to scale
 * @param xScale The scale to apply to the x axis
 * @param yScale The scale to apply to the y axis
 */
protected void setScale(@NonNull TextureView view, float xScale, float yScale) {
    //If the width and height have been swapped, we need to re-calculate the scales based on the swapped sizes
    boolean currentWidthHeightSwapped = ((currentRotation / QUARTER_ROTATION) % 2) == 1;
    if (currentWidthHeightSwapped){
        float scaleTemp = xScale;
        xScale = yScale *  view.getHeight() / view.getWidth();
        yScale = scaleTemp *  view.getWidth() / view.getHeight();
    }

    view.setScaleX(xScale);
    view.setScaleY(yScale);
}