diff --git a/Demo/API_V2/Assets/API/Media/MediaSO.asset b/Demo/API_V2/Assets/API/Media/MediaSO.asset index d33fc71f1..7e7ba02a2 100644 --- a/Demo/API_V2/Assets/API/Media/MediaSO.asset +++ b/Demo/API_V2/Assets/API/Media/MediaSO.asset @@ -20,6 +20,7 @@ MonoBehaviour: - {fileID: 11400000, guid: 1055cfc5cdda7407298fa2ff9997d0c6, type: 2} - {fileID: 11400000, guid: 480646e3cd4d6a948a7538d483c1b043, type: 2} - {fileID: 11400000, guid: ad04526c3748b4e2b8498f998dfea973, type: 2} + - {fileID: 11400000, guid: 74a62098b548c4c9e985d91d4f60bcb9, type: 2} - {fileID: 11400000, guid: 38b7b2300105146ce94a785a915252de, type: 2} - {fileID: 11400000, guid: 04a7c5dbfc2464252841043ba677dcab, type: 2} categoryOrder: 9 diff --git a/Demo/API_V2/Assets/API/NativeVideo/WXVideo.meta b/Demo/API_V2/Assets/API/Media/Video.meta similarity index 77% rename from Demo/API_V2/Assets/API/NativeVideo/WXVideo.meta rename to Demo/API_V2/Assets/API/Media/Video.meta index 51612fd63..76f83812d 100644 --- a/Demo/API_V2/Assets/API/NativeVideo/WXVideo.meta +++ b/Demo/API_V2/Assets/API/Media/Video.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 3871f3583d0374d0ba711452505caa5d +guid: 9fe9f477259b04f18b8c4f9bd2c7ef64 folderAsset: yes DefaultImporter: externalObjects: {} diff --git a/Demo/API_V2/Assets/API/Media/Video/Video.cs b/Demo/API_V2/Assets/API/Media/Video/Video.cs new file mode 100644 index 000000000..3d7e93f04 --- /dev/null +++ b/Demo/API_V2/Assets/API/Media/Video/Video.cs @@ -0,0 +1,133 @@ +using System; +using LitJson; +using UnityEngine; +using WeChatWASM; + +public class Video : Details +{ + private WXVideo _video; + + private readonly Action _onEnded = () => + { + const string result = "【Video】OnEnded"; + GameManager.Instance.detailsController.AddResult( + new ResultData() { initialContentText = result } + ); + }; + private readonly Action _onError = (res) => + { + var result = "【Video】OnError: " + JsonMapper.ToJson(res); + GameManager.Instance.detailsController.AddResult( + new ResultData() { initialContentText = result } + ); + }; + private readonly Action _onPause = () => + { + const string result = "【Video】OnPause"; + GameManager.Instance.detailsController.AddResult( + new ResultData() { initialContentText = result } + ); + }; + private readonly Action _onPlay = () => + { + const string result = "【Video】OnPlay"; + GameManager.Instance.detailsController.AddResult( + new ResultData() { initialContentText = result } + ); + }; + private readonly Action _onProgress = (res) => + { + var result = "【Video】OnProgress: " + JsonMapper.ToJson(res); + GameManager.Instance.detailsController.AddResult( + new ResultData() { initialContentText = result } + ); + }; + private readonly Action _onTimeUpdate = (res) => + { + var result = "【Video】OnTimeUpdate: " + JsonMapper.ToJson(res); + GameManager.Instance.detailsController.AddResult( + new ResultData() { initialContentText = result } + ); + }; + private readonly Action _onWaiting = () => + { + const string result = "【Video】OnWaiting"; + GameManager.Instance.detailsController.AddResult( + new ResultData() { initialContentText = result } + ); + }; + + private void Start() + { + GameManager.Instance.detailsController.BindExtraButtonAction(0, ChangeMuteState); + } + + // 创建视频 + protected override void TestAPI(string[] args) + { + if (_video != null) + { + _video.Destroy(); + } + var createVideoOption = new CreateVideoOption() + { + x = GetOptionValue(0), + y = GetOptionValue(1), + width = GetOptionValue(2), + height = GetOptionValue(3), + src = args[4] == "示例视频" ? "http://wxsnsdy.tc.qq.com/105/20210/snsdyvideodownload?filekey=30280201010421301f0201690402534804102ca905ce620b1241b726bc41dcff44e00204012882540400&bizid=1023&hy=SH&fileparam=302c020101042530230204136ffd93020457e3c4ff02024ef202031e8d7f02030f42400204045a320a0201000400" : "", + poster = args[5] == "示例封面" ? "https://mmgame.qpic.cn/image/b4e70a6cba5ccad456667d85c3c0ea3c02e4f879a9705ed75071595a3e9f4ca0/0" : "", + initialTime = GetOptionValue(6), + playbackRate = GetOptionValue(7), + live = GetOptionValue(8), + objectFit = GetOptionString(9), + controls = GetOptionValue(10), + showProgress = GetOptionValue(11), + showProgressInControlMode = GetOptionValue(12), + backgroundColor = GetOptionString(13), + autoplay = GetOptionValue(14), + loop = GetOptionValue(15), + muted = GetOptionValue(16), + obeyMuteSwitch = GetOptionValue(17), + enableProgressGesture = GetOptionValue(18), + enablePlayGesture = GetOptionValue(19), + showCenterPlayBtn = GetOptionValue(20), + underGameView = GetOptionValue(21), + autoPauseIfNavigate = GetOptionValue(22), + autoPauseIfOpenNative = GetOptionValue(23), + }; + _video = WX.CreateVideo(createVideoOption); + _video.OnEnded(_onEnded); + _video.OnError(_onError); + _video.OnPause(_onPause); + _video.OnPlay(_onPlay); + _video.OnProgress(_onProgress); + _video.OnTimeUpdate(_onTimeUpdate); + _video.OnWaiting(_onWaiting); + } + + private void ChangeMuteState() + { + if (_video == null) + { + WX.ShowModal(new ShowModalOption() { content = "请先创建视频" }); + return; + } + + // 确保 muted 属性存在 + _video.muted ??= false; + + _video.muted = !_video.muted.Value; + GameManager.Instance.detailsController.ChangeExtraButtonText(0, _video.muted.Value ? "取消静音" : "静音"); + var result = "【Video】Mute state changed: " + _video.muted.Value; + WX.ShowModal(new ShowModalOption() { content = result }); + } + + private void OnDestroy() + { + if (_video != null) + { + _video.Destroy(); + } + } +} diff --git a/Demo/API_V2/Assets/API/NativeVideo/WXVideo/WXVideo.cs.meta b/Demo/API_V2/Assets/API/Media/Video/Video.cs.meta similarity index 83% rename from Demo/API_V2/Assets/API/NativeVideo/WXVideo/WXVideo.cs.meta rename to Demo/API_V2/Assets/API/Media/Video/Video.cs.meta index 401a818e9..e399df500 100644 --- a/Demo/API_V2/Assets/API/NativeVideo/WXVideo/WXVideo.cs.meta +++ b/Demo/API_V2/Assets/API/Media/Video/Video.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: b6f50f478ae16468fad92af4f7c5b7ee +guid: 5891aaa249e0740f1a0ba77397d39844 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/Demo/API_V2/Assets/API/Media/Video/VideoSO.asset b/Demo/API_V2/Assets/API/Media/Video/VideoSO.asset new file mode 100644 index 000000000..a2c7304ba --- /dev/null +++ b/Demo/API_V2/Assets/API/Media/Video/VideoSO.asset @@ -0,0 +1,146 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &11400000 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 57c8415214254e23a63d9bfb8c6bbf62, type: 3} + m_Name: VideoSO + m_EditorClassIdentifier: + entryName: "\u89C6\u9891" + entryOrder: 0 + entryScriptTypeName: Video + entryAPI: CreateVideo + entryDescription: "\u521B\u5EFA\u89C6\u9891" + optionList: + - optionName: x + availableOptions: + - null + - 0 + - 100 + - optionName: y + availableOptions: + - null + - 0 + - 100 + - optionName: width + availableOptions: + - null + - 0 + - 100 + - optionName: height + availableOptions: + - null + - 0 + - 100 + - optionName: src + availableOptions: + - "\u793A\u4F8B\u89C6\u9891" + - optionName: poster + availableOptions: + - null + - "\u793A\u4F8B\u5C01\u9762" + - optionName: initialTime + availableOptions: + - null + - 0 + - 100 + - optionName: playbackRate + availableOptions: + - null + - 0.5 + - 0.8 + - 1.0 + - 1.25 + - 1.5 + - optionName: live + availableOptions: + - null + - false + - true + - optionName: objectFit + availableOptions: + - null + - fill + - contain + - cover + - optionName: controls + availableOptions: + - null + - false + - true + - optionName: showProgress + availableOptions: + - null + - false + - true + - optionName: showProgressInControlMode + availableOptions: + - null + - false + - true + - optionName: backgroundColor + availableOptions: + - null + - '#000000' + - '#FFFFFFF' + - '#07C160' + - optionName: autoplay + availableOptions: + - null + - false + - true + - optionName: loop + availableOptions: + - null + - false + - true + - optionName: muted + availableOptions: + - null + - false + - true + - optionName: obeyMuteSwitch + availableOptions: + - null + - false + - true + - optionName: enableProgressGesture + availableOptions: + - null + - false + - true + - optionName: enablePlayGesture + availableOptions: + - null + - false + - true + - optionName: showCenterPlayBtn + availableOptions: + - null + - false + - true + - optionName: underGameView + availableOptions: + - null + - false + - true + - optionName: autoPauseIfNavigate + availableOptions: + - null + - false + - true + - optionName: autoPauseIfOpenNative + availableOptions: + - null + - false + - true + initialButtonText: "\u521B\u5EFA\u89C6\u9891" + extraButtonList: + - buttonText: "\u9759\u97F3" + initialResultList: [] diff --git a/Demo/API_V2/Assets/API/NativeVideo/WXVideo/WXVideoSO.asset.meta b/Demo/API_V2/Assets/API/Media/Video/VideoSO.asset.meta similarity index 79% rename from Demo/API_V2/Assets/API/NativeVideo/WXVideo/WXVideoSO.asset.meta rename to Demo/API_V2/Assets/API/Media/Video/VideoSO.asset.meta index d595d3d4e..0f2735018 100644 --- a/Demo/API_V2/Assets/API/NativeVideo/WXVideo/WXVideoSO.asset.meta +++ b/Demo/API_V2/Assets/API/Media/Video/VideoSO.asset.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: ebd496025e81f434bb6b5b487cfbf2ed +guid: 74a62098b548c4c9e985d91d4f60bcb9 NativeFormatImporter: externalObjects: {} mainObjectFileID: 11400000 diff --git a/Demo/API_V2/Assets/API/NativeInputField/InputField/TmpTextInit.cs b/Demo/API_V2/Assets/API/NativeInputField/InputField/TmpTextInit.cs index dd5985ff2..ee3225860 100644 --- a/Demo/API_V2/Assets/API/NativeInputField/InputField/TmpTextInit.cs +++ b/Demo/API_V2/Assets/API/NativeInputField/InputField/TmpTextInit.cs @@ -19,7 +19,7 @@ private void Start() // 如果 GameManager 的字体已经加载,直接设置 Text 的字体 if (GameManager.Instance.font != null) { - _text.font = GameManager.Instance.fonts; + _text.font = GameManager.Instance.TMP_font; } else { diff --git a/Demo/API_V2/Assets/API/NativeVideo/NativeVideoSO.asset b/Demo/API_V2/Assets/API/NativeVideo/NativeVideoSO.asset index a928a6271..270471374 100644 --- a/Demo/API_V2/Assets/API/NativeVideo/NativeVideoSO.asset +++ b/Demo/API_V2/Assets/API/NativeVideo/NativeVideoSO.asset @@ -18,5 +18,4 @@ MonoBehaviour: entryList: - {fileID: 11400000, guid: 5073e277b29d95642abb3c49fe94eea0, type: 2} - {fileID: 11400000, guid: 27654a238f98e4f7e8756e4caed418e1, type: 2} - - {fileID: 11400000, guid: ebd496025e81f434bb6b5b487cfbf2ed, type: 2} categoryOrder: 0 diff --git a/Demo/API_V2/Assets/API/NativeVideo/WXVideo/WXVideo.cs b/Demo/API_V2/Assets/API/NativeVideo/WXVideo/WXVideo.cs deleted file mode 100644 index dcbd8e81d..000000000 --- a/Demo/API_V2/Assets/API/NativeVideo/WXVideo/WXVideo.cs +++ /dev/null @@ -1,57 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; -using UnityEngine.UI; -using WeChatWASM; - -public class WXvideo : MonoBehaviour -{ - private WXVideo _video; - - // Start is called before the first frame update - void Start() - { - var btn = this.GetComponent