Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SurfaceHolder.setType is deprecated... But required?

void android.view.SurfaceHolder.setType(int type)

public abstract void setType (int type) Since: API Level 1

This method is deprecated. this is ignored, this value is set automatically when needed.

Sets the surface's type.

http://developer.android.com/reference/android/view/SurfaceHolder.html

It says it's set automatically but, without it my video doesn't play. What's going on here? Is there something that replaces it? I'm having a time getting video to play correctly on Android.

like image 532
bwoogie Avatar asked Feb 24 '12 22:02

bwoogie


1 Answers

The trick is in knowing when it was deprecated, which is kind of hard to determine from my experience. The documentation is always current for the latest API available, but you are probably not running this app on the latest API, if I had to guess. So you still have to use this method (typically with PUSH_BUFFERS) to make it work on older platforms.

EDIT: it was deprecated in Android 3.0, which the docs now reflect.
So we can use it like following:

if(Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB)
    getHolder().setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
like image 178
lyricsboy Avatar answered Oct 03 '22 05:10

lyricsboy