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
0
Question by pajamajama · Sep 24, 2013 at 04:30 AM · iosloopmovieplayfullscreenmovie

How To Loop FullScreen Video On IOS

Hello, Thank you very much for your time and wisdom! I am trying to loop a fullscreen video on IOS indefinitely, and only close the video once a user has touched the screen. I got the movie to play fine and cancel on input, but there doesn't seem to be any documentation on making the video loop. The default behavior is for it to just play once and close automatically.

I'm using: PlayFullScreenMovie(path, Color, FullScreenMovieControlMode.CancelOnInput)

How can I implementing a looping movie on IOS?

Comment
Add comment · Show 5
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 exerion · Oct 09, 2013 at 10:42 PM 0
Share

Hi pajamajama :)

Did you ever figure out a solution to this problem? I need the same functionality.

avatar image pajamajama · Oct 09, 2013 at 11:37 PM 0
Share

I did. It's quite complicated and involves augmenting the xcode project. When I have a little more time tonight I'll write up some instructions.

avatar image exerion · Oct 09, 2013 at 11:52 PM 0
Share

Thanks pajamajama that would be awesome! :)

avatar image Avinash · Oct 23, 2013 at 06:09 AM 0
Share

@$$anonymous$$majama can you pls post your solution

avatar image pajamajama · Oct 24, 2013 at 03:25 AM 0
Share

Yes. Writing it up now. Sorry, been very busy with work.

2 Replies

· Add your reply
  • Sort: 
avatar image
0
Wiki

Answer by pajamajama · Oct 24, 2013 at 03:39 AM

My solution may be a little long winded. Would love to see some more straightforward code, Objective-C really confuses me so I had to do a lot of trial and error. Also to my knowledge there is no way to do this yet within Unity. It needs to be done inside Xcode project.

This solution also removes the sliding animation for when the movie file comes up.

  1. Get JRSwizzle.h and JRSwizzle.m from github. Place both files in your Classes folder inside the Xcode project.

  2. 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
    
    
  3. Locate the class AppController.mm and put the following code inside "didFinishLaunchingWithOptions():"

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

and put these two lines at the top of AppController.mm

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

That should work! Good Luck!

The line below is responsible for looping the video. It's in the UIViewController.h code above.

 moviePlayerViewController.moviePlayer.repeatMode = MPMovieRepeatModeOne;



Comment
Add comment · Show 1 · 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 robot-ink · Jan 12, 2014 at 02:13 AM 0
Share

Thanks for posting, this works great!

avatar image
0

Answer by leothener · Jan 29, 2017 at 09:41 AM

PlayFullScreenMovie is actually implemented in FullScreenVideoPlayer.mm under iOS project.

There are 2 classes to consider:

AVKitVideoPlayback

Inside actuallyStartTheMovie:(NSURL*)url function add:

 videoViewController.player.actionAtItemEnd = AVPlayerActionAtItemEndNone;
     
     [[NSNotificationCenter defaultCenter] addObserver:self
                                              selector:@selector(playerItemDidReachEnd:)
                                                  name:AVPlayerItemDidPlayToEndTimeNotification
                                                object:[videoViewController.player currentItem]];

Under onPlayerDidFinishPlayingVideo function:

remove [self finish];

Under - (void)finish

 [[NSNotificationCenter defaultCenter] removeObserver:self
                                                     name:AVPlayerItemDidPlayToEndTimeNotification
                                                   object:[videoViewController.player currentItem]];

Add new function:

 - (void)playerItemDidReachEnd:(NSNotification *)notification
 {
 
   AVPlayerItem *p = [notification object];
   [p seekToTime:kCMTimeZero];
   [videoViewController.player play];
 }

MPVideoPlayback (for old iOS)

Under - (void)actuallyStartTheMovie:(NSURL*)url function

 moviePlayer.repeatMode = MPMovieRepeatModeOne;


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

20 People are following this question.

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

Related Questions

The name 'Joystick' does not denote a valid type ('not found') 2 Answers

How to play the movie without a seek bar on iOS8& avoid crashing on iOS5 devices? 0 Answers

How to tilt the gameobject based of Input.Acceleration? 0 Answers

Facebook unity sdk: is it possible to send friend invites/app requests to non app users ? 1 Answer

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