You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
56 lines
1.2 KiB
56 lines
1.2 KiB
4 years ago
|
using System.Collections;
|
||
|
using System.Collections.Generic;
|
||
|
using UnityEngine;
|
||
|
using UnityEngine.UI;
|
||
|
using UnityEngine.EventSystems;
|
||
|
using System;
|
||
|
|
||
|
public class VideoSlider : MonoBehaviour,IPointerDownHandler,IPointerUpHandler,IDragHandler
|
||
|
{
|
||
|
|
||
|
private Slider videoSlider;
|
||
|
private bool isPlaying;
|
||
|
private VideoPanel videoPanel;
|
||
|
// Use this for initialization
|
||
|
void Start()
|
||
|
{
|
||
|
videoSlider = GetComponent<Slider>();
|
||
|
videoPanel = transform.parent.parent.GetComponent<VideoPanel>();
|
||
|
}
|
||
|
|
||
|
// Update is called once per frame
|
||
|
void Update()
|
||
|
{
|
||
|
|
||
|
}
|
||
|
|
||
|
public void OnPointerDown(PointerEventData eventData)
|
||
|
{
|
||
|
videoPanel.skip = true;
|
||
|
if (videoPanel.videoPlayer.isPlaying)
|
||
|
{
|
||
|
isPlaying = true;
|
||
|
videoPanel.Pause();
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
isPlaying = false;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public void OnPointerUp(PointerEventData eventData)
|
||
|
{
|
||
|
videoPanel.videoPlayer.time = videoSlider.value;
|
||
|
videoPanel.skip = false;
|
||
|
if (isPlaying)
|
||
|
{
|
||
|
videoPanel.Play();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public void OnDrag(PointerEventData eventData)
|
||
|
{
|
||
|
videoPanel.videoPlayer.time = videoSlider.value;
|
||
|
}
|
||
|
}
|