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
1
Question by MusicManGP · Jan 31, 2012 at 07:52 PM · movietexturemovie

Problems with movies - delayed play or silent failure

I'm trying to get some large (1-2 minutes at 1920x1080 resolution) movies to work, and I'm having problems no matter what I try. I'm using Unity Pro.

In both cases I'm using a GUITexture object with an attached script to handle the actual movie playing. The GUITexture is setup to display the texture fullscreen.

The first method I attempted was to simply import the movies into Unity like regular assets, provide the references to the movies on the movie playing script, and simply select which texture to use. The script looked something like this:

 public void Play(string whichMovie)
 {
     MovieTexture selectedMovie;
     switch (whichMovie)
         ... set selectedMovie appropriately

     guiTexture.texture = selectedMovie;
     audio.clip = selectedMovie.audioClip;

     selectedMovie.Play();
     audio.Play();
 }

This technically works, but there's a problem. The movie doesn't actually start playing when I call Play(). It seems like the movie doesn't properly get loaded until Play is called, and there's a huge delay. This wouldn't be a problem except that once the movie does start playing, it automatically syncs up to where it should be, cutting off the beginning few seconds of the clips.

I've tried various methods to wait until the video is actually ready to play, but nothing works. It seems like the delay is inevitable using this method.

So onto method 2: using the WWW class. My code for that is as follows:

 public void Play(string whichMovie)
 {
     moviePath = "file://C:/agnes_build/" + which + ".ogg";
     StartCoroutine(LoadAndPlayMovie());
 }

 IEnumerator LoadAndPlayMovie()
 {
     WWW w = new WWW(moviePath);

     MovieTexture movie = w.movie;
     while (!movie.isReadyToPlay)
         yield return null;

     guiTexture.texture = movie;
     audio.clip = movie.audioClip;

     movie.Play();
     audio.Play();
 }

At first it seemed the second method didn't work at all. But then I tried using the sample video provided by Unity (http://www.unity3d.com/webplayers/Movie/sample.ogg), and it worked. So now I realize that the code works, but for some reason the movies I'm encoding don't work in Unity, though they work outside of Unity just fine.

I used ffmpeg2theora as recommended in a different post, and I've also tried using Miro Video Converter (which is just using ffmpeg2theora under the hood I think), to no avail. The videos work just fine outside of Unity, but when I try to load them using the WWW class as above, they "load" immediately but have a duration of -1 seconds. They take no time to play and the code basically immediately finishes.

I've been scouring the forums, and I feel like I've already tried everything I can to get this working in an ideal way. At the moment I'm quite disappointed in getting a Pro license for the movie support. Any thoughts?

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
0

Answer by kmccmk9 · Jun 26, 2012 at 02:49 AM

I am having the same problem. Right now I'm troubleshooting by adding a second and a half to the beginning of my video. I noticed if you don't start playing the audio, it does not delay at all. Give it a shot.

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 Gawain · Jun 26, 2012 at 04:54 AM

The delay is because of the audio and video running seperety. You need to make it run video and have audio listener. If that dosent work run them from different scripts.

Comment
Add comment · Show 3 · 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 kmccmk9 · Jun 28, 2012 at 04:39 AM 0
Share

So don't call audio.Play()? Just have an audio listener component?

avatar image kmccmk9 · Jun 28, 2012 at 04:44 AM 0
Share

I do have an audio listener component on the object and that isn't working. So I should play video in one script and play audio in another script?

avatar image kmccmk9 · Jun 29, 2012 at 12:38 AM 0
Share

Okay I have done what you suggested and now it plays at the right time but the whole video plays sped up

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

6 People are following this question.

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

Related Questions

'movie' is not a member of 'UnityEngine.WWW' 1 Answer

Projector with Movie Texture only sometimes works? 0 Answers

Is it possible to play a movie on Android OS? 3 Answers

Movie texture ( I have pro ) 2 Answers

skip transition in Handheld.PlayFullScreenMovie 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