59 lines
1.7 KiB
C#
59 lines
1.7 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using UnityEngine.Video;
|
|
|
|
public class VideoObject : MonoBehaviour
|
|
{
|
|
public ScreenRecording screenRecording;
|
|
public string url;
|
|
#region 测试方法
|
|
[ContextMenu("PlayInput")]
|
|
public void PlayTest1()
|
|
{
|
|
SetVideoUrl(url);
|
|
}
|
|
#endregion
|
|
// public void Start()
|
|
// {
|
|
// if (transform.name == "PlayMp4" && screenRecording.url != null)
|
|
// {
|
|
// SetVideoUrl(screenRecording.url);
|
|
// }
|
|
// }
|
|
|
|
|
|
public void SetVideoUrl(string url)
|
|
{
|
|
//VideoPlayer.url = url;
|
|
SetTexture();
|
|
|
|
//VideoPlayer.prepareCompleted += StartNext;
|
|
//VideoPlayer.SetDirectAudioMute(0, false);
|
|
// 禁用音频输出
|
|
//VideoPlayer.audioOutputMode = VideoAudioOutputMode.None;
|
|
// VideoPlayer.Prepare();
|
|
|
|
|
|
|
|
}
|
|
public void SetTexture()
|
|
{
|
|
|
|
// RenderTexture renderTexture = new RenderTexture(1280, 720, 0);
|
|
// renderTexture.graphicsFormat = UnityEngine.Experimental.Rendering.GraphicsFormat.R8G8B8A8_UNorm;
|
|
// renderTexture.depthStencilFormat = UnityEngine.Experimental.Rendering.GraphicsFormat.D32_SFloat_S8_UInt;
|
|
// VideoPlayer.targetTexture = renderTexture;
|
|
// RawImage.texture = renderTexture;
|
|
|
|
//renderTexture.dimension = UnityEngine.Rendering.TextureDimension.Tex2D;
|
|
|
|
}
|
|
public void StartNext(VideoPlayer vp)
|
|
{
|
|
vp.Play();
|
|
//mVideoPlayer.time = segmentStartTimes[currentSegmentIndex];
|
|
}
|
|
}
|