Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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
1
Question by LeeGibson · Jun 20, 2011 at 03:16 PM · textureaudiovideospeedplay

video texture plays too fast when adding audio

I have a video texture on a primitive cube; attached to that is a PlayMovie-Script with the functions play and stop. The player can play and stop the movie with a mousedownbutton. Everything went well, all the scripts work and the video plays whenever i want to.

But when I added the corresponding audioclip to the gameobject (imported with the video of course), something strange happened: the whole video plays with sound, but suddenly at 4 times the speed than it should be. This is the line of code where I start video & audio:

function Play () { renderer.material.mainTexture.Play(); Debug.Log("played movie!"); audio.Play(); PlayerCollisions.moviePlays = true; }

If I disable //audio.Play(); the speed is back to normal.

Ideas, anyone?

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

2 Replies

· Add your reply
  • Sort: 
avatar image
2

Answer by atsakir · Sep 28, 2012 at 01:50 PM

For all those that share this problem, the issue appears when .play() is called more than once either on video or audio. Make sure you call `.play()` inside an `if (!video.isPlaying)` statement. Here is a script for playing either video or audio with delay and/or via trigger showing how this is done correctly:

 #pragma strict
 
 var delay : float = 0.0;
 private var timer : float;
 private var video : MovieTexture;
 private var isPlaying : boolean = false;
 var MovieObject : GameObject = null;
 private var obj_audio : AudioSource;
 var play_on_trigger : boolean = false;
 private var play : boolean = false;
 var loop : boolean = false;
 
 function Start () {
     timer = delay;   
     if (MovieObject == null) MovieObject = gameObject;
     if (MovieObject!=null)    { 
         if (MovieObject.renderer) 
         {
             video = MovieObject.renderer.material.mainTexture as MovieTexture;    
         }
         obj_audio = MovieObject.GetComponent(AudioSource);
         if (obj_audio != null) {
         }
     }
     if (!play_on_trigger) 
         play = true;
     if (loop && video) {
         video.loop = true;
     }
 }
 
 function Update () {
     if (MovieObject != null && play) {
         if (timer < 0) {
             if ( MovieObject.renderer) 
                 MovieObject.renderer.enabled = true;
             if (video && !video.isPlaying) {
                 video.Play();
             }
             if (obj_audio && !obj_audio.isPlaying) {
                 obj_audio.Play();
             }
             else Debug.Log(MovieObject.name+" no audio");
             isPlaying = true;
         }
         timer -= Time.deltaTime;
     }
 
 }
 
 function OnTriggerEnter()
 {
     play = true;
 }
 
Comment
Add comment · Share
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
avatar image
0

Answer by LeeGibson · Jul 01, 2011 at 02:31 PM

seems like it may have been a bug - rebuild the scene, did exactly the same as before, and now it works as it should.

just in case anybody else encounters the problem ;)

Comment
Add comment · Share
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

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Changing texture when movie is paused 0 Answers

Video texture problem? 2 Answers

GST Movie Texture - How to mute video?? 0 Answers

Add a Movie Texture to UI Button 0 Answers

playing audio from a video clip 0 Answers


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