-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVideoDisplayEventHandler.java
More file actions
66 lines (55 loc) · 2.06 KB
/
Copy pathVideoDisplayEventHandler.java
File metadata and controls
66 lines (55 loc) · 2.06 KB
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package com.ken.smartguard.video_stream.video_player;
import android.util.Log;
import android.view.SurfaceHolder;
public class VideoDisplayEventHandler implements SurfaceHolder.Callback
{
private final static String DEBUG_TAG = "Ken-Surface";
private final int initialHeight;
private final OnSurfaceCreatedCallback onSurfaceCreatedCallback;
private final OnSurfaceDestroyedCallback onSurfaceDestroyedCallback;
/**
*
* @param initialHeight -1 = original height of the display
* @param onSurfaceCreatedCallback
* @param onSurfaceDestroyedCallback
*/
/* default */ VideoDisplayEventHandler( int initialHeight, OnSurfaceCreatedCallback onSurfaceCreatedCallback, OnSurfaceDestroyedCallback onSurfaceDestroyedCallback)
{
this.initialHeight = initialHeight;
this.onSurfaceCreatedCallback = onSurfaceCreatedCallback;
this.onSurfaceDestroyedCallback = onSurfaceDestroyedCallback;
}
@Override
public void surfaceCreated(SurfaceHolder holder)
{
Log.d(DEBUG_TAG, "Surface created. Width: " + holder.getSurfaceFrame().width() + ", Height: " + holder.getSurfaceFrame().height());
final int height;
if(initialHeight == -1)
height = holder.getSurfaceFrame().height();
else
height = initialHeight;
//holder.setFixedSize(holder.getSurfaceFrame().width(), height);
onSurfaceCreatedCallback.accept(holder);
}
@Override
public void surfaceChanged(SurfaceHolder holder, int format, int width, int height)
{
Log.d(DEBUG_TAG, "Surface changed. New width: " + width + " New height: " + height);
}
@Override
public void surfaceDestroyed(SurfaceHolder holder)
{
Log.d(DEBUG_TAG, "Surface destroyed.");
onSurfaceDestroyedCallback.accept(holder);
}
@FunctionalInterface
public interface OnSurfaceCreatedCallback
{
void accept(SurfaceHolder holder);
}
@FunctionalInterface
public interface OnSurfaceDestroyedCallback
{
void accept(SurfaceHolder holder);
}
}