Search in sources :

Example 21 with SurfaceTexture

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);
}
Also used : SurfaceTexture(android.graphics.SurfaceTexture) ByteBuffer(java.nio.ByteBuffer)

Example 22 with SurfaceTexture

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);
            }
        }
    });
}
Also used : SurfaceTexture(android.graphics.SurfaceTexture) TextureView(android.view.TextureView) ImageView(android.widget.ImageView) ImageView(android.widget.ImageView) TextureView(android.view.TextureView) View(android.view.View) Surface(android.view.Surface)

Example 23 with SurfaceTexture

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);
}
Also used : SurfaceHolder(android.view.SurfaceHolder) SurfaceTexture(android.graphics.SurfaceTexture) SurfaceView(android.view.SurfaceView) Surface(android.view.Surface)

Example 24 with SurfaceTexture

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);
}
Also used : SurfaceTexture(android.graphics.SurfaceTexture) RelativeLayout(android.widget.RelativeLayout) GSYTextureView(com.shuyu.gsyvideoplayer.GSYTextureView) GSYTextureView(com.shuyu.gsyvideoplayer.GSYTextureView) TextureView(android.view.TextureView) Surface(android.view.Surface)

Example 25 with SurfaceTexture

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);
    }
}
Also used : SurfaceTexture(android.graphics.SurfaceTexture) Surface(android.view.Surface)

Aggregations

SurfaceTexture (android.graphics.SurfaceTexture)159 Surface (android.view.Surface)97 SurfaceView (android.view.SurfaceView)18 IOException (java.io.IOException)17 Test (org.junit.Test)16 EGLSurface (android.opengl.EGLSurface)14 SurfaceHolder (android.view.SurfaceHolder)14 Context (android.content.Context)13 ExoPlayer (com.google.android.exoplayer2.ExoPlayer)13 FakeClock (com.google.android.exoplayer2.testutil.FakeClock)13 TextureView (android.view.TextureView)12 PlaybackOutput (com.google.android.exoplayer2.robolectric.PlaybackOutput)12 CapturingRenderersFactory (com.google.android.exoplayer2.testutil.CapturingRenderersFactory)12 Uri (android.net.Uri)9 MediaPlayer (android.media.MediaPlayer)8 OnInfoListener (android.media.MediaPlayer.OnInfoListener)8 OnPreparedListener (android.media.MediaPlayer.OnPreparedListener)8 ImageView (android.widget.ImageView)6 ApplicationProvider (androidx.test.core.app.ApplicationProvider)6 AndroidJUnit4 (androidx.test.ext.junit.runners.AndroidJUnit4)6