Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3997100
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T07:21:38+00:00 2026-05-20T07:21:38+00:00

I have a small UIView that displays a repeated movie. When the user taps

  • 0

I have a small UIView that displays a repeated movie. When the user taps a button another movie is loaded and displayed in the same UIView.

The problem is that there is a half second “flash” between the removing of the first movie and the displaying of the second. Is there any to remove this?

- (void) setUpMovie:(NSString*)title {
NSString *url = [[NSBundle mainBundle] pathForResource:title ofType:@"mp4"];

MPMoviePlayerController *player = [[MPMoviePlayerController alloc] initWithContentURL:[NSURL fileURLWithPath:url]];
[[player view] setFrame:self.movieView.bounds];
[self.movieView addSubview:player.view];
if ([title isEqualToString:@"Bo_idle_02"]) {
    [player setRepeatMode:MPMovieRepeatModeOne];
} else {
    [player setRepeatMode:MPMovieRepeatModeNone];
}
[player setControlStyle:MPMovieControlStyleNone];
[player play];
}

- (void) startDanceAnimation { [self setUpMovie:@"Bo_dance_02"]; return; }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T07:21:38+00:00Added an answer on May 20, 2026 at 7:21 am

    I managed to get my movies changing without the white flash using the AVFoundation as suggested previously. sudo code below, hope it helps someone 🙂

    Apples reference docs can be found here and I used them to get most of my information:
    http://developer.apple.com/library/ios/#documentation/AudioVideo/Conceptual/AVFoundationPG/Articles/00_Introduction.html#//apple_ref/doc/uid/TP40010188-CH1-SW3

    The first thing I did was to add the following class, called PlayerView (can’t remember where I got it sorry) to my project. Its a subclass of UIView and its the view that the movie will be displayed in. Once you add it to your project open UI Builder, add a new view to an existing xib and change its class to PlayerView. Connect this using an IBOutlet. Again remember this is the view that will display the movie.

    PlayerView.h

    
    #import 
    #import 
    #import 
    
    @interface PlayerView : UIView {
        AVPlayer *player;
    }
    
    @property (nonatomic,retain) AVPlayer *player;
    
    @end
    

    PlayerView.m

    
    #import "PlayerView.h"
    
    
    @implementation PlayerView
    @synthesize player;
    
    + (Class)layerClass {
        return [AVPlayerLayer class];
    }
    - (AVPlayer*)player {
        return [(AVPlayerLayer *)[self layer] player];
    }
    - (void)setPlayer:(AVPlayer *)player {
        [(AVPlayerLayer *)[self layer] setPlayer:player];
    }
    
    - (void) dealloc {
        [super dealloc];
        [player release];
    }
    
    @end
    

    In the ViewContoller that displays the movies I have the following:

    DisplayMovies.h

    
    #import 
    #import 
    @class PlayerView;
    
    @interface DisplayMovies : UIViewController {
    IBOutlet AVPlayer *player;
    AVPlayerItem *movieOneItem;
    AVPlayerItem *movieTwoItem;
    }
    @property (nonatomic, retain) AVPlayer *player;
    @property (retain) AVPlayerItem *movieOneItem;
    @property (retain) AVPlayerItem *movieTwoItem;
    

    DisplayMovies.m

    
    @implementation DisplayMovies
    @synthesize player, movieOneItem, movieTwoItem;
    
    - (void)viewDidLoad {
    // load the two movies
    NSURL *movieOneItemURL = [[NSBundle mainBundle] URLForResource:@"movieOne" withExtension:@"mp4"];
        AVURLAsset *movieOneItemAsset = [AVURLAsset URLAssetWithURL:movieOneItemURL options:nil];
        self.movieOneItem = [AVPlayerItem playerItemWithAsset:movieOneItemAsset];
    
        [[NSNotificationCenter defaultCenter] addObserver:self
                                                 selector:@selector(movieOneItemDidReachEnd:)
                                                     name:AVPlayerItemDidPlayToEndTimeNotification
                                                   object:self.movieOneItem];
    
    NSURL *movieTwoItemURL = [[NSBundle mainBundle] URLForResource:@"movieTwo" withExtension:@"mp4"];
        AVURLAsset *movieTwoItemAsset = [AVURLAsset URLAssetWithURL:movieTwoItemURL options:nil];
        self.movieTwoItem = [AVPlayerItem playerItemWithAsset:movieTwoItemAsset];
    
        [[NSNotificationCenter defaultCenter] addObserver:self
                                                 selector:@selector(movieTwoItemDidReachEnd:)
                                                     name:AVPlayerItemDidPlayToEndTimeNotification
                                                   object:self.movieTwoItem];
        [self.player play];
    }
    
    
    - (void) movieOneItemDidReachEnd:(NSNotification*)notification {
    // play movie two once movie one finishes
        [self.player seekToTime:kCMTimeZero];
        [self.player replaceCurrentItemWithPlayerItem:self.movieTwoItem];
        [self.player play];
    }
    
    - (void) movieTwoItemDidReachEnd:(NSNotification*)notification {
    // play movie one once movie two finishes
        [self.player seekToTime:kCMTimeZero];
        [self.player replaceCurrentItemWithPlayerItem:self.movieOneItem];
        [self.player play];
    }
    
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a small UIView that should appear always in the center of the
I have a small UIView that I hide/show in to show a message to
That's tricky. I have a small button over a very big one. When the
I have small application that is uploading pictures to another website via webservice. My
I have this function that taking a screenshot of the a small UIView that
I have an MKMapView and another UIView subclass that is overlaid on top of
I have a class called GraphView that extends UIView that basically draws a small
I have a small floating UIView, viewHover, which acts as a container to 2
have small problem, and would very much appreciate help :) I should convert byte
I have small problem with Spring MVC. Basically what I'm trying to do is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.