@byteplus/react-native-live-push 1.0.3-rc.1 → 1.1.1-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,34 +1,107 @@
|
|
|
1
1
|
package com.volcengine.velive.rn.push;
|
|
2
2
|
|
|
3
|
-
import android.
|
|
3
|
+
import android.graphics.SurfaceTexture;
|
|
4
4
|
import android.util.Log;
|
|
5
|
+
import android.view.SurfaceHolder;
|
|
5
6
|
import android.view.SurfaceView;
|
|
7
|
+
import android.view.TextureView;
|
|
6
8
|
import android.view.View;
|
|
7
9
|
import android.widget.FrameLayout;
|
|
8
|
-
|
|
10
|
+
import androidx.annotation.NonNull;
|
|
9
11
|
import com.facebook.react.bridge.Arguments;
|
|
10
12
|
import com.facebook.react.bridge.ReactContext;
|
|
11
13
|
import com.facebook.react.bridge.WritableMap;
|
|
14
|
+
import com.facebook.react.uimanager.ThemedReactContext;
|
|
12
15
|
import com.facebook.react.uimanager.events.RCTEventEmitter;
|
|
16
|
+
import com.volcengine.VolcApiEngine.view.VolcViewManager;
|
|
13
17
|
|
|
14
18
|
public class VeLivePushView extends FrameLayout {
|
|
15
19
|
public String viewId;
|
|
20
|
+
public String viewKind;
|
|
16
21
|
public boolean hasRegister = false;
|
|
17
|
-
|
|
18
|
-
|
|
22
|
+
private final ThemedReactContext themedReactContext;
|
|
23
|
+
private boolean hasLoad = false;
|
|
24
|
+
private View subview;
|
|
25
|
+
|
|
26
|
+
public VeLivePushView(ThemedReactContext context) {
|
|
19
27
|
super(context);
|
|
28
|
+
this.themedReactContext = context;
|
|
20
29
|
}
|
|
21
|
-
|
|
30
|
+
|
|
22
31
|
public void setViewId(String viewId) {
|
|
23
|
-
this.viewId = viewId;
|
|
32
|
+
this.viewId = viewId;
|
|
24
33
|
this.hasRegister = true;
|
|
25
34
|
this.emitOnLoad();
|
|
26
35
|
}
|
|
27
|
-
|
|
36
|
+
|
|
37
|
+
public void setViewKind(String viewKind) {
|
|
38
|
+
this.viewKind = viewKind;
|
|
39
|
+
switch (viewKind) {
|
|
40
|
+
case "SurfaceView":
|
|
41
|
+
SurfaceView surfaceView =
|
|
42
|
+
new SurfaceView(themedReactContext.getReactApplicationContext());
|
|
43
|
+
surfaceView.getHolder().addCallback(new SurfaceHolder.Callback() {
|
|
44
|
+
@Override
|
|
45
|
+
public void surfaceCreated(@NonNull SurfaceHolder holder) {
|
|
46
|
+
hasLoad = true;
|
|
47
|
+
subview = surfaceView;
|
|
48
|
+
VolcViewManager.putViewById(viewId, subview);
|
|
49
|
+
emitOnLoad();
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
@Override
|
|
53
|
+
public void surfaceChanged(@NonNull SurfaceHolder holder, int format,
|
|
54
|
+
int width, int height) {}
|
|
55
|
+
|
|
56
|
+
@Override
|
|
57
|
+
public void surfaceDestroyed(@NonNull SurfaceHolder holder) {}
|
|
58
|
+
});
|
|
59
|
+
this.addView(surfaceView);
|
|
60
|
+
break;
|
|
61
|
+
case "TextureView":
|
|
62
|
+
TextureView textureView =
|
|
63
|
+
new TextureView(themedReactContext.getReactApplicationContext());
|
|
64
|
+
subview = textureView;
|
|
65
|
+
textureView.setSurfaceTextureListener(
|
|
66
|
+
new TextureView.SurfaceTextureListener() {
|
|
67
|
+
@Override
|
|
68
|
+
public void onSurfaceTextureAvailable(SurfaceTexture surfaceTexture,
|
|
69
|
+
int width, int height) {
|
|
70
|
+
hasLoad = true;
|
|
71
|
+
VolcViewManager.putViewById(viewId, subview);
|
|
72
|
+
emitOnLoad();
|
|
73
|
+
}
|
|
74
|
+
@Override
|
|
75
|
+
public void onSurfaceTextureSizeChanged(
|
|
76
|
+
SurfaceTexture surfaceTexture, int width, int height) {}
|
|
77
|
+
@Override
|
|
78
|
+
public boolean onSurfaceTextureDestroyed(
|
|
79
|
+
SurfaceTexture surfaceTexture) {
|
|
80
|
+
return true;
|
|
81
|
+
}
|
|
82
|
+
@Override
|
|
83
|
+
public void onSurfaceTextureUpdated(SurfaceTexture surfaceTexture) {
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
this.addView(textureView);
|
|
87
|
+
break;
|
|
88
|
+
default:
|
|
89
|
+
break;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
public void resetSurface() {
|
|
94
|
+
if (subview instanceof SurfaceView) {
|
|
95
|
+
SurfaceView surface = (SurfaceView)subview;
|
|
96
|
+
removeView(surface);
|
|
97
|
+
addView(surface);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
28
101
|
public void setVisible(Boolean visible) {
|
|
29
102
|
Log.i("surfaceView", "setVisible");
|
|
30
103
|
View subview = this.getChildAt(0);
|
|
31
|
-
if(visible) {
|
|
104
|
+
if (visible) {
|
|
32
105
|
subview.setVisibility(View.VISIBLE);
|
|
33
106
|
} else {
|
|
34
107
|
subview.setVisibility(View.INVISIBLE);
|
|
@@ -36,10 +109,12 @@ public class VeLivePushView extends FrameLayout {
|
|
|
36
109
|
}
|
|
37
110
|
|
|
38
111
|
public void emitOnLoad() {
|
|
112
|
+
if (hasLoad) {
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
39
115
|
WritableMap event = Arguments.createMap();
|
|
40
116
|
ReactContext reactContext = (ReactContext)getContext();
|
|
41
|
-
reactContext
|
|
42
|
-
|
|
43
|
-
.receiveEvent(getId(), "load", event);
|
|
117
|
+
reactContext.getJSModule(RCTEventEmitter.class)
|
|
118
|
+
.receiveEvent(getId(), "load", event);
|
|
44
119
|
}
|
|
45
120
|
}
|
|
@@ -1,26 +1,20 @@
|
|
|
1
1
|
package com.volcengine.velive.rn.push;
|
|
2
2
|
|
|
3
3
|
import android.os.Looper;
|
|
4
|
-
import android.view.SurfaceView;
|
|
5
|
-
import android.view.View;
|
|
6
|
-
|
|
7
4
|
import androidx.annotation.NonNull;
|
|
8
5
|
import androidx.annotation.Nullable;
|
|
9
|
-
|
|
10
6
|
import com.facebook.react.bridge.ReadableArray;
|
|
11
7
|
import com.facebook.react.common.MapBuilder;
|
|
12
8
|
import com.facebook.react.uimanager.SimpleViewManager;
|
|
13
9
|
import com.facebook.react.uimanager.ThemedReactContext;
|
|
14
10
|
import com.facebook.react.uimanager.annotations.ReactProp;
|
|
15
|
-
import com.volcengine.VolcApiEngine.view.*;
|
|
16
|
-
|
|
17
11
|
import java.util.Map;
|
|
18
12
|
|
|
19
13
|
public class VeLivePushViewManager extends SimpleViewManager<VeLivePushView> {
|
|
20
14
|
public static final String NAME = "VeLivePushView";
|
|
21
|
-
|
|
22
|
-
private ThemedReactContext context;
|
|
23
15
|
|
|
16
|
+
private ThemedReactContext context;
|
|
17
|
+
|
|
24
18
|
@NonNull
|
|
25
19
|
@Override
|
|
26
20
|
public String getName() {
|
|
@@ -29,64 +23,54 @@ public class VeLivePushViewManager extends SimpleViewManager<VeLivePushView> {
|
|
|
29
23
|
|
|
30
24
|
@NonNull
|
|
31
25
|
@Override
|
|
32
|
-
protected VeLivePushView
|
|
26
|
+
protected VeLivePushView
|
|
27
|
+
createViewInstance(@NonNull ThemedReactContext reactContext) {
|
|
33
28
|
// 确保在主线程创建
|
|
34
29
|
if (Looper.myLooper() != Looper.getMainLooper()) {
|
|
35
|
-
throw new IllegalStateException(
|
|
30
|
+
throw new IllegalStateException(
|
|
31
|
+
"View must be created on the main thread");
|
|
36
32
|
}
|
|
37
33
|
context = reactContext;
|
|
38
34
|
return new VeLivePushView(reactContext);
|
|
39
35
|
}
|
|
40
|
-
|
|
36
|
+
|
|
41
37
|
@ReactProp(name = "viewId")
|
|
42
38
|
public void setViewId(VeLivePushView view, String viewId) {
|
|
43
39
|
view.setViewId(viewId);
|
|
44
|
-
VolcViewManager.putViewById(viewId, view);
|
|
45
40
|
}
|
|
46
41
|
|
|
47
42
|
@ReactProp(name = "kind")
|
|
48
43
|
public void setKind(VeLivePushView view, String kind) {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
switch (kind) {
|
|
52
|
-
case "SurfaceView" -> {
|
|
53
|
-
SurfaceView subView = new SurfaceView(themedReactContext.getReactApplicationContext());
|
|
54
|
-
view.addView(subView);
|
|
55
|
-
}
|
|
56
|
-
case "View" -> {
|
|
57
|
-
View subView = new View(themedReactContext.getApplicationContext());
|
|
58
|
-
view.addView(subView);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
44
|
+
view.setViewKind(kind);
|
|
61
45
|
}
|
|
62
|
-
|
|
46
|
+
|
|
63
47
|
public void setVisible(VeLivePushView view, Boolean visible) {
|
|
64
48
|
view.setVisible(visible);
|
|
65
49
|
}
|
|
50
|
+
|
|
51
|
+
public void resetSurface(VeLivePushView view) {
|
|
52
|
+
view.resetSurface();
|
|
53
|
+
}
|
|
66
54
|
|
|
67
55
|
/**
|
|
68
56
|
* Handle "create" command (called from JS) and call createFragment method
|
|
69
57
|
*/
|
|
70
|
-
public void receiveCommand(
|
|
71
|
-
|
|
72
|
-
String command,
|
|
73
|
-
@Nullable ReadableArray args
|
|
74
|
-
) {
|
|
58
|
+
public void receiveCommand(@NonNull VeLivePushView root, String command,
|
|
59
|
+
@Nullable ReadableArray args) {
|
|
75
60
|
super.receiveCommand(root, command, args);
|
|
76
|
-
|
|
61
|
+
|
|
77
62
|
if (command.equals("setVisible")) {
|
|
78
63
|
assert args != null;
|
|
79
64
|
setVisible(root, args.getBoolean(0));
|
|
65
|
+
} else if(command.equals("resetSurface")) {
|
|
66
|
+
resetSurface(root);
|
|
80
67
|
}
|
|
81
68
|
}
|
|
82
69
|
|
|
83
70
|
public Map getExportedCustomBubblingEventTypeConstants() {
|
|
84
|
-
return MapBuilder.builder()
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
MapBuilder.of("bubbled", "onViewLoad")
|
|
89
|
-
)
|
|
90
|
-
).build();
|
|
71
|
+
return MapBuilder.builder()
|
|
72
|
+
.put("load", MapBuilder.of("phasedRegistrationNames",
|
|
73
|
+
MapBuilder.of("bubbled", "onViewLoad")))
|
|
74
|
+
.build();
|
|
91
75
|
}
|
|
92
76
|
}
|
package/lib/commonjs/index.js
CHANGED
|
@@ -28053,10 +28053,7 @@ function initAndroidPusher(options) {
|
|
|
28053
28053
|
case 2:
|
|
28054
28054
|
_d.sent();
|
|
28055
28055
|
viewTag = reactNative.findNodeHandle(element);
|
|
28056
|
-
reactNative.UIManager.dispatchViewManagerCommand(viewTag, '
|
|
28057
|
-
setTimeout(function () {
|
|
28058
|
-
reactNative.UIManager.dispatchViewManagerCommand(viewTag, 'setVisible', [true]);
|
|
28059
|
-
}, 1000);
|
|
28056
|
+
reactNative.UIManager.dispatchViewManagerCommand(viewTag, 'resetSurface', []);
|
|
28060
28057
|
return [2 /*return*/, packObject(pusher, VeLivePusher)];
|
|
28061
28058
|
}
|
|
28062
28059
|
});
|
package/lib/module/index.js
CHANGED
|
@@ -28051,10 +28051,7 @@ function initAndroidPusher(options) {
|
|
|
28051
28051
|
case 2:
|
|
28052
28052
|
_d.sent();
|
|
28053
28053
|
viewTag = findNodeHandle(element);
|
|
28054
|
-
UIManager.dispatchViewManagerCommand(viewTag, '
|
|
28055
|
-
setTimeout(function () {
|
|
28056
|
-
UIManager.dispatchViewManagerCommand(viewTag, 'setVisible', [true]);
|
|
28057
|
-
}, 1000);
|
|
28054
|
+
UIManager.dispatchViewManagerCommand(viewTag, 'resetSurface', []);
|
|
28058
28055
|
return [2 /*return*/, packObject(pusher, VeLivePusher)];
|
|
28059
28056
|
}
|
|
28060
28057
|
});
|