Search in sources :

Example 6 with SurfaceTextureListener

use of android.view.TextureView.SurfaceTextureListener in project android_packages_apps_Settings by LineageOS.

the class FingerprintLocationAnimationVideoViewTest method onSurfaceTextureAvailable_nullMediaPlayer_shouldNotCrash.

@Test
public void onSurfaceTextureAvailable_nullMediaPlayer_shouldNotCrash() {
    mView.onFinishInflate();
    final SurfaceTextureListener listener = mView.getSurfaceTextureListener();
    when(mView.createMediaPlayer(any(Context.class), any(Uri.class))).thenReturn(null);
    listener.onSurfaceTextureAvailable(mock(SurfaceTexture.class), 48, 48);
// should not crash
}
Also used : Context(android.content.Context) SurfaceTexture(android.graphics.SurfaceTexture) SurfaceTextureListener(android.view.TextureView.SurfaceTextureListener) Uri(android.net.Uri) Test(org.junit.Test)

Example 7 with SurfaceTextureListener

use of android.view.TextureView.SurfaceTextureListener in project android_packages_apps_Settings by omnirom.

the class FingerprintLocationAnimationVideoViewTest method onSurfaceTextureAvailable_nullMediaPlayer_shouldNotCrash.

@Test
public void onSurfaceTextureAvailable_nullMediaPlayer_shouldNotCrash() {
    mView.onFinishInflate();
    final SurfaceTextureListener listener = mView.getSurfaceTextureListener();
    when(mView.createMediaPlayer(any(Context.class), any(Uri.class))).thenReturn(null);
    listener.onSurfaceTextureAvailable(mock(SurfaceTexture.class), 48, 48);
// should not crash
}
Also used : Context(android.content.Context) SurfaceTexture(android.graphics.SurfaceTexture) SurfaceTextureListener(android.view.TextureView.SurfaceTextureListener) Uri(android.net.Uri) Test(org.junit.Test)

Example 8 with SurfaceTextureListener

use of android.view.TextureView.SurfaceTextureListener in project android_packages_apps_Settings by DirtyUnicorns.

the class FingerprintLocationAnimationVideoViewTest method onSurfaceTextureAvailable_nullMediaPlayer_shouldNotCrash.

@Test
public void onSurfaceTextureAvailable_nullMediaPlayer_shouldNotCrash() {
    mView.onFinishInflate();
    final SurfaceTextureListener listener = mView.getSurfaceTextureListener();
    when(mView.createMediaPlayer(any(Context.class), any(Uri.class))).thenReturn(null);
    listener.onSurfaceTextureAvailable(mock(SurfaceTexture.class), 48, 48);
// should not crash
}
Also used : Context(android.content.Context) SurfaceTexture(android.graphics.SurfaceTexture) SurfaceTextureListener(android.view.TextureView.SurfaceTextureListener) Uri(android.net.Uri) Test(org.junit.Test)

Example 9 with SurfaceTextureListener

use of android.view.TextureView.SurfaceTextureListener in project LanSoEditor_common by LanSoSdk.

the class VideoPlayerActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.player_layout);
    textureView = (TextureRenderView) findViewById(R.id.surface1);
    videoPath = getIntent().getStringExtra("videopath");
    TextView tvScreen = (TextView) findViewById(R.id.id_palyer_screenhinit);
    TextView tvVideoRatio = (TextView) findViewById(R.id.id_palyer_videoRatio);
    TextView tvVideoDuration = (TextView) findViewById(R.id.id_palyer_videoduration);
    tvSizeHint = (TextView) findViewById(R.id.id_palyer_videosizehint);
    // 获取屏幕密度(方法2)
    DisplayMetrics dm = new DisplayMetrics();
    dm = getResources().getDisplayMetrics();
    screenWidth = dm.widthPixels;
    screenHeight = dm.heightPixels;
    String str = "当前屏幕分辨率:";
    str += String.valueOf(screenWidth);
    str += "x";
    str += String.valueOf(screenHeight);
    tvScreen.setText(str);
    mInfo = new MediaInfo(videoPath, false);
    if (mInfo.prepare() == false) {
        showHintDialog();
        isSupport = false;
    } else {
        isSupport = true;
        str = "当前视频分辨率:";
        str += String.valueOf(mInfo.vWidth);
        str += "x";
        str += String.valueOf(mInfo.vHeight);
        tvVideoRatio.setText(str);
        str = "当前视频时长:";
        str += String.valueOf(mInfo.vDuration);
        str += "\n文件大小:" + new File(videoPath).length();
        tvVideoDuration.setText(str);
    }
    textureView.setSurfaceTextureListener(new SurfaceTextureListener() {

        @Override
        public void onSurfaceTextureUpdated(SurfaceTexture surface) {
        // TODO Auto-generated method stub
        }

        @Override
        public void onSurfaceTextureSizeChanged(SurfaceTexture surface, int width, int height) {
        // TODO Auto-generated method stub
        }

        @Override
        public boolean onSurfaceTextureDestroyed(SurfaceTexture surface) {
            // TODO Auto-generated method stub
            return false;
        }

        @Override
        public void onSurfaceTextureAvailable(SurfaceTexture surface, int width, int height) {
            // TODO Auto-generated method stub
            if (isSupport) {
                // play(new Surface(surface));
                startVPlayer(new Surface(surface));
            }
        }
    });
}
Also used : MediaInfo(com.lansosdk.videoeditor.MediaInfo) SurfaceTexture(android.graphics.SurfaceTexture) SurfaceTextureListener(android.view.TextureView.SurfaceTextureListener) TextView(android.widget.TextView) DisplayMetrics(android.util.DisplayMetrics) File(java.io.File) Surface(android.view.Surface)

Example 10 with SurfaceTextureListener

use of android.view.TextureView.SurfaceTextureListener in project platform_packages_apps_Settings by BlissRoms.

the class FingerprintLocationAnimationVideoViewTest method onSurfaceTextureAvailable_nullMediaPlayer_shouldNotCrash.

@Test
public void onSurfaceTextureAvailable_nullMediaPlayer_shouldNotCrash() {
    mView.onFinishInflate();
    final SurfaceTextureListener listener = mView.getSurfaceTextureListener();
    when(mView.createMediaPlayer(any(Context.class), any(Uri.class))).thenReturn(null);
    listener.onSurfaceTextureAvailable(mock(SurfaceTexture.class), 48, 48);
// should not crash
}
Also used : Context(android.content.Context) SurfaceTexture(android.graphics.SurfaceTexture) SurfaceTextureListener(android.view.TextureView.SurfaceTextureListener) Uri(android.net.Uri) Test(org.junit.Test)

Aggregations

SurfaceTexture (android.graphics.SurfaceTexture)10 SurfaceTextureListener (android.view.TextureView.SurfaceTextureListener)10 Context (android.content.Context)8 Uri (android.net.Uri)8 Test (org.junit.Test)8 DisplayMetrics (android.util.DisplayMetrics)2 Surface (android.view.Surface)2 TextView (android.widget.TextView)2 MediaInfo (com.lansosdk.videoeditor.MediaInfo)2 File (java.io.File)1