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 8873551
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T18:29:36+00:00 2026-06-14T18:29:36+00:00

I am trying to play a video clip that loops indefinitely. I am doing

  • 0

I am trying to play a video clip that loops indefinitely. I am doing this the way Apple recommends; by setting up a notification that gets triggered by AVPlayerItemDidPlayToEndTimeNotification:

@property(nonatomic) AVPlayer *videoPlayer;
@property(nonatomic) AVPlayerItem *videoPlayerItem;

-(void)loadVideo
{
    NSURL *url = [[NSBundle mainBundle] URLForResource:filename withExtension:extension];
    AVURLAsset *asset = [AVURLAsset URLAssetWithURL:url options:nil];
    NSString *tracksKey = @"tracks";

    [asset loadValuesAsynchronouslyForKeys:@[tracksKey] completionHandler:
    ^{
        dispatch_async(dispatch_get_main_queue(),
        ^{
            NSError *error;
            AVKeyValueStatus status = [asset statusOfValueForKey:tracksKey error:&error];

            if (status == AVKeyValueStatusLoaded)
            {
                [self setVideoPlayerItem:[AVPlayerItem playerItemWithAsset:asset]];
                [videoPlayerItem addObserver:self forKeyPath:@"status" options:0 context:&ItemStatusContext];
                [[NSNotificationCenter defaultCenter] addObserver:self
                                                         selector:@selector (videoPlayerItemDidReachEnd:)
                                                             name:AVPlayerItemDidPlayToEndTimeNotification
                                                           object:videoPlayerItem];
                [self setVideoPlayer:[AVPlayer playerWithPlayerItem:videoPlayerItem]];
                [scenePlayerView setVideoPlayer:videoPlayer];
            }
        });
    }];
}

When triggered, this calls my method to effectively rewind and play the clip again:

-(void)videoPlayerItemDidReachEnd:(NSNotification *)notification
{
    [videoPlayerItem seekToTime:kCMTimeZero];
    [videoPlayer play];
}

The problem is, there is a brief but visible pause in the video playback every time it hits this method and loops back to the beginning.

The video clips are H.264 and have been tested in other players to ensure that they have no visible “skips” in their content. This is all happening under iOS6 both in the Simulator and on an iPad2 and iPad3.

What am I doing wrong?

  • 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-06-14T18:29:37+00:00Added an answer on June 14, 2026 at 6:29 pm

    Unfortunately it appears this actually is not currently possible using AVPlayer as it stands- there is an unavoidable hiccup upon beginning playback in an AVPlayer in every case. So “messier” hacks appear to be the only way to solve this, using multiple AVPlayers, etc.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to play video from youtube using this code but I get this
I am trying to play a video from video path that I have in
I've heard that Windows Media Player has problems trying to play H.264 video over
While trying to play video using media player, I am getting this error: Unable
I am trying to play a video that is stored in an NSData object.
I am trying to play a video that is on my server. its short
I am using VideoView trying to play video. But when I use this code
I'm trying to play a video and have a button that switches the video
I have been trying to play a video that was converted using http://www.mirovideoconverter.com/ to
I am trying to record and play video simultaneously. Is this possible with avfoundation?

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.