Search in sources :

Example 71 with SurfaceView

use of android.view.SurfaceView in project LeafPic by HoraApps.

the class PlayerActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(org.horaapps.leafpic.R.layout.activity_player);
    FrameLayout root = (FrameLayout) findViewById(org.horaapps.leafpic.R.id.root);
    findViewById(R.id.video_frame).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            toggleControlsVisibility();
        }
    });
    root.setOnKeyListener(new OnKeyListener() {

        @Override
        public boolean onKey(View v, int keyCode, KeyEvent event) {
            return !(keyCode == KeyEvent.KEYCODE_BACK || keyCode == KeyEvent.KEYCODE_ESCAPE || keyCode == KeyEvent.KEYCODE_MENU) && mediaController.dispatchKeyEvent(event);
        }
    });
    root.setBackgroundColor(ContextCompat.getColor(getApplicationContext(), R.color.md_black_1000));
    shutterView = findViewById(org.horaapps.leafpic.R.id.shutter);
    videoFrame = (AspectRatioFrameLayout) findViewById(org.horaapps.leafpic.R.id.video_frame);
    surfaceView = (SurfaceView) findViewById(org.horaapps.leafpic.R.id.surface_view);
    surfaceView.getHolder().addCallback(this);
    mediaController = new CustomMediaController(this, this);
    mediController_anchor = findViewById(org.horaapps.leafpic.R.id.media_player_anchor);
    mediaController.setAnchorView(root);
    //mediaController.setPaddingRelative(0,0,0,Measure.getNavBarHeight(PlayerActivity.this));
    toolbar = (Toolbar) findViewById(org.horaapps.leafpic.R.id.toolbar);
    initUI();
    CookieHandler currentHandler = CookieHandler.getDefault();
    if (currentHandler != defaultCookieManager)
        CookieHandler.setDefault(defaultCookieManager);
    audioCapabilitiesReceiver = new AudioCapabilitiesReceiver(this, this);
    audioCapabilitiesReceiver.register();
}
Also used : KeyEvent(android.view.KeyEvent) AudioCapabilitiesReceiver(com.google.android.exoplayer.audio.AudioCapabilitiesReceiver) FrameLayout(android.widget.FrameLayout) AspectRatioFrameLayout(com.google.android.exoplayer.AspectRatioFrameLayout) OnKeyListener(android.view.View.OnKeyListener) SurfaceView(android.view.SurfaceView) VideoControllerView(org.horaapps.leafpic.views.VideoControllerView) View(android.view.View) CookieHandler(java.net.CookieHandler)

Example 72 with SurfaceView

use of android.view.SurfaceView in project XobotOS by xamarin.

the class ViewManager method requestLayout.

/**
     * This should only be called from the UI thread.
     */
private void requestLayout(ChildView v) {
    int width = mWebView.contentToViewDimension(v.width);
    int height = mWebView.contentToViewDimension(v.height);
    int x = mWebView.contentToViewX(v.x);
    int y = mWebView.contentToViewY(v.y);
    AbsoluteLayout.LayoutParams lp;
    ViewGroup.LayoutParams layoutParams = v.mView.getLayoutParams();
    if (layoutParams instanceof AbsoluteLayout.LayoutParams) {
        lp = (AbsoluteLayout.LayoutParams) layoutParams;
        lp.width = width;
        lp.height = height;
        lp.x = x;
        lp.y = y;
    } else {
        lp = new AbsoluteLayout.LayoutParams(width, height, x, y);
    }
    // apply the layout to the view
    v.mView.setLayoutParams(lp);
    if (v.mView instanceof SurfaceView) {
        final SurfaceView sView = (SurfaceView) v.mView;
        if (sView.isFixedSize() && mZoomInProgress) {
            /* If we're already fixed, and we're in a zoom, then do nothing
                   about the size. Just wait until we get called at the end of
                   the zoom session (with mZoomInProgress false) and we'll
                   fixup our size then.
                 */
            return;
        }
        /* Compute proportional fixed width/height if necessary.
             *
             * NOTE: plugins (e.g. Flash) must not explicitly fix the size of
             * their surface. The logic below will result in unexpected behavior
             * for the plugin if they attempt to fix the size of the surface.
             */
        int fixedW = width;
        int fixedH = height;
        if (fixedW > MAX_SURFACE_DIMENSION || fixedH > MAX_SURFACE_DIMENSION) {
            if (v.width > v.height) {
                fixedW = MAX_SURFACE_DIMENSION;
                fixedH = v.height * MAX_SURFACE_DIMENSION / v.width;
            } else {
                fixedH = MAX_SURFACE_DIMENSION;
                fixedW = v.width * MAX_SURFACE_DIMENSION / v.height;
            }
        }
        if (fixedW * fixedH > MAX_SURFACE_AREA) {
            float area = MAX_SURFACE_AREA;
            if (v.width > v.height) {
                fixedW = (int) Math.sqrt(area * v.width / v.height);
                fixedH = v.height * fixedW / v.width;
            } else {
                fixedH = (int) Math.sqrt(area * v.height / v.width);
                fixedW = v.width * fixedH / v.height;
            }
        }
        if (fixedW != width || fixedH != height) {
            // if we get here, either our dimensions or area (or both)
            // exeeded our max, so we had to compute fixedW and fixedH
            sView.getHolder().setFixedSize(fixedW, fixedH);
        } else if (!sView.isFixedSize() && mZoomInProgress) {
            // just freeze where we were (view size) until we're done with
            // the zoom progress
            sView.getHolder().setFixedSize(sView.getWidth(), sView.getHeight());
        } else if (sView.isFixedSize() && !mZoomInProgress) {
            /* The changing of visibility is a hack to get around a bug in
                 * the framework that causes the surface to revert to the size
                 * it was prior to being fixed before it redraws using the
                 * values currently in its layout.
                 *
                 * The surface is destroyed when it is set to invisible and then
                 * recreated at the new dimensions when it is made visible. The
                 * same destroy/create step occurs without the change in
                 * visibility, but then exhibits the behavior described in the
                 * previous paragraph.
                 */
            if (sView.getVisibility() == View.VISIBLE) {
                sView.setVisibility(View.INVISIBLE);
                sView.getHolder().setSizeFromLayout();
                // setLayoutParams() only requests the layout. If we set it
                // to VISIBLE now, it will use the old dimension to set the
                // size. Post a message to ensure that it shows the new size.
                mWebView.mPrivateHandler.post(new Runnable() {

                    public void run() {
                        sView.setVisibility(View.VISIBLE);
                    }
                });
            } else {
                sView.getHolder().setSizeFromLayout();
            }
        }
    }
}
Also used : ViewGroup(android.view.ViewGroup) AbsoluteLayout(android.widget.AbsoluteLayout) SurfaceView(android.view.SurfaceView)

