Files
BabyVideo/Assets/Scripts/Game.cs
2026-02-09 20:10:14 +08:00

53 lines
1.5 KiB
C#

using System;
using System.Collections.Generic;
using RenderHeads.Media.AVProVideo;
using UnityEngine;
namespace NBF
{
public class Game : MonoBehaviour
{
public static Game Instance { get; private set; }
public readonly List<VideoRetData> Videos = new List<VideoRetData>();
public int Page = 1;
public int PageSize = 100;
private void Awake()
{
Instance = this;
}
public void Tick(Action<bool> callback = null)
{
var dic = new Dictionary<string, string>
{
{ "device", PlatformInfo.GetAndroidID() },
{ "deviceName", "android" },
{ "id", "0" },
{ "time", "0" }
};
Net.Instance.Send("/api/device", dic, result => { callback?.Invoke(result.Code == 0); });
}
public void GetList(Action callback)
{
var dic = new Dictionary<string, string>
{
{ "page", Page.ToString() },
{ "PageSize", PageSize.ToString() }
};
Net.Instance.Send("/api/list", dic, result =>
{
ParseVideo(result);
callback?.Invoke();
});
}
private void ParseVideo(HttpResult httpResult)
{
if (httpResult.Code != 0) return;
var retData = httpResult.Data.ToObject<PageListData<VideoRetData>>();
}
}
}