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);
}
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();
}
}
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();
}
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();
}
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");
}
}
Aggregations