I plan to implement a feature playing several videos in one screen simultaneously and video views can be scrolled while they are playing videos.
I am going to add video views to a ListView which acts as their parent view. We should not use SurfaceView to render the video stream, because SurfaceView can not be redrawed by android view hierarchy. It is a bad idea to scroll SurfaceView.
Fortunately, TextureView was added since API level 14, it was a replacer of SurfaceView. So I can use it to achieve my plan.
But TextureView is available only above API level 14. In fact, I was demanded to implement this feature in a platform which is not lower than API level 11.
I start to pay attention to SurfaceTexture which was added to android since API level 11, We can use SurfaceTexture to either put the camera image stream or video decoded stream onto an OpenGL texture, I also know that android view hierarchy is drawed by opengl instead of skia since api level 11.
So I wonder if I can render the video stream onto a ordinary android view using SurfaceTexture.
In other words, can we implement a customized widget for api level 11-13 to replace the position of TextureView added since api level 14?
I have looked into the source code of android.view.TextureView,it is not very complicated, the dependence classes are as follow:
package android.view;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.Rect;
import android.graphics.SurfaceTexture;
import android.os.Looper;
import android.util.AttributeSet;
import android.util.Log;
And there are 4 native apis:
private native void nCreateNativeWindow(SurfaceTexture surface);
private native void nDestroyNativeWindow();
private static native boolean nLockCanvas(int nativeWindow, Canvas canvas, Rect dirty);
private static native void nUnlockCanvasAndPost(int nativeWindow, Canvas canvas);
Is it possible to transplant the class TextureView to android api level 11-13?
Who can give me some advices?
You should try surfaceView it could be solved your issue.
If you can't handle that edit your question with your source code.
I can't give you a definitive answer, but I doubt it's something you can just drop into your app. It might be possible with reflective access to private APIs.
I can't see how this would be worthwhile. If you look at the version dashboard you'll see that Gingerbread and earlier accounts for about 5.9% of active devices (as of July 7 2015), so even if you made it work with API 10 you would only be increasing your market share by a few percent. The hardware-accelerated View features were introduced in API 11, so I expect making TextureView work in API 10 would be even more of a challenge. API 11 isn't even called out in the dashboard -- AFAIK the few devices that got Honeycomb were all eligible for upgrades to ICS.
(Which specific devices are you hoping to support with API 11 vs. API 14? There's just not that many un-upgraded Motorola Xooms out there. Do you have an API 11 device to test with?)
Making things even more complicated is the lack of API 11 source code. Honeycomb's sources were never released. So you'll be doing a lot of fumbling in the dark trying to get it to work.
I think your best option is to push back on whoever is making the request.