List of usage examples for android.view SurfaceHolder getSurface
public Surface getSurface();
From source file:com.appunite.appunitevideoplayer.PlayerActivity.java
@Override public void surfaceCreated(SurfaceHolder holder) { if (player != null) { player.setSurface(holder.getSurface()); } }
From source file:com.example.android.hdrviewfinder.HdrViewfinderActivity.java
/** * Callbacks for the FixedAspectSurfaceView *//* w ww . jav a2s. co m*/ @Override public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) { mPreviewSurface = holder.getSurface(); setupProcessor(); }
From source file:android.car.cluster.sample.NavigationFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { Log.i(TAG, "onCreateView"); mDisplayManager = getActivity().getSystemService(DisplayManager.class); mDisplayManager.registerDisplayListener(mDisplayListener, new Handler()); // Inflate the layout for this fragment View root = inflater.inflate(R.layout.fragment_navigation, container, false); mSurfaceView = root.findViewById(R.id.nav_surface); mSurfaceView.getHolder().addCallback(new Callback() { @Override// w w w. j a v a 2 s . c o m public void surfaceCreated(SurfaceHolder holder) { Log.i(TAG, "surfaceCreated, holder: " + holder); } @Override public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) { Log.i(TAG, "surfaceChanged, holder: " + holder + ", size:" + width + "x" + height + ", format:" + format); //Create dummy unobscured area to report to navigation activity. mUnobscuredBounds = new Rect(40, 0, width - 80, height - 40); if (mVirtualDisplay == null) { mVirtualDisplay = createVirtualDisplay(holder.getSurface(), width, height); } else { mVirtualDisplay.setSurface(holder.getSurface()); } } @Override public void surfaceDestroyed(SurfaceHolder holder) { Log.i(TAG, "surfaceDestroyed, holder: " + holder + ", detaching surface from" + " display, surface: " + holder.getSurface()); // detaching surface is similar to turning off the display mVirtualDisplay.setSurface(null); } }); return root; }
From source file:com.android.onemedia.playback.LocalRenderer.java
/** * Checks if the holder is ready and either sets up a callback to wait for * it or sets it directly. If//from w w w . jav a2s .c o m * * @param holder * @param player * @return */ private boolean isHolderReady(final SurfaceHolder holder, final MediaPlayer player) { mHolder = holder; if (holder != null) { if (holder.getSurface() != null && holder.getSurface().isValid()) { player.setDisplay(holder); return true; } else { Log.w(TAG, "Holder not null, waiting for it to be ready"); // If the holder isn't ready yet add a callback to set the // holder when it's ready. SurfaceHolder.Callback cb = new SurfaceHolder.Callback() { @Override public void surfaceDestroyed(SurfaceHolder arg0) { } @Override public void surfaceCreated(SurfaceHolder arg0) { if (player.equals(mPlayer)) { player.setDisplay(arg0); preparePlayer(player, true); } } @Override public void surfaceChanged(SurfaceHolder arg0, int arg1, int arg2, int arg3) { } }; mHolderCB = cb; holder.addCallback(cb); return false; } } return true; }
From source file:com.example.javier.MaterialDesignApp.PlayerActivity.java
@Override public void surfaceCreated(SurfaceHolder holder) { if (player != null) { player.setSurface(holder.getSurface()); } }
From source file:com.simas.vc.editor.player.PlayerFragment.java
@Override public void surfaceCreated(SurfaceHolder holder) { if (holder.getSurface().isValid()) { Player player = getControls().getPlayer(); if (player != null) { player.setDisplay(holder);/*from www . j a v a2 s. c o m*/ } } }
From source file:com.simas.vc.editor.player.PlayerFragment.java
@Override public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) { if (holder.getSurface().isValid()) { Player player = getControls().getPlayer(); if (player != null) { player.setDisplay(holder);//from ww w . j a va 2 s. c om } } }
From source file:paulscode.android.mupen64plusae.game.GameFragment.java
@Override public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) { Log.i("GameFragment", "surfaceChanged"); mIsSurface = true;//from www . j a va2s . c om mCoreFragment.setSurface(holder.getSurface()); tryRunning(); }
From source file:com.serenegiant.usb.UVCCamera.java
/** * set preview surface with SurfaceHolder</br> * you can use SurfaceHolder came from SurfaceView/GLSurfaceView * @param holder/*from ww w . jav a2s . c o m*/ */ public void setPreviewDisplay(final SurfaceHolder holder) { nativeSetPreviewDisplay(mNativePtr, holder.getSurface()); }
From source file:com.fishstix.dosboxfree.DBGLSurfaceView.java
private void canvasDraw(Bitmap bitmap, int src_width, int src_height, int startLine, int endLine) { SurfaceHolder surfaceHolder = getHolder(); Surface surface = surfaceHolder.getSurface(); Canvas canvas = null;/*from w w w .j a v a 2 s. c o m*/ try { synchronized (surfaceHolder) { boolean isDirty = false; if (mDirtyCount < 3) { mDirtyCount++; isDirty = true; startLine = 0; endLine = src_height; } if (mScale) { mDstRect.set(0, 0, mRenderer.width, mRenderer.height); mSrcRect.set(0, 0, src_width, src_height); mDstRect.offset(mRenderer.x, mRenderer.y); mDirtyRect.set(0, startLine * mRenderer.height / src_height, mRenderer.width, endLine * mRenderer.height / src_height + 1); //locnet, 2011-04-21, a strip on right side not updated mDirtyRect.offset(mRenderer.x, mRenderer.y); } else { //L,T,R,B mSrcRect.set(-mScroll_x, Math.max(-mScroll_y, startLine), mRenderer.mCropWorkspace[2], Math.min(Math.min(getHeight() - mScroll_y, src_height), endLine)); mDstRect.set(0, mSrcRect.top + mScroll_y, mSrcRect.width(), mSrcRect.top + mScroll_y + mSrcRect.height()); if (isLandscape) { mDstRect.offset((getWidth() - mSrcRect.width()) / 2, 0); } else { mDstRect.offset((getWidth() - mSrcRect.width()) / 2, mActionBarHeight); } mDirtyRect.set(mDstRect); } if (surface != null && surface.isValid()) { if (isDirty) { canvas = surfaceHolder.lockCanvas(null); canvas.drawColor(0xff000000); } else { canvas = surfaceHolder.lockCanvas(mDirtyRect); } if (mScale) { canvas.drawBitmap(bitmap, mSrcRect, mDstRect, (mParent.mPrefScaleFilterOn) ? mBitmapPaint : null); } else { canvas.drawBitmap(bitmap, mSrcRect, mDstRect, null); } } } } finally { if (canvas != null && surface != null && surface.isValid()) { surfaceHolder.unlockCanvasAndPost(canvas); } } surfaceHolder = null; }