Stop sliding transition animation when playing a movie with iOS

When I play a movie using:

iPhoneUtils.PlayMovie(“MyMovie.m4v”, transitionColour, iPhoneMovieControlMode.CancelOnTouch, iPhoneMovieScalingMode.AspectFill);

The iPhone slides the movie in to view before playing, the problem is I need to play the movie in position as I’m trying to create a seamless effect where the movie plays on top of the game view.

I’ve done some research and from what I can tell Unity is calling

[moviePlayer setFullscreen:YES animated:YES]

where the animated line needs to say no… unfortunately I don’t know where I can change this. If anyone knows how and could provide a quick step by step instruction it would be great.

Thanks!

I’ve managed to fix this in a hackish way. Swapping the implementation of [UIViewController presentMoviePlayerViewControllerAnimated] with a version that presents the movie player controller modally with no animation. No guarantees this works for your situation, but it works for us:

#import "JRSwizzle.h"
#import <MediaPlayer/MediaPlayer.h>

@interface UIViewController(OverrideAnimatedTransition)
- (void) nonanimatedPresentMoviePlayerViewControllerAnimated:(MPMoviePlayerViewController*) moviePlayerViewController;
- (void) nonanimatedDismissMoviePlayerViewControllerAnimated;
@end

@implementation UIViewController(OverrideAnimatedTransition)
- (void) nonanimatedPresentMoviePlayerViewControllerAnimated:(MPMoviePlayerViewController*) moviePlayerViewController {
    [self presentModalViewController:moviePlayerViewController animated:NO];
}

- (void) nonanimatedDismissMoviePlayerViewControllerAnimated {
    [self dismissModalViewControllerAnimated:NO];
}
@end

I use the JRSwizzle code from GitHub - rentzsch/jrswizzle: one-stop-shop for all your method swizzling needs to do the method implementation swaps in the appDidFinishLanuching like so:

NSError* err = nil;

[UIViewController jr_swizzleMethod:@selector(presentMoviePlayerViewControllerAnimated:) withMethod:@selector(nonanimatedPresentMoviePlayerViewControllerAnimated:) error:&err];
    [UIViewController jr_swizzleMethod:@selector(dismissMoviePlayerViewControllerAnimated) withMethod:@selector(nonanimatedDismissMoviePlayerViewControllerAnimated) error:&err];

Unity 4.0.1f2 and this is still a problem. Why isn’t the animation option exposed in Unity’s iPhoneUtils function? I’d like to try coquifrogs’ solution, but I don’t really know where to put that code, or which parts of JRSwizzle to put where. Has anything changed in the last two years since this problem was first identified?

We managed to implement the solution provided by coquifrogs.

Get JRSwizzle.h and JRSwizzle.m from GitHub - rentzsch/jrswizzle: one-stop-shop for all your method swizzling needs.
Place them in your Classes folder inside your Xcode project.

Generate a file called UIViewController.h and place it in the Classes folder as well. Put the following code in UIViewController.h

#import "JRSwizzle.h"
#import "VideoViewController.h"
@interface UIViewController(OverrideAnimatedTransition)
- (void) nonanimatedPresentMoviePlayerViewControllerAnimated:(MPMoviePlayerViewController*) moviePlayerViewController;
- (void) nonanimatedDismissMoviePlayerViewControllerAnimated;
@end
@implementation UIViewController(OverrideAnimatedTransition)
- (void) nonanimatedPresentMoviePlayerViewControllerAnimated:(MPMoviePlayerViewController*) moviePlayerViewController {
    [self presentModalViewController:moviePlayerViewController animated:NO];
}
- (void) nonanimatedDismissMoviePlayerViewControllerAnimated {
    [self dismissModalViewControllerAnimated:NO];
}
@end

Locate the class AppController.mm and put the following code at didFinishLaunchingWithOptions():

NSError* err = nil;
 
[UIViewController jr_swizzleMethod:@selector(presentMoviePlayerViewControllerAnimated:) withMethod:@selector(nonanimatedPresentMoviePlayerViewControllerAnimated:) error:&err];
    [UIViewController jr_swizzleMethod:@selector(dismissMoviePlayerViewControllerAnimated) withMethod:@selector(nonanimatedDismissMoviePlayerViewControllerAnimated) error:&err];

You may need to import

#import "JRSwizzle.h"
#import "UIViewController.h"

in
AppController.mm

After that the video played without the scrolling transition.
Thanks coquifrogs!

Any solution? I encountered that in Unity 3.3 this bug was not there, but Unity 3.4 will have this bug.

How could I play it with my own code? I know how to play a video with objective-C but I dont know how to find out the location of the Streaming folder of unity.