Java Code Examples for android.view.SurfaceView#setZOrderMediaOverlay()

The following examples show how to use android.view.SurfaceView#setZOrderMediaOverlay() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: VideoPlayerActivity.java    From VCL-Android with Apache License 2.0 7 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.player_remote);

    mSurfaceView = (SurfaceView) findViewById(R.id.remote_player_surface);
    mSubtitlesSurfaceView = (SurfaceView) findViewById(R.id.remote_subtitles_surface);
    mSurfaceFrame = (FrameLayout) findViewById(R.id.remote_player_surface_frame);

    if (HWDecoderUtil.HAS_SUBTITLES_SURFACE) {
        mSubtitlesSurfaceView.setZOrderMediaOverlay(true);
        mSubtitlesSurfaceView.getHolder().setFormat(PixelFormat.TRANSLUCENT);
    } else
        mSubtitlesSurfaceView.setVisibility(View.GONE);
    VideoPlayerActivity activity = (VideoPlayerActivity)getOwnerActivity();
    if (activity == null) {
        Log.e(TAG, "Failed to get the VideoPlayerActivity instance, secondary display won't work");
        return;
    }

    Log.i(TAG, "Secondary display created");
}
 
Example 2
Source File: MultiSurfaceActivity.java    From pause-resume-video-recording with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_multi_surface_test);

    // #1 is at the bottom; mark it as secure just for fun.  By default, this will use
    // the RGB565 color format.
    mSurfaceView1 = (SurfaceView) findViewById(R.id.multiSurfaceView1);
    mSurfaceView1.getHolder().addCallback(this);
    mSurfaceView1.setSecure(true);

    // #2 is above it, in the "media overlay"; must be translucent or we will totally
    // obscure #1 and it will be ignored by the compositor.  The addition of the alpha
    // plane should switch us to RGBA8888.
    mSurfaceView2 = (SurfaceView) findViewById(R.id.multiSurfaceView2);
    mSurfaceView2.getHolder().addCallback(this);
    mSurfaceView2.getHolder().setFormat(PixelFormat.TRANSLUCENT);
    mSurfaceView2.setZOrderMediaOverlay(true);

    // #3 is above everything, including the UI.  Also translucent.
    mSurfaceView3 = (SurfaceView) findViewById(R.id.multiSurfaceView3);
    mSurfaceView3.getHolder().addCallback(this);
    mSurfaceView3.getHolder().setFormat(PixelFormat.TRANSLUCENT);
    mSurfaceView3.setZOrderOnTop(true);
}
 
Example 3
Source File: MultiSurfaceActivity.java    From grafika with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_multi_surface_test);

    // #1 is at the bottom; mark it as secure just for fun.  By default, this will use
    // the RGB565 color format.
    mSurfaceView1 = (SurfaceView) findViewById(R.id.multiSurfaceView1);
    mSurfaceView1.getHolder().addCallback(this);
    mSurfaceView1.setSecure(true);

    // #2 is above it, in the "media overlay"; must be translucent or we will totally
    // obscure #1 and it will be ignored by the compositor.  The addition of the alpha
    // plane should switch us to RGBA8888.
    mSurfaceView2 = (SurfaceView) findViewById(R.id.multiSurfaceView2);
    mSurfaceView2.getHolder().addCallback(this);
    mSurfaceView2.getHolder().setFormat(PixelFormat.TRANSLUCENT);
    mSurfaceView2.setZOrderMediaOverlay(true);

    // #3 is above everything, including the UI.  Also translucent.
    mSurfaceView3 = (SurfaceView) findViewById(R.id.multiSurfaceView3);
    mSurfaceView3.getHolder().addCallback(this);
    mSurfaceView3.getHolder().setFormat(PixelFormat.TRANSLUCENT);
    mSurfaceView3.setZOrderOnTop(true);
}
 
Example 4
Source File: CompositorSurfaceManager.java    From 365browser with Apache License 2.0 5 votes vote down vote up
public SurfaceState(Context context, int format, SurfaceHolder.Callback2 callback) {
    surfaceView = new SurfaceView(context);
    surfaceView.setZOrderMediaOverlay(true);
    surfaceView.setVisibility(View.INVISIBLE);
    surfaceHolder().setFormat(format);
    surfaceHolder().addCallback(callback);

    // Set this to UNKNOWN until we get a format back.
    this.format = PixelFormat.UNKNOWN;
}
 
Example 5
Source File: CallVideoFragment.java    From Linphone4Android with GNU General Public License v3.0 4 votes vote down vote up
private void fixZOrder(SurfaceView video, SurfaceView preview) {
	video.setZOrderOnTop(false);
	preview.setZOrderOnTop(true);
	preview.setZOrderMediaOverlay(true); // Needed to be able to display control layout over
}
 
Example 6
Source File: MultiVideoCallActivity.java    From sealtalk-android with MIT License 4 votes vote down vote up
public void onSwitchRemoteUsers(View view) {
    String from = (String) view.getTag();
    if (from == null)
        return;
    String to = (String) localView.getTag();
    FrameLayout layout = (FrameLayout) view;
    SurfaceView fromView = (SurfaceView) layout.getChildAt(0);
    SurfaceView toView = localView;

    localViewContainer.removeAllViews();
    layout.removeAllViews();

    View singleRemoteView = remoteViewContainer.findViewWithTag(from + "view");
    UserInfo toUserInfo = RongContext.getInstance().getUserInfoFromCache(to);
    UserInfo fromUserInfo = RongContext.getInstance().getUserInfoFromCache(from);

    AsyncImageView userPortraitView = (AsyncImageView) singleRemoteView.findViewById(R.id.user_portrait);
    TextView backUserNameView = (TextView) singleRemoteView.findViewById(R.id.user_name);

    if (toUserInfo != null) {
        if (toUserInfo.getPortraitUri() != null) {
            userPortraitView.setAvatar(toUserInfo.getPortraitUri().toString(), R.drawable.rc_default_portrait);
        }
        backUserNameView.setText(toUserInfo.getName());
    } else {
        backUserNameView.setText(to);
    }
    singleRemoteView.setTag(to + "view");
    fromView.setZOrderOnTop(false);
    fromView.setZOrderMediaOverlay(false);
    localViewContainer.addView(fromView);
    toView.setZOrderOnTop(true);
    toView.setZOrderMediaOverlay(true);
    layout.addView(toView);

    TextView topUserNameView = (TextView) topContainer.findViewById(R.id.rc_voip_user_name);
    if (fromUserInfo != null) {
        topUserNameView.setText(fromUserInfo.getName());
    } else {
        topUserNameView.setText(from);
    }
    layout.setTag(to);
    localView = fromView;
    localView.setTag(from);
    localViewUserId = from;
}