- Home /
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?
Answer by yosh · Jun 28, 2010 at 10:47 AM
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...
So, after working on it, its now working. I only moved the "iPhoneStrea$$anonymous$$gAsset"-path one folder up where the "Assets" and the "Library"-folders are, then it works.
just to complement my previous comment, its path was indeed changed: http://answers.unity3d.com/questions/26570/iphoneutilsplaymovie-seems-disabled-in-unity-3.html
Answer by equalsequals · May 31, 2010 at 05:29 PM
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,
==
Answer by Tetrad · Jun 14, 2010 at 06:35 PM
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
Your answer
Follow this Question
Related Questions
Problem with video in IOS 1 Answer
Prepare Different Resolutions App Preview Videos for Apple Store 0 Answers
iPhone video playback in 3.0 beta5 working? 2 Answers
Record video on iPhone or Android? 6 Answers