当前位置:网站首页>Self use tool unity video player that monkeys can use
Self use tool unity video player that monkeys can use
2022-06-28 03:35:00 【Starve fish】
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.Video;
public class Movie : MonoBehaviour
{
[Tooltip(" Whether to hide when the program starts running UI,false For hiding ")] public bool OpenMovie_Awake = true;
[Header("Buttons")]
[Tooltip(" Play button ")] public Button Start;
[Tooltip(" Broadcasting speed +")] public Button SpeedUp;
[Tooltip(" Broadcasting speed -")] public Button SpeedDown;
[Header("UI")]
[Tooltip(" Input VideoPlayer")] public VideoPlayer VideoPlayers;
[Tooltip(" Broadcasting speed Text")] public Text SpeedShow;
[Tooltip(" Playback time and total duration Text")] public Text TimeShow;
[Header(" Slider bar . You need to add a sliding event to the slider ")]
[Tooltip(" Volume bar ")] public Slider Volume;
[Tooltip(" Progress bar ")] public Slider Times;
[Header(" Video playback speed ")]
[Range(0f, 1f)]
public float PlayBackSpeedChange = 0.5f;// Playback speed adjusted each time
[Range(0f, 5f)]
public float PlayBackSpeedMax = 3f;// Maximum playback speed
public static int PlayingURL;// Play current URL
public static string[] URL = { @"file://D:/Test/Movie01.mov"};// Video collection
void Awake()
{
VideoPlayers.GetComponent<VideoPlayer>().url = URL[0];
AddListerer();
_MovieOpend = true;
}
public void Update()// The playback speed text is adjusted here
{
SpeedShow.text = " Broadcasting speed X" + VideoPlayers.playbackSpeed.ToString("#0.0");
TimeShow.text = ($"{(int)VideoPlayers.time / 60}:{(VideoPlayers.time % 60).ToString("00")}/{(int)VideoPlayers.length / 60}:{(VideoPlayers.length % 60).ToString("00")}");
if (VideoPlayers.frameRate / VideoPlayers.frameCount > 0)// Progress bar
{
if (!Input.GetMouseButton(0) || _volumedraging)
Times.value = (float)VideoPlayers.time / (float)VideoPlayers.length;
}
if (Input.GetMouseButtonUp(0)) _volumedraging = false;// Prevent sliding the volume bar to lock the progress bar
}
/// <summary>
/// Progress bar
/// </summary>
public void Ondrag()
{
if (Input.GetMouseButton(0) && !_volumedraging)
VideoPlayers.time = Times.value * (float)VideoPlayers.length;
}
/// <summary>
/// The volume
/// </summary>
public void VolumeDrag()
{
_volumedraging = true;
VideoPlayers.SetDirectAudioVolume(0, Volume.value);
}
/// <summary>
/// Add listeners for all buttons
/// </summary>
void AddListerer()
{
Start.onClick.AddListener(() =>// Play
{
if (_Pauseing)
{
VideoPlayers.playbackSpeed = 1f;
Start.gameObject.transform.Find("Text").GetComponent<Text>().text = " Pause ";
_Pauseing = false;
}
else
{
VideoPlayers.playbackSpeed = 0f;
Start.gameObject.transform.Find("Text").GetComponent<Text>().text = " Play ";
_Pauseing = true;
}
});
SpeedUp.onClick.AddListener(() =>
{
if (VideoPlayers.playbackSpeed < PlayBackSpeedMax)
VideoPlayers.playbackSpeed += PlayBackSpeedChange;
});
SpeedDown.onClick.AddListener(() =>
{
if (VideoPlayers.playbackSpeed > 0f)
VideoPlayers.playbackSpeed -= PlayBackSpeedChange;
});
}
bool _MovieOpend;
bool _Pauseing = false;
bool _volumedraging;
}
design sketch
边栏推荐
- 在牛客中使用JS编程题【split】
- 【PaddleDetection】ModuleNotFoundError: No module named ‘paddle‘
- GAMES104 作业2-ColorGrading
- 2022 safety officer-c certificate examination question bank simulated examination platform operation
- 数据库乱码问题
- 资源管理、高可用与自动化(中)
- 如何获取GC(垃圾回收器)的STW(暂停)时间?
- 可扩展数据库(上)
- crond BAD FILE MODE /etc/cron. d
- Relative path writing of files
猜你喜欢

基于 LNMP 搭建个人网站的填坑之旅

17 `bs object Node name h3 Parent ` parents get parent node ancestor node

嵌入式软件开发中必备软件工具

建立自己的网站(17)

【小程序】使用font-awesome字体图标的解决文案(图文)

剑指 Offer 49. 丑数(三指针法)

What is the core problem to be solved in the East and West?

数据库系列之MySQL中的执行计划

Websocket (simple experience version)

2022安全员-C证考试题库模拟考试平台操作
随机推荐
Redis cluster setup [simple]
嵌入式软件开发中必备软件工具
云应用、服务的“5层”架构
nn.Parameter和torch.nn.init系列函数给模型参数初始化
Go speed
在excel文件上设置下拉选项
__ getitem__ And__ setitem__
2022年R1快開門式壓力容器操作特種作業證考試題庫及答案
Arm development studio build compilation error
crond BAD FILE MODE /etc/cron.d
Set drop-down options on Excel files
可扩展数据库(上)
crond BAD FILE MODE /etc/cron. d
开口式霍尔电流传感器如何助力直流配电改造?
Flow based depth generation model
In the digital era, enterprises must do well in user information security
Summary of the use of composition API in the project
GAMES104 作业2-ColorGrading
s32ds跳转到DefaultISR
力扣每日一题-第29天-575.分糖果