Search in sources :

Example 1 with Surface

use of android.view.Surface in project VideoPlayerManager by danylovolokh.

the class MediaPlayerWrapper method setSurfaceTexture.

public void setSurfaceTexture(SurfaceTexture surfaceTexture) {
    if (SHOW_LOGS)
        Logger.v(TAG, ">> setSurfaceTexture " + surfaceTexture);
    if (SHOW_LOGS)
        Logger.v(TAG, "setSurfaceTexture mSurface " + mSurface);
    if (surfaceTexture != null) {
        mSurface = new Surface(surfaceTexture);
        // TODO fix illegal state exception
        mMediaPlayer.setSurface(mSurface);
    } else {
        mMediaPlayer.setSurface(null);
    }
    if (SHOW_LOGS)
        Logger.v(TAG, "<< setSurfaceTexture " + surfaceTexture);
}
Also used : Surface(android.view.Surface)

Example 2 with Surface

use of android.view.Surface in project UltimateAndroid by cymcsg.

the class VideoResourceInput method initWithGLContext.

@Override
protected void initWithGLContext() {
    ready = false;
    try {
        player = MediaPlayer.create(context, id);
    } catch (Exception e) {
        Log.e("VideoPlayer", "Failed to load video");
        StringWriter sw = new StringWriter();
        PrintWriter pw = new PrintWriter(sw);
        e.printStackTrace(pw);
        Log.e("VideoPlayer", sw.toString());
        player.release();
    }
    setRenderSize(player.getVideoWidth(), player.getVideoHeight());
    super.initWithGLContext();
    int[] textures = new int[1];
    GLES20.glGenTextures(1, textures, 0);
    GLES20.glBindTexture(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, textures[0]);
    GLES20.glTexParameterf(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, GL10.GL_TEXTURE_MIN_FILTER, GL10.GL_LINEAR);
    GLES20.glTexParameterf(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, GL10.GL_TEXTURE_MAG_FILTER, GL10.GL_LINEAR);
    GLES20.glTexParameteri(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, GL10.GL_TEXTURE_WRAP_S, GL10.GL_CLAMP_TO_EDGE);
    GLES20.glTexParameteri(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, GL10.GL_TEXTURE_WRAP_T, GL10.GL_CLAMP_TO_EDGE);
    texture_in = textures[0];
    videoTex = new SurfaceTexture(texture_in);
    videoTex.setOnFrameAvailableListener(this);
    Surface surface = new Surface(videoTex);
    player.setSurface(surface);
    ready = true;
    if (startWhenReady) {
        player.start();
    }
}
Also used : SurfaceTexture(android.graphics.SurfaceTexture) StringWriter(java.io.StringWriter) PrintWriter(java.io.PrintWriter) Surface(android.view.Surface)

Example 3 with Surface

use of android.view.Surface in project android_frameworks_base by ParanoidAndroid.

the class HTML5VideoInline method decideDisplayMode.

@Override
public void decideDisplayMode() {
    SurfaceTexture surfaceTexture = getSurfaceTexture(getVideoLayerId());
    Surface surface = new Surface(surfaceTexture);
    mPlayer.setSurface(surface);
    surface.release();
}
Also used : SurfaceTexture(android.graphics.SurfaceTexture) Surface(android.view.Surface)

Example 4 with Surface

use of android.view.Surface in project android_frameworks_base by ParanoidAndroid.

the class MediaPlayer method setDisplay.

/**
     * Sets the {@link SurfaceHolder} to use for displaying the video
     * portion of the media.
     *
     * Either a surface holder or surface must be set if a display or video sink
     * is needed.  Not calling this method or {@link #setSurface(Surface)}
     * when playing back a video will result in only the audio track being played.
     * A null surface holder or surface will result in only the audio track being
     * played.
     *
     * @param sh the SurfaceHolder to use for video display
     */
public void setDisplay(SurfaceHolder sh) {
    mSurfaceHolder = sh;
    Surface surface;
    if (sh != null) {
        surface = sh.getSurface();
    } else {
        surface = null;
    }
    _setVideoSurface(surface);
    updateSurfaceScreenOn();
}
Also used : Surface(android.view.Surface)

Example 5 with Surface

use of android.view.Surface in project android_frameworks_base by ParanoidAndroid.

the class VideoEditorImpl method startPreview.

/*
     * {@inheritDoc}
     */
public void startPreview(SurfaceHolder surfaceHolder, long fromMs, long toMs, boolean loop, int callbackAfterFrameCount, PreviewProgressListener listener) {
    if (surfaceHolder == null) {
        throw new IllegalArgumentException();
    }
    final Surface surface = surfaceHolder.getSurface();
    if (surface == null) {
        throw new IllegalArgumentException("Surface could not be retrieved from surface holder");
    }
    if (surface.isValid() == false) {
        throw new IllegalStateException("Surface is not valid");
    }
    if (listener == null) {
        throw new IllegalArgumentException();
    }
    if (fromMs >= mDurationMs) {
        throw new IllegalArgumentException("Requested time not correct");
    }
    if (fromMs < 0) {
        throw new IllegalArgumentException("Requested time not correct");
    }
    boolean semAcquireDone = false;
    if (!mPreviewInProgress) {
        try {
            semAcquireDone = lock(ENGINE_ACCESS_MAX_TIMEOUT_MS);
            if (semAcquireDone == false) {
                throw new IllegalStateException("Timeout waiting for semaphore");
            }
            if (mMANativeHelper == null) {
                throw new IllegalStateException("The video editor is not initialized");
            }
            if (mMediaItems.size() > 0) {
                mPreviewInProgress = true;
                mMANativeHelper.previewStoryBoard(mMediaItems, mTransitions, mAudioTracks, null);
                mMANativeHelper.doPreview(surface, fromMs, toMs, loop, callbackAfterFrameCount, listener);
            }
        /**
                 *  Release The lock on complete by calling stopPreview
                 */
        } catch (InterruptedException ex) {
            Log.w(TAG, "The thread was interrupted", new Throwable());
            throw new IllegalStateException("The thread was interrupted");
        }
    } else {
        throw new IllegalStateException("Preview already in progress");
    }
}
Also used : Surface(android.view.Surface)

Aggregations

Surface (android.view.Surface)300 ArrayList (java.util.ArrayList)100 SurfaceTexture (android.graphics.SurfaceTexture)49 BlockingSessionCallback (com.android.ex.camera2.blocking.BlockingSessionCallback)44 Size (android.util.Size)35 CaptureRequest (android.hardware.camera2.CaptureRequest)34 OutputConfiguration (android.hardware.camera2.params.OutputConfiguration)30 IOException (java.io.IOException)27 EGLSurface (android.opengl.EGLSurface)19 Paint (android.graphics.Paint)16 StreamConfigurationMap (android.hardware.camera2.params.StreamConfigurationMap)15 SurfaceHolder (android.view.SurfaceHolder)15 Rect (android.graphics.Rect)13 SurfaceView (android.view.SurfaceView)13 Canvas (android.graphics.Canvas)12 CameraAccessException (android.hardware.camera2.CameraAccessException)12 WifiDisplay (android.hardware.display.WifiDisplay)12 MediaRecorder (android.media.MediaRecorder)11 SurfaceControl (android.view.SurfaceControl)11 Image (android.media.Image)10