iOS seamless video loop using AVPlayer

I’ve been lately hacking a new app, Fireplace Deluxe for the new Apple TV thingy, and had to deal with looping videos.

The usual way to implement this is getting a notification for AVPlayerItemDidPlayToEndTimeNotification and rewind the video. But this introduces some milliseconds of lag and give us some undesired hiccups.

There is not much info about this but a nice way to solve the issue is by using the AVQueuePlayer and inserting videos in the queue indefinitely as long as they are being played.

This will render a nice seamless video loop without annoying hiccups.

#import <UIKit/UIKit.h>
@import AVKit;

@interface VideoViewController : AVPlayerViewController

#import "VideoViewController.h"

@implementation VideoViewController
    NSURL* videoURL;
    AVQueuePlayer* queue;

- (void)viewDidLoad {
    [super viewDidLoad];
    NSString *resourceName = @"";
    NSString* movieFilePath = [[NSBundle mainBundle]
                               pathForResource:resourceName ofType:nil];
    videoURL = [NSURL fileURLWithPath:movieFilePath];
    AVPlayerItem *video = [[AVPlayerItem alloc] initWithURL:videoURL];
    queue = [[AVQueuePlayer alloc] initWithItems:@
    video = [[AVPlayerItem alloc] initWithURL:videoURL];
    [queue insertItem:video afterItem:nil];
    self.player = queue;
    self.showsPlaybackControls = FALSE;

    [self.player play];
    NSNotificationCenter *noteCenter = [NSNotificationCenter defaultCenter];
    [noteCenter addObserverForName:AVPlayerItemDidPlayToEndTimeNotification
                usingBlock:^(NSNotification *note) {
                    AVPlayerItem *video = [[AVPlayerItem alloc] initWithURL:videoURL];
                    [queue insertItem:video afterItem:nil];


Gearsystem Emulator

So this is my latest project.

After finishing and polishing my Game Boy emulator I wanted a new challenge. Something a little bit more complex.

I tried the Master System and to my surprise I found that it is rather easy to emulate. The CPU (Zilog Z80) is somewhat harder but the system is quite simple compared to the Game Boy and Game Boy Color. Most games aren’t very sensitive to timing and the VDP is easy to implement.

So after some weeks of work I have it running most games flawlessly.

I made it multi-platform so it can run on iOS, Windows, Linux, Mac OS X and Raspberry Pi.

You can get it here:

And now what? NES maybe?




To me, DevOps is a label that describes a situation where there are no walls, no gates, no transitions, and no ceremony between Development and Operations.

They are seamlessly integrated (when viewed from “above”) into a single, value delivering, IT entity. From within, there may be individuals who specialize on “one side or the other,” but even those individuals interface seamlessly and directly without the need for an intermediary.

Most importantly (in my humble opinion) DevOps means that everyone—from Jr Analyst, to Mid Dev, to Sr. Test, to Director of IT—is equally responsible and accountable for the product from inception through retirement, meaning the Devs are just as likely to be maintaining the system in Prod as the Sys Admins are, to be doing configuration testing in the Dev Environment.

The rise and fall of Gearboy on Cydia

After several months of hard work my Game Boy Color emulator Gearboy can be considered as finished.

It has sound, full emulation of the most usual memory bank controllers, save files, disassembler, frame mixing and can be played on many platforms including Windows, Mac OS, Linux, iOS and Raspberry Pi.

The compatibility is pretty high. It can run almost all Game Boy and Game Boy Color games. Most of them run flawlessly.

If you are interested you can grab the full source code and binaries from here:

Some days ago I had the happy idea of selling the iOS port on Cydia. It was a good idea indeed.

This attracted a lot of people on Twitter and the news of a new Game Boy emulator running on iPhone 5 got viral. Quite a lot of people were asking me about the emulator, its features and when it was going to be released.

Gearboy eventually went live on Cydia and was selling pretty fast when suddenly, only a few hours later, I got an email from Saurik telling me he was having some issues with PayPal not allowing payments for the emulator. So he decieded to refund all customers and pull the emulator out of Cydia.

This was sad 🙁

Anyway, I learnt a lot by writing Gearboy and it was quite funny. In the end, my real interest is just to learn how consoles do work.