本文整理汇总了Java中android.view.TextureView类的典型用法代码示例。如果您正苦于以下问题:Java TextureView类的具体用法?Java TextureView怎么用?Java TextureView使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TextureView类属于android.view包,在下文中一共展示了TextureView类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: updateFromPreferences
import android.view.TextureView; //导入依赖的package包/类
@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;
}
}
示例2: onCreate
import android.view.TextureView; //导入依赖的package包/类
@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());
}
示例3: onCreate
import android.view.TextureView; //导入依赖的package包/类
@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);
}
示例4: initViews
import android.view.TextureView; //导入依赖的package包/类
@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);
}
示例5: setupSurfaceView
import android.view.TextureView; //导入依赖的package包/类
@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);
}
}
示例6: captureView
import android.view.TextureView; //导入依赖的package包/类
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;
}
示例7: setPlayer
import android.view.TextureView; //导入依赖的package包/类
/**
* 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);
}
}
示例8: showingPreview
import android.view.TextureView; //导入依赖的package包/类
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);
}
};
}
示例9: initPickupPlayer
import android.view.TextureView; //导入依赖的package包/类
/**
* ピックアップ再生用の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);
}
示例10: onCreate
import android.view.TextureView; //导入依赖的package包/类
@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();
}
示例11: onCreate
import android.view.TextureView; //导入依赖的package包/类
@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));
}
}
示例12: configureTransform
import android.view.TextureView; //导入依赖的package包/类
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);
}
示例13: setup
import android.view.TextureView; //导入依赖的package包/类
/**
* 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);
}
示例14: CameraView
import android.view.TextureView; //导入依赖的package包/类
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);
}
示例15: onCreate
import android.view.TextureView; //导入依赖的package包/类
@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));
}