PlayVideo.cs 1.5 KB
Newer Older
J
junkunzhang 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using WeChatWASM;

public class PlayVideo : MonoBehaviour
{
    // Start is called before the first frame update
    void Start()
    {
        var btn = this.GetComponent<Button>();
        btn.onClick.AddListener(OnClick);

        this.AutoPlayVideo();
    }

    // Update is called once per frame
    void Update()
    {
        
    }

    private void AutoPlayVideo()
    {
        WX.InitSDK((int code) => {
            var systemInfo = WX.GetSystemInfoSync();
            var video = WX.CreateVideo(new WXCreateVideoParam() {
                src = "http://wxsnsdy.tc.qq.com/105/20210/snsdyvideodownload?filekey=30280201010421301f0201690402534804102ca905ce620b1241b726bc41dcff44e00204012882540400&bizid=1023&hy=SH&fileparam=302c020101042530230204136ffd93020457e3c4ff02024ef202031e8d7f02030f42400204045a320a0201000400",
                controls = false,
                showProgress = false,
                showProgressInControlMode = false,
                autoplay = true,
                showCenterPlayBtn = false,
                underGameView = true,
                width = ((int)systemInfo.screenWidth),
                height = ((int)systemInfo.screenHeight),
            });
            video.OnPlay(() => {
                Debug.Log("video on play");
            });
            video.OnError(() => {
                Debug.Log("video on error");
            });
        });
    }

    private void OnClick()
    {
        Debug.Log("click");
    }
}