Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by Valiner · May 04, 2021 at 01:35 PM · buttonscript.video

How to display exact video by index, property on button click

Hi everyone, I'm developing an App where you can play a video clip. I have around 60 buttons, where I would like tp aatach the game object with this script. But, I can play only next video, and I dont know how to play exact video, for example, how can I choose video 40 t0 be played on button 40. Can Anyone help me please, this script, create an list of videos, so I can play them one by one, but I need, not to play them one after another, but when I press specific button, the correct video from the list is playing, many thanks in advance


using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.Video; using UnityEngine.UI; using System.Linq;

public class WorldSpacVideoPlayer : MonoBehaviour { public Renderer playButtonRenderer; public VideoClip[] videoClips; public GameObject[] Buttons;

 private VideoPlayer videoPlayer;
 private int videoClipIndex = 0;

 void Awake()
 {
     videoPlayer = GetComponent<VideoPlayer> ();

 }

 // Use this for initialization
 void Start () 
 {
     videoPlayer.targetTexture.Release ();
     videoPlayer.clip = videoClips [0];

    
     
 }

 // Update is called once per frame
 void Update () 
 {
     if (videoPlayer.isPlaying) 
     {
         SetCurrentTimeUI ();
         
     }
 }

 public void SetNextClip()
 {
     videoClipIndex++;

     videoPlayer.clip = videoClips [videoClipIndex];
     SetTotalTimeUI ();
     videoPlayer.Play ();

 }

   
 void SetCurrentTimeUI()
 {
     string minutes = Mathf.Floor ((int)videoPlayer.time / 60).ToString ("00");
     string seconds = ((int)videoPlayer.time % 60).ToString ("00");

 }

 void SetTotalTimeUI()
 {
     string minutes = Mathf.Floor ((int)videoPlayer.clip.length / 60).ToString ("00");
     string seconds = ((int)videoPlayer.clip.length % 60).ToString ("00");


 }

 double CalculatePlayedFraction()
 {
     double fraction = (double)videoPlayer.frame / (double)videoPlayer.clip.frameCount;
     return fraction;
 }

}

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

171 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How to keep the old line text? 1 Answer

Unity multiple button on click 1 Answer

Animation script help light problem 0 Answers

How do I attach a GameObject when the script is attached to unity's on click () function (for buttons). 2 Answers

how can i save a video from project folder (ASSETS) to android internal or external storage? 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges