use of android.graphics.SurfaceTexture in project react-native-android-video-editor by RZulfikri.
the class VideoTextureRenderer method setupTexture.
private void setupTexture(Context context) {
ByteBuffer texturebb = ByteBuffer.allocateDirect(textureCoords.length * 4);
texturebb.order(ByteOrder.nativeOrder());
textureBuffer = texturebb.asFloatBuffer();
textureBuffer.put(textureCoords);
textureBuffer.position(0);
// Generate the actual texture
GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
GLES20.glGenTextures(1, textures, 0);
checkGlError("Texture generate");
GLES20.glBindTexture(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, textures[0]);
checkGlError("Texture bind");
videoTexture = new SurfaceTexture(textures[0]);
videoTexture.setOnFrameAvailableListener(this);
}
use of android.graphics.SurfaceTexture in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class GesturePreference method onBindViewHolder.
@Override
public void onBindViewHolder(PreferenceViewHolder holder) {
super.onBindViewHolder(holder);
if (!mAnimationAvailable) {
return;
}
final TextureView video = (TextureView) holder.findViewById(R.id.gesture_video);
final ImageView imageView = (ImageView) holder.findViewById(R.id.gesture_image);
imageView.setImageResource(mPreviewResource);
final ImageView playButton = (ImageView) holder.findViewById(R.id.gesture_play_button);
video.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (mMediaPlayer != null) {
if (mMediaPlayer.isPlaying()) {
mMediaPlayer.pause();
playButton.setVisibility(View.VISIBLE);
} else {
mMediaPlayer.start();
playButton.setVisibility(View.GONE);
}
}
}
});
video.setSurfaceTextureListener(new TextureView.SurfaceTextureListener() {
@Override
public void onSurfaceTextureAvailable(SurfaceTexture surfaceTexture, int width, int height) {
if (mMediaPlayer != null) {
mMediaPlayer.setSurface(new Surface(surfaceTexture));
mVideoReady = false;
mMediaPlayer.seekTo(0);
}
}
@Override
public void onSurfaceTextureSizeChanged(SurfaceTexture surfaceTexture, int width, int height) {
}
@Override
public boolean onSurfaceTextureDestroyed(SurfaceTexture surfaceTexture) {
imageView.setVisibility(View.VISIBLE);
return false;
}
@Override
public void onSurfaceTextureUpdated(SurfaceTexture surfaceTexture) {
if (mVideoReady && imageView.getVisibility() == View.VISIBLE) {
imageView.setVisibility(View.GONE);
} else if (mScrolling) {
mScrolling = false;
if (mMediaPlayer != null && mMediaPlayer.isPlaying()) {
mMediaPlayer.pause();
playButton.setVisibility(View.VISIBLE);
}
}
if (mMediaPlayer != null && !mMediaPlayer.isPlaying() && playButton.getVisibility() != View.VISIBLE) {
playButton.setVisibility(View.VISIBLE);
}
}
});
}
use of android.graphics.SurfaceTexture in project XobotOS by xamarin.
the class EGLImpl method eglCreateWindowSurface.
public EGLSurface eglCreateWindowSurface(EGLDisplay display, EGLConfig config, Object native_window, int[] attrib_list) {
Surface sur = null;
if (native_window instanceof SurfaceView) {
SurfaceView surfaceView = (SurfaceView) native_window;
sur = surfaceView.getHolder().getSurface();
} else if (native_window instanceof SurfaceHolder) {
SurfaceHolder holder = (SurfaceHolder) native_window;
sur = holder.getSurface();
}
int eglSurfaceId;
if (sur != null) {
eglSurfaceId = _eglCreateWindowSurface(display, config, sur, attrib_list);
} else if (native_window instanceof SurfaceTexture) {
eglSurfaceId = _eglCreateWindowSurfaceTexture(display, config, (SurfaceTexture) native_window, attrib_list);
} else {
throw new java.lang.UnsupportedOperationException("eglCreateWindowSurface() can only be called with an instance of " + "SurfaceView, SurfaceHolder or SurfaceTexture at the moment, " + "this will be fixed later.");
}
if (eglSurfaceId == 0) {
return EGL10.EGL_NO_SURFACE;
}
return new EGLSurfaceImpl(eglSurfaceId);
}
use of android.graphics.SurfaceTexture in project GSYVideoPlayer by CarGuo.
the class CustomGSYVideoPlayer method addTextureView.
@Override
protected void addTextureView() {
super.addTextureView();
if (mPreviewLayout.getChildCount() > 0) {
mPreviewLayout.removeAllViews();
}
mPreviewTexture = null;
mPreviewTexture = new GSYTextureView(getContext());
mPreviewTexture.setSurfaceTextureListener(new TextureView.SurfaceTextureListener() {
@Override
public void onSurfaceTextureAvailable(SurfaceTexture surface, int width, int height) {
GSYPreViewManager.instance().setDisplay(new Surface(surface));
}
@Override
public void onSurfaceTextureSizeChanged(SurfaceTexture surface, int width, int height) {
}
@Override
public boolean onSurfaceTextureDestroyed(SurfaceTexture surface) {
GSYPreViewManager.instance().setDisplay(null);
return true;
}
@Override
public void onSurfaceTextureUpdated(SurfaceTexture surface) {
}
});
mPreviewTexture.setRotation(mRotate);
RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
layoutParams.addRule(RelativeLayout.CENTER_IN_PARENT);
mPreviewLayout.addView(mPreviewTexture, layoutParams);
}
use of android.graphics.SurfaceTexture in project android_frameworks_base by DirtyUnicorns.
the class RequestThreadManager method createDummySurface.
/**
* Fake preview for jpeg captures when there is no active preview
*/
private void createDummySurface() {
if (mDummyTexture == null || mDummySurface == null) {
mDummyTexture = new SurfaceTexture(/*ignored*/
0);
// TODO: use smallest default sizes
mDummyTexture.setDefaultBufferSize(640, 480);
mDummySurface = new Surface(mDummyTexture);
}
}
Aggregations