x


how integrate video before menu in unity iphone game

hi i need integrate a video movie introduction before my menu game unity iphone.

how is that posible?

more ▼

asked May 31 '10 at 03:30 PM

didier castillo gravatar image

didier castillo
31 1 1 4

Do you have iPhone advanced? That is necessary.

May 31 '10 at 04:13 PM Peter G
(comments are locked)
10|3000 characters needed characters left

3 answers: sort voted first

Like @Tetrad said, i created a "iPhoneStreamingAssets"-folder in a new unity-project and imported a *.mp4 video with this code:

function Start() {
    iPhoneUtils.PlayMovie("StarWars.mp4", Color.black, iPhoneMovieControlMode.CancelOnTouch);
}

After that i build and run it on my ipad - but no video playback on the app-start.The movieplayback-control is only 0.5 seconds visible - but no video. Any ideas on that? (i checked my imported video in the inspector with the video-size-format but i cant preview it in the inspector.. is that correctly or does that show that the video file is wrong?)

And a second question: Where are the video-files (from the "iPhoneStreamingAssets"-folder) that unity generates in the xcode project?

Thanks for any help...

more ▼

answered Jun 28 '10 at 10:47 AM

yosh gravatar image

yosh
901 73 81 94

So, after working on it, its now working. I only moved the "iPhoneStreamingAsset"-path one folder up where the "Assets" and the "Library"-folders are, then it works.

Jun 28 '10 at 01:13 PM yosh

to me it worked with /Assets/StreamingAsset

Feb 04 '11 at 09:41 PM Cawas

just to complement my previous comment, its path was indeed changed: http://answers.unity3d.com/questions/26570/iphoneutilsplaymovie-seems-disabled-in-unity-3.html

Oct 18 '11 at 03:39 PM Cawas
(comments are locked)
10|3000 characters needed characters left

Assuming that you have Unity iPhone Advanced, as video is not supported in Unity iPhone Basic, this is how I implemented a video before anything else.

Awake and Start are called pretty much immediately, so the easiest place to put your call is there. It's a basic function call and not much else to it. (I am currently not on my Mac so I can't point you to the class reference)

If you have done that correctly then the video will play immediately. The tricky part though, is that if you play your game and end up coming back to the menu it'll play the video again. Typically you don't want this to happen as it is kind of annoying especially if you don't give a tap to skip option. (which you probably should)

What I did to get around that is check your current time (Time.time) in Awake or Start (ours was 0 because it executed right away), just before you call the video. Add a little leeway for contingency and then do something like this:

if(Time.time < 1)
{
   //play video code here
}   

Since it will most likely be impossible to skip the video, start playing the game, pause, quit back to main menu in the time it takes your Time.time to increase from 0 to 1 you won't see the video play every time you return to the menu, only on application launch.

Another way to do it would be tell the video to play on Awake inside of a check for a static boolean something like this:

public static bool playVid = true;
void Awake()
{
   if(playVid)
   {
       //play video code here
       playVid = false;
   }
}

This is probably the more simple method.

Cheers,

==

more ▼

answered May 31 '10 at 05:29 PM

equalsequals gravatar image

equalsequals
4.5k 16 28 64

(comments are locked)
10|3000 characters needed characters left

If you're looking for the way to play a movie (and not just how to do it on startup), look in your hard drive scripting reference for iPhoneUtils.PlayMovie

It should be located here: /Applications/Unity%20iPhone/Unity%20iPhone.app/Contents/Documentation/Documentation/ScriptReference/iPhoneUtils.PlayMovie.html

more ▼

answered Jun 14 '10 at 06:35 PM

Tetrad gravatar image

Tetrad
7.2k 27 37 89

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

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

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x2000
x283

asked: May 31 '10 at 03:30 PM

Seen: 5618 times

Last Updated: Oct 18 '11 at 03:39 PM