|
@@ -1,511 +0,0 @@
|
1
|
|
-package com.gnhz.clinic.eitc_erm_app.sightGlass;
|
2
|
|
-
|
3
|
|
-import android.Manifest;
|
4
|
|
-import android.annotation.SuppressLint;
|
5
|
|
-import android.content.Intent;
|
6
|
|
-import android.content.pm.PackageManager;
|
7
|
|
-import android.content.res.Configuration;
|
8
|
|
-import android.graphics.Bitmap;
|
9
|
|
-import android.os.Build;
|
10
|
|
-import android.os.Bundle;
|
11
|
|
-import android.os.Handler;
|
12
|
|
-import android.os.Message;
|
13
|
|
-import android.util.Log;
|
14
|
|
-import android.view.KeyEvent;
|
15
|
|
-import android.view.PixelCopy;
|
16
|
|
-import android.view.SurfaceHolder;
|
17
|
|
-import android.view.SurfaceView;
|
18
|
|
-import android.view.View;
|
19
|
|
-import android.view.WindowManager;
|
20
|
|
-import android.widget.Button;
|
21
|
|
-import android.widget.ImageButton;
|
22
|
|
-import android.widget.ImageView;
|
23
|
|
-import android.widget.ProgressBar;
|
24
|
|
-import android.widget.TextView;
|
25
|
|
-import android.widget.Toast;
|
26
|
|
-
|
27
|
|
-import androidx.annotation.NonNull;
|
28
|
|
-import androidx.appcompat.content.res.AppCompatResources;
|
29
|
|
-
|
30
|
|
-import com.github.chrisbanes.photoview.PhotoView;
|
31
|
|
-import com.gnhz.clinic.eitc_erm_app.BuildConfig;
|
32
|
|
-import com.gnhz.clinic.eitc_erm_app.MainActivity;
|
33
|
|
-import com.gnhz.clinic.eitc_erm_app.R;
|
34
|
|
-
|
35
|
|
-import java.util.Timer;
|
36
|
|
-import java.util.TimerTask;
|
37
|
|
-
|
38
|
|
-public class VideoSDK extends com.example.eitc_erm_app.sightGlass.BaseActivity {
|
39
|
|
- public Video videoDecoder;
|
40
|
|
- public SurfaceView mSurfaceView;
|
41
|
|
- private ProgressBar progressBar;
|
42
|
|
- private PhotoView clickView;
|
43
|
|
- private ImageView getImage;
|
44
|
|
- public Button deleteChecked;
|
45
|
|
- public Button checkAll;
|
46
|
|
- public Button cancelAll;
|
47
|
|
- private TextView textView;
|
48
|
|
- private ImageView restart;
|
49
|
|
- private Button recordButton;
|
50
|
|
-
|
51
|
|
- private DecodeUtil decodeUtil;
|
52
|
|
- private TextView sdkversion;
|
53
|
|
- private TextView devversion;
|
54
|
|
- private Button videobuttonStop;
|
55
|
|
- public static int fpsCount = 0;
|
56
|
|
- private Timer t = null;
|
57
|
|
- private final Handler handler = new Handler(new Handler.Callback() {
|
58
|
|
- @Override
|
59
|
|
- public boolean handleMessage(@NonNull Message msg) {
|
60
|
|
- if (msg.what == 1) {
|
61
|
|
- showButton();
|
62
|
|
- }
|
63
|
|
- if (msg.what == 2) {
|
64
|
|
- hideButton();
|
65
|
|
- }
|
66
|
|
- if (msg.what == 3) {
|
67
|
|
- hideProgress();
|
68
|
|
- if (videoDecoder != null && MyXUtil.h264PlayFlag) {
|
69
|
|
- hideRestart();
|
70
|
|
-// PopTip.show("打开视频成功!").iconSuccess();
|
71
|
|
- Toast.makeText(VideoSDK.this, "打开视频成功!", Toast.LENGTH_SHORT).show();
|
72
|
|
- /* camera temp = camera.getInstance();
|
73
|
|
- byte[] ver = new byte[32];
|
74
|
|
- if (temp.getDevVersion(ver) == 0) {
|
75
|
|
- //获取成功,例如:20200923_V10.8_sh999
|
76
|
|
- devversion.setText(new String(ver).trim());
|
77
|
|
- } else {
|
78
|
|
- Log.e(TAG, "handleMessage: wtf,获取版本号失败!");
|
79
|
|
- }
|
80
|
|
- textView.setText("::" + MyXUtil.nowPort);*/
|
81
|
|
- if (!MyXUtil.ketThreadFlag) {
|
82
|
|
- ThreadPoolHelper.executeTask(() -> videoDecoder.StartKeyScanThread());
|
83
|
|
- }
|
84
|
|
- videobuttonStop.setText("停止");
|
85
|
|
- // videobuttonStop.setCompoundDrawables(ResourcesCompat.getDrawable(Resources.getSystem(), R.drawable.stop, null), null, null, null);
|
86
|
|
- videobuttonStop.setCompoundDrawablesWithIntrinsicBounds(AppCompatResources.getDrawable(VideoSDK.this, R.drawable.stop), null, null, null);
|
87
|
|
-
|
88
|
|
- } else {
|
89
|
|
- showRestart();
|
90
|
|
- closeAllSocket();
|
91
|
|
- // TastyToast.makeText(videoSdkTemp, "当前网络没有找到设备", TastyToast.LENGTH_SHORT, TastyToast.ERROR);
|
92
|
|
-// PopTip.show("当前网路没有找到设备!").iconError();
|
93
|
|
- Toast.makeText(VideoSDK.this, "当前网路没有找到设备!", Toast.LENGTH_SHORT).show();
|
94
|
|
- }
|
95
|
|
- }
|
96
|
|
- if (msg.what == 4) {
|
97
|
|
- screenshot(mSurfaceView, 1920, 1080);
|
98
|
|
- Log.e("iMVR", "============msg.what==4=================");
|
99
|
|
- }
|
100
|
|
- if (msg.what == 5) {
|
101
|
|
- hideRestart();
|
102
|
|
- showProgress();
|
103
|
|
- ThreadPoolHelper.executeTask(() -> {
|
104
|
|
- Log.e(TAG, "onCreate: 开始视频。。。。。");
|
105
|
|
- videoDecoder.startVideoDecode();
|
106
|
|
- });
|
107
|
|
- }
|
108
|
|
- if (msg.what == 6) {
|
109
|
|
-// PopTip.show("已经存在视屏流!").iconError();
|
110
|
|
- Toast.makeText(VideoSDK.this, "已经存在视屏流!", Toast.LENGTH_SHORT).show();
|
111
|
|
- }
|
112
|
|
- if (msg.what == 7) {
|
113
|
|
- //发送心跳包失败
|
114
|
|
- startOrStopVideo();
|
115
|
|
- }
|
116
|
|
- if (msg.what == 8) {
|
117
|
|
- //wtf?
|
118
|
|
- }
|
119
|
|
- if (msg.what == 9) {
|
120
|
|
- // TastyToast.makeText(videoSdkTemp, "socket连接失败!", TastyToast.LENGTH_SHORT, TastyToast.ERROR);
|
121
|
|
-// PopTip.show("当前网络查找视频失败!").iconError();
|
122
|
|
- Toast.makeText(VideoSDK.this, "当前网络查找视频失败!", Toast.LENGTH_SHORT).show();
|
123
|
|
- }
|
124
|
|
- if (msg.what == 20) {
|
125
|
|
-// PopTip.show("←👈👈👈按键左").iconSuccess();
|
126
|
|
- Toast.makeText(VideoSDK.this, "按键左!", Toast.LENGTH_SHORT).show();
|
127
|
|
- }
|
128
|
|
- if (msg.what == 21) {
|
129
|
|
-// PopTip.show("按键右👉👉👉→").iconSuccess();
|
130
|
|
- Toast.makeText(VideoSDK.this, "按键右!", Toast.LENGTH_SHORT).show();
|
131
|
|
- }
|
132
|
|
- if (msg.what == 22) {
|
133
|
|
-// PopTip.show("按键下👇👇👇↓").iconSuccess();
|
134
|
|
- Toast.makeText(VideoSDK.this, "按键下!", Toast.LENGTH_SHORT).show();
|
135
|
|
- }
|
136
|
|
- if (msg.what == 23) {
|
137
|
|
-// PopTip.show("重置为AP模式,并自动关机!(*Φ皿Φ*)").iconSuccess();
|
138
|
|
- Toast.makeText(VideoSDK.this, "重置为AP模式,并自动关机!", Toast.LENGTH_SHORT).show();
|
139
|
|
- }
|
140
|
|
- if (msg.what == 24) {
|
141
|
|
- // sdkversion.setText("Ver::" + BuildConfig.VERSION_NAME + BuildConfig.VERSION_CODE);
|
142
|
|
- sdkversion.setText("FPS : " + fpsCount);
|
143
|
|
- fpsCount = 0;
|
144
|
|
- }
|
145
|
|
- return false;
|
146
|
|
- }
|
147
|
|
- });
|
148
|
|
-
|
149
|
|
-
|
150
|
|
- @SuppressLint("SetTextI18n")
|
151
|
|
- @Override
|
152
|
|
- public void onCreate(Bundle savedInstanceState) {
|
153
|
|
- super.onCreate(savedInstanceState);
|
154
|
|
- this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
155
|
|
- setContentView(R.layout.videosdk_activity);
|
156
|
|
- initFindID();
|
157
|
|
- hideButton();
|
158
|
|
- initSurface();
|
159
|
|
- showProgress();
|
160
|
|
- sdkversion.setText("Ver::" + BuildConfig.VERSION_NAME + BuildConfig.VERSION_CODE);
|
161
|
|
-// TcpSender.SetDeviceType(0);
|
162
|
|
- calcuteFPS();
|
163
|
|
- }
|
164
|
|
-
|
165
|
|
- private void calcuteFPS() {
|
166
|
|
- if (t == null) {
|
167
|
|
- t = new Timer();
|
168
|
|
- }
|
169
|
|
- t.scheduleAtFixedRate(new TimerTask() {
|
170
|
|
- @Override
|
171
|
|
- public void run() {
|
172
|
|
- // System.out.println("hello world");
|
173
|
|
- // Log.e(TAG, "run: " + fpsCount);
|
174
|
|
- if (MyXUtil.h264PlayFlag) {
|
175
|
|
- handler.sendEmptyMessage(24);
|
176
|
|
- }
|
177
|
|
- }
|
178
|
|
- }, 100, 1000);
|
179
|
|
- }
|
180
|
|
-
|
181
|
|
-
|
182
|
|
- Bitmap mScreenBitmap = null;
|
183
|
|
-
|
184
|
|
- public void screenshot(SurfaceView view, int outWidth, int outHeight) {
|
185
|
|
- mScreenBitmap = Bitmap.createBitmap(outWidth, outHeight, Bitmap.Config.ARGB_8888);
|
186
|
|
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
187
|
|
- PixelCopy.request(view, mScreenBitmap, new PixelCopy.OnPixelCopyFinishedListener() {
|
188
|
|
- @Override
|
189
|
|
- public void onPixelCopyFinished(int copyResult) {
|
190
|
|
- if (PixelCopy.SUCCESS == copyResult) {
|
191
|
|
- //获取成功
|
192
|
|
- getImage.setImageBitmap(mScreenBitmap);
|
193
|
|
- } else {
|
194
|
|
-// PopTip.show("copy error,抓拍失败!").iconError();
|
195
|
|
- Toast.makeText(VideoSDK.this, "copy error,抓拍失败!", Toast.LENGTH_SHORT).show();
|
196
|
|
- }
|
197
|
|
- }
|
198
|
|
- }, handler);
|
199
|
|
- } else {
|
200
|
|
-// PopTip.show("安卓版本太低,抓拍失败!").iconWarning();
|
201
|
|
- Toast.makeText(VideoSDK.this, "安卓版本太低,抓拍失败!", Toast.LENGTH_SHORT).show();
|
202
|
|
- }
|
203
|
|
- }
|
204
|
|
-
|
205
|
|
-
|
206
|
|
- class MyClickListenner implements View.OnClickListener {
|
207
|
|
- @Override
|
208
|
|
- public void onClick(View v) {
|
209
|
|
- if (v.getId() == R.id.checkAll) {
|
210
|
|
-
|
211
|
|
- }
|
212
|
|
- if (v.getId() == R.id.cancelAll) {
|
213
|
|
-
|
214
|
|
- }
|
215
|
|
- if (v.getId() == R.id.deleteChecked) {
|
216
|
|
-
|
217
|
|
- }
|
218
|
|
- if (v.getId() == R.id.face_recordbtn) {
|
219
|
|
- //record
|
220
|
|
- if (decodeUtil != null) {
|
221
|
|
- if (!DecodeUtil.recordMp4Flag) {
|
222
|
|
- decodeUtil.initRecordMp4(MyXUtil.getSdPath() + "test.mp4", 1920, 1080);
|
223
|
|
- runOnUiThread(new Runnable() {
|
224
|
|
- @Override
|
225
|
|
- public void run() {
|
226
|
|
- recordButton.setText("recording.....");
|
227
|
|
- }
|
228
|
|
- });
|
229
|
|
- } else {
|
230
|
|
- decodeUtil.stopRecordMp4();
|
231
|
|
- runOnUiThread(new Runnable() {
|
232
|
|
- @Override
|
233
|
|
- public void run() {
|
234
|
|
- recordButton.setText("record");
|
235
|
|
- }
|
236
|
|
- });
|
237
|
|
- }
|
238
|
|
- }
|
239
|
|
- }
|
240
|
|
-
|
241
|
|
- if (v.getId() == R.id.toMain) {
|
242
|
|
- closeAllSocket();
|
243
|
|
- startActivity(new Intent(VideoSDK.this, MainActivity.class));
|
244
|
|
- finish();
|
245
|
|
- }
|
246
|
|
- if (v.getId() == R.id.clickView) {
|
247
|
|
- clickView.setImageDrawable(null);
|
248
|
|
- clickView.setVisibility(View.GONE);
|
249
|
|
- }
|
250
|
|
-
|
251
|
|
- if (v.getId() == R.id.restart) {
|
252
|
|
- if (videoDecoder == null) {
|
253
|
|
- if (decodeUtil == null) {
|
254
|
|
- decodeUtil = new DecodeUtil(mSurfaceView.getHolder().getSurface());
|
255
|
|
- decodeUtil.StartCodec();
|
256
|
|
- }
|
257
|
|
- videoDecoder = new Video(handler, decodeUtil);
|
258
|
|
- handler.sendEmptyMessage(5);
|
259
|
|
- } else {
|
260
|
|
- handler.sendEmptyMessage(5);
|
261
|
|
- }
|
262
|
|
- }
|
263
|
|
-
|
264
|
|
- if (v.getId() == R.id.face_stopbtn) {
|
265
|
|
- startOrStopVideo();
|
266
|
|
- }
|
267
|
|
- if (v.getId() == R.id.face_capturebtn) {
|
268
|
|
- //手动抓图
|
269
|
|
- // Video.captureStill = true;
|
270
|
|
- handler.sendEmptyMessage(4);
|
271
|
|
- }
|
272
|
|
- if (v.getId() == R.id.getImage) {
|
273
|
|
- runOnUiThread(new Runnable() {
|
274
|
|
- @Override
|
275
|
|
- public void run() {
|
276
|
|
- if (clickView.getVisibility() != View.VISIBLE) {
|
277
|
|
- clickView.setVisibility(View.VISIBLE);
|
278
|
|
- clickView.setImageDrawable(getImage.getDrawable());
|
279
|
|
- } else {
|
280
|
|
- clickView.setImageDrawable(null);
|
281
|
|
- clickView.setVisibility(View.GONE);
|
282
|
|
- }
|
283
|
|
- }
|
284
|
|
- });
|
285
|
|
- }
|
286
|
|
- }
|
287
|
|
- }
|
288
|
|
-
|
289
|
|
- private void startOrStopVideo() {
|
290
|
|
- if (MyXUtil.h264PlayFlag) {
|
291
|
|
- MyXUtil.h264PlayFlag = false;
|
292
|
|
- if (videoDecoder != null) {
|
293
|
|
- closeAllSocket();
|
294
|
|
- showRestart();
|
295
|
|
- Log.e(TAG, "onCreate: 停止解码");
|
296
|
|
- }
|
297
|
|
- } else {
|
298
|
|
- if (videoDecoder == null) {
|
299
|
|
- if (decodeUtil == null) {
|
300
|
|
- decodeUtil = new DecodeUtil(mSurfaceView.getHolder().getSurface());
|
301
|
|
- decodeUtil.StartCodec();
|
302
|
|
- }
|
303
|
|
- videoDecoder = new Video(handler, decodeUtil);
|
304
|
|
- handler.sendEmptyMessage(5);
|
305
|
|
- } else {
|
306
|
|
- handler.sendEmptyMessage(5);
|
307
|
|
- }
|
308
|
|
- }
|
309
|
|
- }
|
310
|
|
-
|
311
|
|
-
|
312
|
|
- private void closeAllSocket() {
|
313
|
|
- MyXUtil.h264PlayFlag = false;
|
314
|
|
- if (videoDecoder != null) {
|
315
|
|
- videoDecoder.closeSocket();
|
316
|
|
- }
|
317
|
|
- }
|
318
|
|
-
|
319
|
|
- //初始化播放相关
|
320
|
|
- private void initSurface() {
|
321
|
|
- mSurfaceView.getHolder().addCallback(new SurfaceHolder.Callback2() {
|
322
|
|
- @Override
|
323
|
|
- public void surfaceRedrawNeeded(@NonNull SurfaceHolder holder) {
|
324
|
|
-
|
325
|
|
- }
|
326
|
|
-
|
327
|
|
- @Override
|
328
|
|
- public void surfaceCreated(@NonNull SurfaceHolder holder) {
|
329
|
|
- if (decodeUtil == null) {
|
330
|
|
- decodeUtil = new DecodeUtil(holder.getSurface());
|
331
|
|
- }
|
332
|
|
- if (videoDecoder == null) {
|
333
|
|
- videoDecoder = new Video(handler, decodeUtil);
|
334
|
|
- }
|
335
|
|
- decodeUtil.StartCodec();
|
336
|
|
- handler.sendEmptyMessage(5);
|
337
|
|
- }
|
338
|
|
-
|
339
|
|
- @Override
|
340
|
|
- public void surfaceChanged(@NonNull SurfaceHolder holder, int format, int width, int height) {
|
341
|
|
-
|
342
|
|
- }
|
343
|
|
-
|
344
|
|
- @Override
|
345
|
|
- public void surfaceDestroyed(@NonNull SurfaceHolder holder) {
|
346
|
|
- MyXUtil.h264PlayFlag = false;
|
347
|
|
- if (videoDecoder != null) {
|
348
|
|
- closeAllSocket();
|
349
|
|
- runOnUiThread(new Runnable() {
|
350
|
|
- @Override
|
351
|
|
- public void run() {
|
352
|
|
- showRestart();
|
353
|
|
- }
|
354
|
|
- });
|
355
|
|
- Log.e(TAG, "onCreate: 停止解码");
|
356
|
|
- }
|
357
|
|
- if (decodeUtil != null) {
|
358
|
|
- decodeUtil.StopCodec();
|
359
|
|
- }
|
360
|
|
- }
|
361
|
|
- });
|
362
|
|
- }
|
363
|
|
-
|
364
|
|
-
|
365
|
|
- private void initFindID() {
|
366
|
|
- MyClickListenner myClickListenner = new MyClickListenner();
|
367
|
|
- mSurfaceView = findViewById(R.id.surfaceView1);
|
368
|
|
- mSurfaceView.setFocusable(true);
|
369
|
|
- mSurfaceView.setFocusableInTouchMode(true);
|
370
|
|
- Button videobuttonCapture = findViewById(R.id.face_capturebtn);
|
371
|
|
- videobuttonCapture.setOnClickListener(myClickListenner);
|
372
|
|
- ImageButton toMain = findViewById(R.id.toMain);
|
373
|
|
- toMain.setOnClickListener(myClickListenner);
|
374
|
|
- videobuttonStop = findViewById(R.id.face_stopbtn);
|
375
|
|
- videobuttonStop.setOnClickListener(myClickListenner);
|
376
|
|
- textView = findViewById(R.id.showByteArr);
|
377
|
|
- clickView = findViewById(R.id.clickView);
|
378
|
|
- clickView.setOnClickListener(myClickListenner);
|
379
|
|
- progressBar = findViewById(R.id.progressStartVideo);
|
380
|
|
- deleteChecked = findViewById(R.id.deleteChecked);
|
381
|
|
- deleteChecked.setOnClickListener(myClickListenner);
|
382
|
|
- checkAll = findViewById(R.id.checkAll);
|
383
|
|
- checkAll.setOnClickListener(myClickListenner);
|
384
|
|
- cancelAll = findViewById(R.id.cancelAll);
|
385
|
|
- cancelAll.setOnClickListener(myClickListenner);
|
386
|
|
- restart = findViewById(R.id.restart);
|
387
|
|
- restart.setOnClickListener(myClickListenner);
|
388
|
|
- getImage = findViewById(R.id.getImage);
|
389
|
|
- getImage.setOnClickListener(myClickListenner);
|
390
|
|
- recordButton = findViewById(R.id.face_recordbtn);
|
391
|
|
- recordButton.setOnClickListener(myClickListenner);
|
392
|
|
- sdkversion = findViewById(R.id.sdkversion);
|
393
|
|
- devversion = findViewById(R.id.devversion);
|
394
|
|
- hideRestart();
|
395
|
|
- }
|
396
|
|
-
|
397
|
|
- private void showRestart() {
|
398
|
|
- restart.setVisibility(View.VISIBLE);
|
399
|
|
- videobuttonStop.setText("开启");
|
400
|
|
- videobuttonStop.setCompoundDrawablesWithIntrinsicBounds(AppCompatResources.getDrawable(this, R.drawable.start_video), null, null, null);
|
401
|
|
- }
|
402
|
|
-
|
403
|
|
- private void hideRestart() {
|
404
|
|
- restart.setVisibility(View.INVISIBLE);
|
405
|
|
- }
|
406
|
|
-
|
407
|
|
- private void showProgress() {
|
408
|
|
- progressBar.setVisibility(View.VISIBLE);
|
409
|
|
- }
|
410
|
|
-
|
411
|
|
- private void hideProgress() {
|
412
|
|
- progressBar.setVisibility(View.INVISIBLE);
|
413
|
|
- }
|
414
|
|
-
|
415
|
|
- private void showButton() {
|
416
|
|
- cancelAll.setVisibility(View.VISIBLE);
|
417
|
|
- checkAll.setVisibility(View.VISIBLE);
|
418
|
|
- deleteChecked.setVisibility(View.VISIBLE);
|
419
|
|
- }
|
420
|
|
-
|
421
|
|
- private void hideButton() {
|
422
|
|
- cancelAll.setVisibility(View.INVISIBLE);
|
423
|
|
- checkAll.setVisibility(View.INVISIBLE);
|
424
|
|
- deleteChecked.setVisibility(View.INVISIBLE);
|
425
|
|
- }
|
426
|
|
-
|
427
|
|
- //在大于23的android版本中,文件读写需要动态申请权限
|
428
|
|
- private void verifyStoragePermissions() {
|
429
|
|
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
430
|
|
- if ((this.checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) || (this.checkSelfPermission(Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED)) {
|
431
|
|
- this.requestPermissions(new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.READ_EXTERNAL_STORAGE}, 1);
|
432
|
|
- } else {
|
433
|
|
- Log.d(TAG, "已有权限,不需要再申请");
|
434
|
|
- // mHandler.sendEmptyMessage(MyHandler.PERMISSION_ALLOW);
|
435
|
|
- }
|
436
|
|
- } else {
|
437
|
|
- // mHandler.sendEmptyMessage(MyHandler.PERMISSION_ALLOW);
|
438
|
|
- }
|
439
|
|
- }
|
440
|
|
-
|
441
|
|
- @Override
|
442
|
|
- public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
|
443
|
|
- super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
444
|
|
- switch (requestCode) {
|
445
|
|
- case 0x01: //动态申请的读写权限
|
446
|
|
- if ((grantResults.length > 0) && (grantResults[0] == PackageManager.PERMISSION_GRANTED)) {
|
447
|
|
- // mHandler.sendEmptyMessage(PERMISSION_ALLOW);
|
448
|
|
- } else {
|
449
|
|
- // Toast.makeText(this, "用户没有同意文件读取权限!", Toast.LENGTH_LONG).show();
|
450
|
|
-// PopTip.show("用户没有同意文件读取权限").iconError();
|
451
|
|
- Toast.makeText(VideoSDK.this, "用户没有同意文件读取权限!", Toast.LENGTH_SHORT).show();
|
452
|
|
- }
|
453
|
|
- break;
|
454
|
|
- default:
|
455
|
|
- break;
|
456
|
|
- }
|
457
|
|
- }
|
458
|
|
-
|
459
|
|
- @Override
|
460
|
|
- protected void onUserLeaveHint() {
|
461
|
|
- //运用放到了后台
|
462
|
|
- super.onUserLeaveHint();
|
463
|
|
- }
|
464
|
|
-
|
465
|
|
- @Override
|
466
|
|
- public void onConfigurationChanged(Configuration newConfig) {
|
467
|
|
- super.onConfigurationChanged(newConfig);
|
468
|
|
- }
|
469
|
|
-
|
470
|
|
- @Override
|
471
|
|
- public boolean onKeyDown(int keyCode, KeyEvent event) {
|
472
|
|
- if (keyCode == KeyEvent.KEYCODE_BACK || keyCode == KeyEvent.KEYCODE_HOME) {
|
473
|
|
- closeAllSocket();
|
474
|
|
- Intent intent = new Intent();
|
475
|
|
- intent.setClass(VideoSDK.this, MainActivity.class);
|
476
|
|
- startActivity(intent);
|
477
|
|
- finish();
|
478
|
|
- }
|
479
|
|
- return super.onKeyDown(keyCode, event);
|
480
|
|
- }
|
481
|
|
-
|
482
|
|
- @Override
|
483
|
|
- protected void onResume() {
|
484
|
|
- Log.e(TAG, "onResume: ------");
|
485
|
|
- super.onResume();
|
486
|
|
- /* if (restart.getVisibility() == View.VISIBLE) {
|
487
|
|
- if (!MyXUtil.h264PlayFlag) {
|
488
|
|
- Log.e(TAG, "onResume: 重新回到界面,尝试重新开启视频********");
|
489
|
|
- handler.sendEmptyMessage(5);
|
490
|
|
- }
|
491
|
|
- }*/
|
492
|
|
- }
|
493
|
|
-
|
494
|
|
- @Override
|
495
|
|
- protected void onDestroy() {
|
496
|
|
- closeAllSocket();
|
497
|
|
- if (videoDecoder != null) {
|
498
|
|
- videoDecoder = null;
|
499
|
|
- }
|
500
|
|
- if (decodeUtil != null) {
|
501
|
|
- decodeUtil.StopCodec();
|
502
|
|
- decodeUtil = null;
|
503
|
|
- }
|
504
|
|
- MyXUtil.ketThreadFlag = false;
|
505
|
|
- ServerSocketUtil.closeServerSocket();
|
506
|
|
- if (t != null) {
|
507
|
|
- t.cancel();
|
508
|
|
- }
|
509
|
|
- super.onDestroy();
|
510
|
|
- }
|
511
|
|
-}
|