Skip to content

Commit 0857f9a

Browse files
author
hollislu
committed
feat:添加wxvideo
1 parent 591df64 commit 0857f9a

17 files changed

+2763
-490
lines changed

Demo/API_V2/Assets/API/Audio/AudioManager.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
using UnityEngine;
2-
2+
using UnityEngine.Networking;
33
public class AudioManager : MonoBehaviour
44
{
55
public AudioSource AudioSource;
@@ -39,4 +39,11 @@ public void Stop()
3939
{
4040
AudioSource.Stop();
4141
}
42+
43+
public void playDelayed()
44+
{
45+
AudioSource.clip = AudioClipLong;
46+
AudioSource.loop = true;
47+
AudioSource.PlayDelayed(3);
48+
}
4249
}

Demo/API_V2/Assets/API/Facility/Keyboard/Keyboard.cs

Lines changed: 76 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -9,74 +9,89 @@ public class Keyboard : Details
99
private bool _isListening = false;
1010
private System.Random random = new System.Random();
1111

12-
private readonly Action<OnKeyDownListenerResult> _onKeyUp = (res) => {
12+
private readonly Action<OnKeyDownListenerResult> _onKeyUp = (res) =>
13+
{
1314
var result = "onKeyUp\n" + JsonMapper.ToJson(res);
1415
GameManager.Instance.detailsController.AddResult(new ResultData()
1516
{
1617
initialContentText = result
1718
});
1819
};
1920

20-
private readonly Action<OnKeyDownListenerResult> _onKeyDown = (res) => {
21+
private readonly Action<OnKeyDownListenerResult> _onKeyDown = (res) =>
22+
{
2123
var result = "onKeyDown\n" + JsonMapper.ToJson(res);
2224
GameManager.Instance.detailsController.AddResult(new ResultData()
2325
{
2426
initialContentText = result
2527
});
2628
};
2729

28-
private readonly Action<OnKeyboardInputListenerResult> _onKeyboardInput = (res) => {
30+
private readonly Action<OnKeyboardInputListenerResult> _onKeyboardInput = (res) =>
31+
{
2932
var result = "onKeyboardInput\n" + JsonMapper.ToJson(res);
3033
GameManager.Instance.detailsController.AddResult(new ResultData()
3134
{
3235
initialContentText = result
3336
});
3437
};
3538

36-
private readonly Action<OnKeyboardInputListenerResult> _onKeyboardComplete = (res) => {
39+
private readonly Action<OnKeyboardInputListenerResult> _onKeyboardComplete = (res) =>
40+
{
3741
var result = "onKeyboardComplete\n" + JsonMapper.ToJson(res);
3842
GameManager.Instance.detailsController.AddResult(new ResultData()
3943
{
4044
initialContentText = result
4145
});
4246
};
4347

44-
private readonly Action<OnKeyboardInputListenerResult> _onKeyboardConfirm = (res) => {
48+
private readonly Action<OnKeyboardInputListenerResult> _onKeyboardConfirm = (res) =>
49+
{
4550
var result = "onKeyboardConfirm\n" + JsonMapper.ToJson(res);
4651
GameManager.Instance.detailsController.AddResult(new ResultData()
4752
{
4853
initialContentText = result
4954
});
5055
};
5156

52-
private readonly Action<OnKeyboardHeightChangeListenerResult> _onKeyboardHeightChange = (res) => {
57+
private readonly Action<OnKeyboardHeightChangeListenerResult> _onKeyboardHeightChange = (res) =>
58+
{
5359
var result = "onKeyboardHeightChange\n" + JsonMapper.ToJson(res);
5460
GameManager.Instance.detailsController.AddResult(new ResultData()
5561
{
5662
initialContentText = result
5763
});
5864
};
59-
65+
6066

6167
private void Start()
6268
{
6369
// 绑定额外的按钮操作
6470
GameManager.Instance.detailsController.BindExtraButtonAction(0, showKeyboard);
6571
GameManager.Instance.detailsController.BindExtraButtonAction(1, updateKeyboard);
6672
GameManager.Instance.detailsController.BindExtraButtonAction(2, hideKeyboard);
73+
GameManager.Instance.detailsController.BindExtraButtonAction(3, listening);
6774
}
6875

6976
// 测试 API
7077
protected override void TestAPI(string[] args)
7178
{
72-
if (!_isListening) {
79+
showMultipleKeyboard();
80+
}
81+
82+
public void listening()
83+
{
84+
if (!_isListening)
85+
{
7386
WX.OnKeyUp(_onKeyUp);
7487
WX.OnKeyDown(_onKeyDown);
7588
WX.OnKeyboardInput(_onKeyboardInput);
7689
WX.OnKeyboardHeightChange(_onKeyboardHeightChange);
7790
WX.OnKeyboardConfirm(_onKeyboardConfirm);
7891
WX.OnKeyboardComplete(_onKeyboardComplete);
79-
} else {
92+
}
93+
else
94+
{
8095
WX.OffKeyUp(_onKeyUp);
8196
WX.OffKeyDown(_onKeyDown);
8297
WX.OffKeyboardInput(_onKeyboardInput);
@@ -85,73 +100,110 @@ protected override void TestAPI(string[] args)
85100
WX.OffKeyboardComplete(_onKeyboardComplete);
86101
}
87102
_isListening = !_isListening;
88-
GameManager.Instance.detailsController.ChangeInitialButtonText(_isListening ? "取消监听" : "开始监听");
103+
GameManager.Instance.detailsController.ChangeExtraButtonText(3, _isListening ? "取消监听" : "开始监听");
89104
}
90105

91-
public void showKeyboard()
106+
public void showMultipleKeyboard()
92107
{
93-
WX.ShowKeyboard(new ShowKeyboardOption
108+
WX.ShowKeyboard(new ShowKeyboardOption
94109
{
95110
defaultValue = "test",
96111
maxLength = 20,
97112
multiple = true,
98113
confirmHold = false,
99114
confirmType = "done",
100-
success = (res) => {
115+
success = (res) =>
116+
{
101117
Debug.Log("success");
102118
},
103-
fail = (res) => {
119+
fail = (res) =>
120+
{
104121
Debug.Log("fail" + res.errMsg);
105122
},
106-
complete = (res) => {
123+
complete = (res) =>
124+
{
107125
Debug.Log("complete");
108126
}
109127
});
110128
}
111129

112-
public void updateKeyboard() {
130+
public void showKeyboard()
131+
{
132+
WX.ShowKeyboard(new ShowKeyboardOption
133+
{
134+
defaultValue = "test",
135+
maxLength = 20,
136+
multiple = false,
137+
confirmHold = false,
138+
confirmType = "done",
139+
success = (res) =>
140+
{
141+
Debug.Log("success");
142+
},
143+
fail = (res) =>
144+
{
145+
Debug.Log("fail" + res.errMsg);
146+
},
147+
complete = (res) =>
148+
{
149+
Debug.Log("complete");
150+
}
151+
});
152+
}
153+
154+
public void updateKeyboard()
155+
{
113156
WX.UpdateKeyboard(new UpdateKeyboardOption
114157
{
115158
value = "test" + random.Next(0, 100),
116-
success = (res) => {
159+
success = (res) =>
160+
{
117161
Debug.Log("success");
118162
WX.ShowToast(new ShowToastOption
119163
{
120164
title = "更改成功"
121165
});
122166
},
123-
fail = (res) => {
167+
fail = (res) =>
168+
{
124169
Debug.Log("fail" + res.errMsg);
125170
},
126-
complete = (res) => {
171+
complete = (res) =>
172+
{
127173
Debug.Log("complete");
128174
}
129175
});
130176
}
131177

132-
public void hideKeyboard() {
178+
public void hideKeyboard()
179+
{
133180
WX.HideKeyboard(new HideKeyboardOption
134181
{
135-
success = (res) => {
182+
success = (res) =>
183+
{
136184
Debug.Log("success");
137185
},
138-
fail = (res) => {
186+
fail = (res) =>
187+
{
139188
Debug.Log("fail" + res.errMsg);
140189
},
141-
complete = (res) => {
190+
complete = (res) =>
191+
{
142192
Debug.Log("complete");
143193
}
144194
});
145195
}
146196

147-
private void OnDestroy()
197+
public void Destroy()
148198
{
149199
WX.OffKeyUp(_onKeyUp);
150200
WX.OffKeyDown(_onKeyDown);
151201
WX.OffKeyboardInput(_onKeyboardInput);
152202
WX.OffKeyboardHeightChange(_onKeyboardHeightChange);
153203
WX.OffKeyboardConfirm(_onKeyboardConfirm);
154204
WX.OffKeyboardComplete(_onKeyboardComplete);
205+
206+
hideKeyboard();
155207
}
156208
}
157209

Demo/API_V2/Assets/API/Facility/Keyboard/KeyboardSO.asset

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,10 @@ MonoBehaviour:
1717
entryAPI: "\u952E\u76D8\u76F8\u5173API"
1818
entryDescription:
1919
optionList: []
20-
initialButtonText: "\u5F00\u59CB\u76D1\u542C"
20+
initialButtonText: "\u663E\u793A\u591A\u884C\u952E\u76D8"
2121
extraButtonList:
22-
- buttonText: "\u663E\u793A\u952E\u76D8"
22+
- buttonText: "\u663E\u793A\u5355\u884C\u952E\u76D8"
2323
- buttonText: "\u66F4\u65B0\u952E\u76D8\u8F93\u5165\u6846\u5185\u5BB9"
2424
- buttonText: "\u9690\u85CF\u952E\u76D8"
25+
- buttonText: "\u5F00\u59CB\u76D1\u542C"
2526
initialResultList: []

Demo/API_V2/Assets/API/Media/MediaSO.asset

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,3 @@ MonoBehaviour:
2020
- {fileID: 11400000, guid: ad04526c3748b4e2b8498f998dfea973, type: 2}
2121
- {fileID: 11400000, guid: 38b7b2300105146ce94a785a915252de, type: 2}
2222
- {fileID: 11400000, guid: 04a7c5dbfc2464252841043ba677dcab, type: 2}
23-
- {fileID: 11400000, guid: 5b3ed0a7a48524bb695e3f121885e16d, type: 2}

Demo/API_V2/Assets/API/Media/WXVideo/WXVideoSO.asset

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,8 @@ MonoBehaviour:
99
m_GameObject: {fileID: 0}
1010
m_Enabled: 1
1111
m_EditorHideFlags: 0
12-
m_Script: {fileID: 11500000, guid: fb48e4613a53bb941a20036d7c08fefb, type: 3}
12+
m_Script: {fileID: 11500000, guid: 77d040911b51640ea8a6e857528c3a0d, type: 3}
1313
m_Name: WXVideoSO
1414
m_EditorClassIdentifier:
15-
entryScriptTypeName: WXvideo
16-
entryName: "\u89C6\u9891"
17-
entryAPI: CreateVideo
18-
entryDescription: "\u539F\u751FVideoPlayer\u7EC4\u4EF6\u4F9D\u8D563.1.1\u4EE5\u4E0A\u7684\u57FA\u7840\u5E93\u7248\u672C\uFF0C\u5982\u679C\u5E0C\u671B\u8986\u76D6\u66F4\u591A\u4F4E\u7248\u672C\u7528\u6237\uFF0C\u4F7F\u7528API\u7684\u65B9\u5F0F\u5B9E\u73B0"
19-
optionList: []
20-
initialButtonText: "\u64AD\u653E\u89C6\u9891"
21-
extraButtonList: []
22-
initialResultList: []
15+
abilityName: "WX\u89C6\u9891"
16+
abilitySprite: {fileID: 0}

Demo/API_V2/Assets/API/Media/WXVideo/WXVideoSO.asset.meta

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,36 @@
1-
using System;
1+
using System.Collections;
22
using System.Collections.Generic;
3-
using LitJson;
43
using UnityEngine;
4+
using UnityEngine.UI;
55
using WeChatWASM;
66

7-
public class WXvideo : Details
7+
public class WXvideo : MonoBehaviour
88
{
9-
private WXVideo _video = null;
10-
// 测试 API
11-
protected override void TestAPI(string[] args)
9+
private WXVideo _video;
10+
// Start is called before the first frame update
11+
void Start()
1212
{
13-
AutoPlayVideo();
13+
var btn = this.GetComponent<Button>();
14+
btn.onClick.AddListener(OnClick);
15+
16+
this.AutoPlayVideo();
1417
}
1518

1619
private void AutoPlayVideo()
17-
{
20+
{
1821
var systemInfo = WX.GetSystemInfoSync();
19-
_video = WX.CreateVideo(new WXCreateVideoParam() {
22+
_video = WX.CreateVideo(new WXCreateVideoParam()
23+
{
2024
src = "http://wxsnsdy.tc.qq.com/105/20210/snsdyvideodownload?filekey=30280201010421301f0201690402534804102ca905ce620b1241b726bc41dcff44e00204012882540400&bizid=1023&hy=SH&fileparam=302c020101042530230204136ffd93020457e3c4ff02024ef202031e8d7f02030f42400204045a320a0201000400",
2125
controls = false,
2226
showProgress = false,
2327
showProgressInControlMode = false,
2428
autoplay = true,
2529
showCenterPlayBtn = false,
26-
underGameView = false,
27-
x = 0,
28-
y = 450,
30+
underGameView = true,
2931
width = ((int)systemInfo.screenWidth),
30-
height = 300,
32+
height = ((int)systemInfo.screenHeight),
3133
});
32-
_video.Play();
3334
_video.OnPlay(() => {
3435
Debug.Log("video on play");
3536
});
@@ -38,9 +39,13 @@ private void AutoPlayVideo()
3839
});
3940
}
4041

41-
public void Destroy() {
42-
if (_video != null) {
43-
_video.Destroy();
44-
}
42+
private void OnClick()
43+
{
44+
Debug.Log("click");
4545
}
46+
47+
private void OnDestroy()
48+
{
49+
_video.Destroy();
50+
}
4651
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
var LibraryGLClear = {
2+
glClear: function(mask)
3+
{
4+
if (mask == 0x00004000)
5+
{
6+
var v = GLctx.getParameter(GLctx.COLOR_WRITEMASK);
7+
if (GameGlobal.enableTransparentCanvas && !v[0] && !v[1] && !v[2] && v[3])
8+
// We are trying to clear alpha only -- skip.
9+
return;
10+
}
11+
GLctx.clear(mask);
12+
}
13+
};
14+
mergeInto(LibraryManager.library, LibraryGLClear);

0 commit comments

Comments
 (0)