Example 73 with SurfaceView

use of android.view.SurfaceView in project XobotOS by xamarin.

the class PluginFullScreenHolder method setContentView.

public void setContentView(View contentView) {
    // Create a FrameLayout that will contain the plugin's view
    mLayout = new CustomFrameLayout(mWebView.getContext());
    FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT, Gravity.CENTER);
    mLayout.addView(contentView, layoutParams);
    mLayout.setVisibility(View.VISIBLE);
    // by the ViewManager when it is re-attached to the WebView.
    if (contentView instanceof SurfaceView) {
        final SurfaceView sView = (SurfaceView) contentView;
        if (sView.isFixedSize()) {
            sView.getHolder().setSizeFromLayout();
        }
    }
    mContentView = contentView;
}
Also used : FrameLayout(android.widget.FrameLayout) SurfaceView(android.view.SurfaceView)

Example 74 with SurfaceView

use of android.view.SurfaceView in project zxing by zxing.

the class CaptureActivity method onResume.

@Override
public synchronized void onResume() {
    super.onResume();
    SurfaceView surfaceView = (SurfaceView) findViewById(R.id.preview_view);
    SurfaceHolder surfaceHolder = surfaceView.getHolder();
    if (surfaceHolder == null) {
        throw new IllegalStateException("No SurfaceHolder?");
    }
    if (hasSurface) {
        initCamera(surfaceHolder);
    } else {
        surfaceHolder.addCallback(this);
        holderWithCallback = surfaceHolder;
    }
}
Also used : SurfaceHolder(android.view.SurfaceHolder) SurfaceView(android.view.SurfaceView)

Example 75 with SurfaceView

use of android.view.SurfaceView in project QRCode by 5peak2me.

the class MipcaActivityCapture method onResume.

@Override
protected void onResume() {
    super.onResume();
    SurfaceView surfaceView = (SurfaceView) findViewById(R.id.preview_view);
    SurfaceHolder surfaceHolder = surfaceView.getHolder();
    if (hasSurface) {
        initCamera(surfaceHolder);
    } else {
        surfaceHolder.addCallback(this);
        surfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
    }
    decodeFormats = null;
    characterSet = null;
    playBeep = true;
    AudioManager audioService = (AudioManager) getSystemService(AUDIO_SERVICE);
    if (audioService.getRingerMode() != AudioManager.RINGER_MODE_NORMAL) {
        playBeep = false;
    }
    initBeepSound();
    vibrate = true;
}
Also used : SurfaceHolder(android.view.SurfaceHolder) AudioManager(android.media.AudioManager) SurfaceView(android.view.SurfaceView)

Aggregations

SurfaceView (android.view.SurfaceView)92 SurfaceHolder (android.view.SurfaceHolder)45 View (android.view.View)24 SurfaceTexture (android.graphics.SurfaceTexture)15 Surface (android.view.Surface)13 Button (android.widget.Button)12 FrameLayout (android.widget.FrameLayout)12 Intent (android.content.Intent)11 Bitmap (android.graphics.Bitmap)8 TextView (android.widget.TextView)8 FileOutputStream (java.io.FileOutputStream)8 ViewGroup (android.view.ViewGroup)6 MotionEvent (android.view.MotionEvent)5 OnClickListener (android.view.View.OnClickListener)5 ImageView (android.widget.ImageView)5 CameraManager (com.google.zxing.client.android.camera.CameraManager)5 Activity (android.app.Activity)4 PendingIntent (android.app.PendingIntent)4 IntentFilter (android.content.IntentFilter)4 UsbDevice (android.hardware.usb.UsbDevice)4