Skip to content

Commit 5a01a05

Browse files
authored
Merge pull request #246 from wechat-miniprogram/feature/wx-video
feat: 视频demo
2 parents 055b8d0 + ff0bcab commit 5a01a05

32 files changed

+2962
-0
lines changed

Demo/WX_Video/.vsconfig

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"version": "1.0",
3+
"components": [
4+
"Microsoft.VisualStudio.Workload.ManagedGame"
5+
]
6+
}

Demo/WX_Video/Assets/PlayVideo.cs

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
using System.Collections;
2+
using System.Collections.Generic;
3+
using UnityEngine;
4+
using UnityEngine.UI;
5+
using WeChatWASM;
6+
7+
public class PlayVideo : MonoBehaviour
8+
{
9+
// Start is called before the first frame update
10+
void Start()
11+
{
12+
var btn = this.GetComponent<Button>();
13+
btn.onClick.AddListener(OnClick);
14+
15+
this.AutoPlayVideo();
16+
}
17+
18+
// Update is called once per frame
19+
void Update()
20+
{
21+
22+
}
23+
24+
private void AutoPlayVideo()
25+
{
26+
WX.InitSDK((int code) => {
27+
var systemInfo = WX.GetSystemInfoSync();
28+
var video = WX.CreateVideo(new WXCreateVideoParam() {
29+
src = "http://wxsnsdy.tc.qq.com/105/20210/snsdyvideodownload?filekey=30280201010421301f0201690402534804102ca905ce620b1241b726bc41dcff44e00204012882540400&bizid=1023&hy=SH&fileparam=302c020101042530230204136ffd93020457e3c4ff02024ef202031e8d7f02030f42400204045a320a0201000400",
30+
controls = false,
31+
showProgress = false,
32+
showProgressInControlMode = false,
33+
autoplay = true,
34+
showCenterPlayBtn = false,
35+
underGameView = true,
36+
width = ((int)systemInfo.screenWidth),
37+
height = ((int)systemInfo.screenHeight),
38+
});
39+
video.OnPlay(() => {
40+
Debug.Log("video on play");
41+
});
42+
video.OnError(() => {
43+
Debug.Log("video on error");
44+
});
45+
});
46+
}
47+
48+
private void OnClick()
49+
{
50+
Debug.Log("click");
51+
}
52+
}

Demo/WX_Video/Assets/PlayVideo.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
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 (!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);

Demo/WX_Video/Assets/Plugins/TransparentBackground.jslib.meta

Lines changed: 32 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Demo/WX_Video/Assets/Scenes.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)