using System; using System.Collections.Generic; using HC; using JetBrains.Annotations; public partial class HCSDKManager { protected override void OnInstanceCreate() { base.OnInstanceCreate(); #if UNITY_WEBGL || WEBGL_BYTEDANCE var hcWebGLSdkManager = HCWebGLSDKManager.Instance; #endif } public void Share(string title, [CanBeNull] string imgUrl = null, [CanBeNull] string content = null, [CanBeNull] Action callback = null, int type = 0) { #if UNITY_WEBGL || WEBGL_BYTEDANCE HCWebGLSDKManager.Share.Share(title, imgUrl, content, callback); #else // TODO 暂时不支持 callback?.Invoke(false); #endif } public void ExitApp() { HCWebGLSDKManager.Base.ExitApp(); } /// /// 购买 /// /// public void Buy(HCPaymentArgs paymentArgs) { HCAnalyticsManager.Instance.IAPBtnClick(paymentArgs.productName, paymentArgs.gameExtraParam, "CNY", paymentArgs.money, paymentArgs.gameExtraParam); #if UNITY_WEBGL || WEBGL_BYTEDANCE HCWebGLSDKManager.Purchase.Buy(paymentArgs); #endif } /// /// 奖励下发成功 /// /// public void Awarded(string orderID) { #if UNITY_WEBGL || WEBGL_BYTEDANCE HCWebGLSDKManager.Purchase.Awarded(orderID); #endif } #if WEBGL_BYTEDANCE public void DyShare(Action callback, StarkSDKSpace.UNBridgeLib.LitJson.JsonData jsonData) { var json = jsonData.ToJson(); HCDebugger.LogDebug("分享:" + json); HCWebGLSDKManager.Share.DYShare(callback, jsonData); } public void DyShareRecordVideo(string title, string[] videoTopicList, Action> callback) { HCDebugger.LogDebug($"[DyShareRecordVideo] title = {title} videoTopicList = {videoTopicList}"); var topics = new List(); if (videoTopicList != null) { topics.AddRange(videoTopicList); } StarkSDKSpace.StarkSDK.API.GetStarkGameRecorder().ShareVideoWithTitleTopics(result => { HCDebugger.LogDebug($"[DyShareRecordVideo] [successCallback]"); callback?.Invoke(true, "success", result); }, msg => { HCDebugger.LogDebug($"[DyShareRecordVideo] [failedCallback] msg = {msg}"); callback?.Invoke(false, msg, new Dictionary()); }, () => { HCDebugger.LogDebug($"[DyShareRecordVideo] [cancelledCallback]"); callback?.Invoke(false, "cancelled", new Dictionary()); }, title, topics); } public void DyShareVideo(string videoPath, string title, string[] videoTopicList, string[] hashtagList, Action callback) { var videoTopics = new StarkSDKSpace.UNBridgeLib.LitJson.JsonData(); videoTopics.SetJsonType(StarkSDKSpace.UNBridgeLib.LitJson.JsonType.Array); if (videoTopicList != null) { foreach (var s in videoTopicList) { videoTopics.Add(s); } } var hashtags = new StarkSDKSpace.UNBridgeLib.LitJson.JsonData(); hashtags.SetJsonType(StarkSDKSpace.UNBridgeLib.LitJson.JsonType.Array); if (hashtagList != null) { foreach (var s in hashtagList) { hashtags.Add(s); } } var jsonData = new StarkSDKSpace.UNBridgeLib.LitJson.JsonData { ["channel"] = "video", ["title"] = title, ["extra"] = new() { ["videoPath"] = videoPath, ["videoTopics"] = videoTopics, ["hashtag_list"] = hashtags, }, }; DyShare(callback, jsonData); } /// /// 开始录屏 /// 是否录制声音,默认为录制声音 /// 最大录制时长,单位 s。小于等于 0 则无限制。默认为10分钟 /// 视频录制开始回调 /// 视频录制失败回调 /// /// 函数调用状态,调用成功返回true,否则返回false public bool StartRecord(bool isRecordAudio, int maxRecordTimeSec = 600, Action startCallback = null, Action errorCallback = null, Action timeoutCallback = null) { return ((HCBytedanceBase)HCWebGLSDKManager.Base).StartRecord(isRecordAudio, maxRecordTimeSec, startCallback, errorCallback, timeoutCallback); } /// /// 停止录屏 /// 视频录制完成回调 /// 视频录制失败回调 /// 停止后需要对视频进行裁剪的时间片段,如果为null或空列表,则不对视频进行裁剪 /// 是否对视频裁剪片段进行自动合并。 /// 合并规则: /// 如果有两段重叠的时间片段,并且重叠部分小于等于1秒,则对这两段进行合并为一段 /// 若autoMerge为true,比如时间片段为{[1000, 5000], [4000, 7000]},会被合并为{[1000, 7000]}。 /// 若autoMerge为false,将按原始传入的时间片段进行裁剪,是否有重叠,由调用方保证。主要用于自定义裁剪。 /// /// 函数调用状态,调用成功返回true,否则返回false public bool StopRecord(Action completeCallback = null, Action errorCallback = null, List clipRanges = null, bool autoMerge = true) { return ((HCBytedanceBase)HCWebGLSDKManager.Base).StopRecord(completeCallback, errorCallback, clipRanges, autoMerge); } public void CheckScene(string scene, Action success, Action complete, Action error) { ((HCBytedanceBase)HCWebGLSDKManager.Base).CheckScene(scene, success, complete, error); } public void NavigateToScene(string scene, Action success, Action complete, Action error) { ((HCBytedanceBase)HCWebGLSDKManager.Base).NavigateToScene(scene, success, complete, error); } public void OnShowWithDict(Action> paramCallback) { ((HCBytedanceBase)HCWebGLSDKManager.Base).OnShowWithDict(paramCallback); } #endif }