Unity AVPro 解决切换视频卡的问题

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using RenderHeads.Media.AVProVideo.Demos.UI;
using RenderHeads.Media.AVProVideo;
using static UnityEditor.Experimental.GraphView.GraphView;
using System.Numerics;
using System;

public class VIdeoURL : MonoBehaviour
{
    // Start is called before the first frame update
    public string URL;
    public MediaPlayer playerA;
    public MediaPlayer playerB;
    private MediaPlayer player;
    public DisplayUGUI displayUGUI;
    void Start()
    {

        EventTriggerListener.Get(gameObject).onClick = onClick;
    }
    void onClick(GameObject sender)
    {
        if (playerA.gameObject.activeInHierarchy)
        {
            player = playerB;
            playerA.gameObject.SetActive(false);
        }
        else
        {
            player = playerA;
            playerB.gameObject.SetActive(false);
        }
        player.gameObject.SetActive(true);
        print(URL);
        player.OpenMedia(new MediaPath(URL + ".mp4", MediaPathType.RelativeToStreamingAssetsFolder), true);
        Invoke("fun", 0.1f);
    }
    void fun()
    {
        displayUGUI.CurrentMediaPlayer = player;
    }

}

插件2.5.1版本

posted on 2024-10-19 23:50  zqiang0803  阅读(23)  评论(0编辑  收藏  举报

导航