How to enable Screen Recording in your app

A lot of developers have off late liked the idea that they could record gameplay and share with their friends on the internet. This is a good idea and one that a lot have on their wishlist. To be honest, to save you from reading the rest of the article, the answer is similar to what amny have posted, it is not possible, but my reasons are different than the ones posted by many others on various forums.

The reason that you cannot have screen recording is simple that you do not have a handle on the framebuffer of the OpenGL surface. If you did, and you could write a routine that allows you to make low level API calls, you can create your own videos. I am sure that many of you have seen the "Made with Codea" watermark on the videos. Mainly for the game CargoBot, a full fledged amazingly made game in Codea on an iPad.

So the question arises, how do they do it?

The answer is quite simple, they create a video from the screenshots taken from the framebuffer and then interleave it to make a video. I must say two things, Codea is a wonderful software that created waves when they released the wonderful editor. Now when the Codea Runtime has been released, it demonstrates how beautifully the code has been created, it is a trove of functions and routines that you can adapt in your own aps, learn from it and/or use it as intended to compile and release your Codea apps on to the iTunes App store. The second thing is despite it being a recent entrant, it has the most or comparable features to many other established frameworks. It is one of the few Lua based frameworks that can do 3D, something that many other lua based frameworks have not yet been able to add to their frameworks.

The best part of it all is that the Codea Runtime is OpenSource and Free, which means you can download it from GitHub and have a peek inside. I would not be surprised to see a couple of derivatives or developers creating a custom engine based on Codea Runtime for their own apps. The point of this post is not how wonderful Codea is, but that in the source code there is a file in the CodeaTemplate->Codify directory called ScreenCapture.m and ScreenCapture.h these are the objective-C code files that allow for screencapture.

WHile I cannot say with certainty about Moai, CoronaSDK cannot use this functionality as it has no ability to add your own objective-C code. With Gideros, you can write your own plug-ins but I guess that you cannot use this routine as you cannot access the frameBuffer.

so in light of this, i would say that this point of time, you have the ScreenCapture methodology in front of you but you cannot use it with any of the other frameworks, not because it would be restricted by Apple or it violating other things, but for the plain fact that the frameworks do not provide you access to the bits that are required.

Saving the video to the PhotoAlbum is just as easy in Objective-C
- (void)saveMovieToCameraRoll
{
    ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];
    [library writeVideoAtPathToSavedPhotosAlbum:[self tempFileURL]                                
                                completionBlock:^(NSURL *assetURL, NSError *error) 
                                {
                                    if (error)
                                    {
                                        [self showError:error];
                                        [self removeTempFile];
                                    }
                                    else
                                    {
                                        [self removeTempFile];
                                    }                                    
//                                    dispatch_async(movieWritingQueue, ^
//                                    {
//                                        recordingWillBeStopped = NO;
//                                        self.recording = NO;
//                                        
//                                        [self.delegate recordingDidStop];
//                                    });
                                }];
    [library release];
}

If you have XCode and you download this Codea Runtime, you have a full engine to render and run a GUI, 3D lua based app for FREE... no more online compiling or annual subscriptions. The only problem is that it is not cross platform as yet but there are some developers that are working on creating a MacOSX template to port Codea Runtime from the iOS to the MacOSX so that you can port the app to a Mac OSX.

Have a peek, look whatever you want, while the competition will start to heat up with every other person moving into development, be it artists, designers, web coders, etc things will get better with more code and open source projects providing ready to use templates.

Comments

Popular Posts