a
554325746@qq.com
2019-12-25 603cb36a5123e46656b06a5deb8d7ac7ff81307f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package com.basic.security.widget;
 
import android.content.Context;
import android.opengl.GLSurfaceView;
import android.util.AttributeSet;
import android.view.SurfaceHolder;
 
import com.basic.security.base.BaseApplication;
 
import java.io.File;
 
public class H264Player extends GLSurfaceView implements SurfaceHolder.Callback, Runnable {
    public H264Player(Context context) {
        super(context);
    }
 
    public H264Player(Context context, AttributeSet attrs) {
        super(context, attrs);
    }
 
    public void surfaceCreated(SurfaceHolder holder) {
        this.setVisibility(GONE);
    }
 
    public void surfaceDestroyed(SurfaceHolder holder) {
    }
 
    public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) {
    }
 
    public native void Open(String url, Object surface);
 
    public void run() {
        try {
            File file = new File("/sdcard/face2.mp4");
            if (file.exists()) {
                //        Open("rtsp://admin:a1234567@192.168.1.201:554/h264/ch1/main/av_stream", getHolder().getSurface());
                Open("/sdcard/face2.mp4", getHolder().getSurface());
            } else {
                BaseApplication.getApplication().activity.runOnUiThread(() -> H264Player.this.setVisibility(GONE));
            }
//        Open("rtmp://183.58.24.152/dreamStreamCore/qTl38me/lv800", getHolder().getSurface());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}