Color and transparency modification
By default, SurfaceViewRenderer for displaying video stream has black color, but it can be made transparent if necessary. To do this, the following modules should be imported:
Code Block |
---|
|
import android.graphics.PixelFormat; |
and setZOrderOnTop() and setFormat() methods should be used:
Code Block |
---|
|
localRender = (SurfaceViewRenderer) findViewById(R.id.local_video_view);
localRender.setZOrderOnTop(true);
localRender.getHolder().setFormat(PixelFormat.TRANSPARENT); |
To set SurfaceViewRenderer color, setBackgroundColor() method should be used:
Code Block |
---|
|
remoteRender = (SurfaceViewRenderer) findViewById(R.id.remote_video_view);
remoteRender.setZOrderOnTop(true);
remoteRender.getHolder().setFormat(PixelFormat.TRANSLUCENT);
remoteRender.setBackgroundColor(0xFFFF8800); //orange in RGB |
Last frame clearing
When stream playback is finished, last frame still displayed on SurfaceViewRenderer. This frame can be cleared if necessary, then surface will be filled black. To do this, the following modules should be imported:
Code Block |
---|
|
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.PixelFormat;
import android.graphics.PorterDuff; |
and release() method should be invoked:
Code Block |
---|
|
playStream.stop();
playStream = null;
remoteRender.release(); |
After this method invocation no futher operation with surface is possible.
Include Page |
---|
| ANDROIDSDK1EN:SurfaceViewRenderer management in Android application |
---|
| ANDROIDSDK1EN:SurfaceViewRenderer management in Android application |
---|
|