Skip to content

Commit 02a8b5b

Browse files
author
v_shanxia
committed
fix:更改生命周期,增加音频示例
1 parent 074f914 commit 02a8b5b

File tree

7 files changed

+109
-9
lines changed

7 files changed

+109
-9
lines changed

Demo/API_V2/Assets/API/Base/LifeCycle/LifeCycle.cs

+29-3
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,31 @@
66

77
public class LifeCycle : Details
88
{
9+
private void Start()
10+
{
11+
// 绑定额外的按钮操作
12+
GameManager.Instance.detailsController.BindExtraButtonAction(0, getLaunchOptionsSync);
13+
GameManager.Instance.detailsController.BindExtraButtonAction(1, getEnterOptionsSync);
14+
}
915
private bool _isListening = false;
1016

1117
private readonly Action<OnShowListenerResult> _onShow = (res) =>
1218
{
13-
var result = "onShow\n" + JsonMapper.ToJson(res);
19+
var result = "OnShow\n" + JsonMapper.ToJson(res);
1420
GameManager.Instance.detailsController.AddResult(
1521
new ResultData() { initialContentText = result }
1622
);
1723
};
1824

1925
private readonly Action<GeneralCallbackResult> _onHide = (res) =>
2026
{
21-
var result = "onHide\n" + JsonMapper.ToJson(res);
27+
var result = "OnHide\n" + JsonMapper.ToJson(res);
2228
GameManager.Instance.detailsController.AddResult(
2329
new ResultData() { initialContentText = result }
2430
);
2531
};
2632

33+
2734
// 测试 API
2835
protected override void TestAPI(string[] args)
2936
{
@@ -39,8 +46,27 @@ protected override void TestAPI(string[] args)
3946
}
4047
_isListening = !_isListening;
4148
GameManager.Instance.detailsController.ChangeInitialButtonText(
42-
_isListening ? "取消监听" : "开始监听"
49+
_isListening ? "取消监听hide/show事件" : "开始监听hide/show事件"
50+
);
51+
}
52+
53+
public void getLaunchOptionsSync()
54+
{
55+
var LaunchOptionsSync = WX.GetLaunchOptionsSync();
56+
var result = "GetLaunchOptionsSync\n" + JsonMapper.ToJson(LaunchOptionsSync);
57+
GameManager.Instance.detailsController.AddResult(
58+
new ResultData() { initialContentText = result }
59+
);
60+
}
61+
62+
public void getEnterOptionsSync()
63+
{
64+
var EnterOptionsSync = WX.GetEnterOptionsSync();
65+
var result = "GetEnterOptionsSync\n" + JsonMapper.ToJson(EnterOptionsSync);
66+
GameManager.Instance.detailsController.AddResult(
67+
new ResultData() { initialContentText = result }
4368
);
69+
4470
}
4571

4672
private void OnDestroy()

Demo/API_V2/Assets/API/Base/LifeCycle/LifeCycleSO.asset

+8-6
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,16 @@ MonoBehaviour:
1414
m_EditorClassIdentifier:
1515
entryScriptTypeName: LifeCycle
1616
entryName: "\u751F\u547D\u5468\u671F"
17-
entryAPI: 'onHide | onShow
17+
entryAPI: 'OnHide | OnShow
1818
19-
offHide | offShow'
20-
entryDescription: "onHide\uFF1A\u76D1\u542C\u5C0F\u6E38\u620F\u9690\u85CF\u5230\u540E\u53F0\nonShow\uFF1A\u76D1\u542C\u5C0F\u6E38\u620F\u56DE\u5230\u524D\u53F0\u7684\u4E8B\u4EF6\noffHide
21-
/ offShow : \u79FB\u9664\u76D1\u542C"
19+
OffHide | OffShow'
20+
entryDescription: "OnHide\uFF1A\u76D1\u542C\u5C0F\u6E38\u620F\u9690\u85CF\u5230\u540E\u53F0\nOnShow\uFF1A\u76D1\u542C\u5C0F\u6E38\u620F\u56DE\u5230\u524D\u53F0\u7684\u4E8B\u4EF6\nOffHide
21+
/ OffShow : \u79FB\u9664\u76D1\u542C"
2222
optionList: []
23-
initialButtonText: "\u5F00\u59CB\u76D1\u542C"
24-
extraButtonList: []
23+
initialButtonText: "\u5F00\u59CB\u76D1\u542Chide/show\u4E8B\u4EF6"
24+
extraButtonList:
25+
- buttonText: "\u83B7\u53D6\u5C0F\u6E38\u620F\u51B7\u542F\u52A8\u53C2\u6570"
26+
- buttonText: "\u83B7\u53D6\u5C0F\u6E38\u620F\u6253\u5F00\u7684\u53C2\u6570"
2527
initialResultList:
2628
- isDisableInitially: 0
2729
initialTitleText:

Demo/API_V2/Assets/API/Media/InnerAudio.meta

+8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using LitJson;
4+
using UnityEngine;
5+
using WeChatWASM;
6+
7+
public class InnerAudio : Details
8+
{
9+
protected override void TestAPI(string[] args)
10+
{
11+
var music = WX.CreateInnerAudioContext(new InnerAudioContextParam() {
12+
src = "https://res.wx.qq.com/wechatgame/product/webpack/userupload/20220901/211827/CallMeTeenTop.mp3",
13+
needDownload = true //表示等下载完之后再播放,便于后续复用,无延迟
14+
});
15+
music.OnCanplay(() =>
16+
{
17+
Debug.Log("OnCanplay");
18+
music.Play();
19+
});
20+
}
21+
22+
}

Demo/API_V2/Assets/API/Media/InnerAudio/InnerAudio.cs.meta

+11
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
%YAML 1.1
2+
%TAG !u! tag:unity3d.com,2011:
3+
--- !u!114 &11400000
4+
MonoBehaviour:
5+
m_ObjectHideFlags: 0
6+
m_CorrespondingSourceObject: {fileID: 0}
7+
m_PrefabInstance: {fileID: 0}
8+
m_PrefabAsset: {fileID: 0}
9+
m_GameObject: {fileID: 0}
10+
m_Enabled: 1
11+
m_EditorHideFlags: 0
12+
m_Script: {fileID: 11500000, guid: fb48e4613a53bb941a20036d7c08fefb, type: 3}
13+
m_Name: InnerAudioSO
14+
m_EditorClassIdentifier:
15+
entryScriptTypeName: InnerAudio
16+
entryName: "\u97F3\u9891\u793A\u4F8B"
17+
entryAPI:
18+
entryDescription:
19+
optionList: []
20+
initialButtonText: "\u64AD\u653E\u97F3\u9891"
21+
extraButtonList: []
22+
initialResultList: []
23+
entryOrder: 0

Demo/API_V2/Assets/API/Media/InnerAudio/InnerAudioSO.asset.meta

+8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)