首页 > 代码库 > PlayerTest

PlayerTest

using UnityEngine;
using System.Collections;

public class PlayTest : MonoBehaviour
{

//电影纹理
public MovieTexture mov;

 

void Start()
{

audio.clip = mov.audioClip;
audio.Play();
mov.Play();

//设置电影纹理播放模式为循环
mov.loop = true;

}

void OnGUI()
{
if (GUI.Button(new Rect(310, 0, 100, 50), "2倍速播放"))
{
audio.pitch = 2f;
}

if (GUI.Button(new Rect(410, 0, 100, 50), "1倍速播放"))
{
audio.pitch = 1f;
}

GUI.DrawTexture(new Rect(0, 0, 300, 300), mov);

//绘制电影纹理
GUI.DrawTexture(new Rect(0, 0, Screen.width, Screen.height), mov, ScaleMode.StretchToFill);

if (GUILayout.Button("播放/继续"))
{
//播放/继续播放视频
if (!mov.isPlaying)
{
mov.Play();
}

}

if (GUILayout.Button("暂停播放"))
{
//暂停播放
mov.Pause();
}

if (GUILayout.Button("停止播放"))
{
//停止播放
mov.Stop();
}
}

}

PlayerTest