문제

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.

도움이 되었습니까?

해결책

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);
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top