Repository navigation
iOS Everyplay Tutorial
This tutorial will walk you through EveryplayTutorial, an example app from the everyplay-ios-examples repository.
Areas covered in this document:
- Basic Everyplay clientId / secret initialization
- Everyplay delegate handling
- Adding metadata to recorded videos to improve user experience and navigation
- Adding simple UI buttons for launching Everyplay view, start/stop recording and playing the last recorded video
For more detailed information about methods available, see iOS Class Reference documentation.
Before starting with this document, make sure you've read and understood the prerequisite documentation:
Download Everyplay SDK and examples from Github
% git clone https://github.com/Everyplay/everyplay-ios-sdk.git
% git clone https://github.com/Everyplay/everyplay-ios-examples.git
% cd everyplay-ios-examples
% open -a Xcode EveryplayTutorial.xcodeproj
- Drag the Everyplay.framework and Everyplay.bundle to EveryplayTutorial project
- Select the
EveryplayTutorialtarget and checkLinked Frameworks and Librariesfrom theSummarytab, ensure you link against at least these frameworks:- AdSupport (iOS 6+, set to
Optionallink for pre-iOS 6 compatibility) - AssetsLibrary
- AudioToolbox (previously added to EveryplayTutorial)
- AVFoundation
- CoreGraphics (previously added to EveryplayTutorial)
- CoreImage (iOS 5+, set to
Optionallink for pre-iOS 5 compatibility) - CoreMedia
- CoreVideo
- Foundation (previously added to EveryplayTutorial)
- MessageUI
- MobileCoreServices
- OpenGLES (previously added to EveryplayTutorial)
- QuartzCore (previously added to EveryplayTutorial)
- Security
- Social (iOS 6+, set to
Optionallink for pre-iOS 6 compatibility) - StoreKit
- SystemConfiguration
- Twitter (iOS 5+, set to
Optionallink for pre-iOS 5 compatibility) - UIKit (previously added to EveryplayTutorial)
- AdSupport (iOS 6+, set to
- In the view controller header
ERViewController.h, import Everyplay header umbrella and add a delegate for Everyplay
*/
#import <UIKit/UIKit.h>
#import <QuartzCore/QuartzCore.h>
#import "EAGLView.h"
#import "Config.h"
-@interface ERViewController : UIViewController {
+#import <Everyplay/Everyplay.h>
+
+@interface ERViewController : UIViewController <EveryplayDelegate> {
EAGLContext *context;
GLuint program;
BOOL animating;
NSInteger animationFrameInterval;
CADisplayLink *__unsafe_unretained displayLink;-
In the application delegate implementation
ERAppDelegate.m, add the initialization of Everyplay with the clientId, secret and redirectURI atapplication:didFinishLaunchingWithOptions:method.For Everyplay delegates and view handling, you'll need to pass an instance used for delegate handling and the view controller. In this example, using
ERViewControllerhandles both.
self.viewController = [[ERViewController alloc] initWithNibName:@"ERViewController_iPhone" bundle:nil];
} else {
self.viewController = [[ERViewController alloc] initWithNibName:@"ERViewController_iPad" bundle:nil];
}
self.window.rootViewController = self.viewController;
[self.window makeKeyAndVisible];
+ // Initialize Everyplay SDK with our client id and secret.
+ // These can be created at https://developers.everyplay.com
+ [Everyplay setClientId:@"b459897317dc88c80b4515e380e1378022f874d2" clientSecret:@"f1a162969efb1c27aac6977f35b34127e68ee163" redirectURI:@"https://m.everyplay.com/auth"];
+
+ // Tell Everyplay to use our rootViewController for presenting views and for delegate calls.
+ [Everyplay initWithDelegate:self.viewController andParentViewController:self.window.rootViewController];
+
return YES;
}
- (void)applicationWillResignActive:(UIApplication *)application
{
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.-
Getting close for testing! Let's add a few buttons and Everyplay delegate handlers in our
ERViewControllerimplementation and you should be ready for build & run the app.In
everyplayRecordingStopped, we add metadata to just recorded session. In your game, it could be things like highscore, level played or the character used.For improved user experience, we recommend adding metadata for improved navigation and searching. Future iterations of Everyplay will use this information for showing information about gameplay and you may also use them for personal use via server API.
NUM_ATTRIBUTES
};
@interface ERViewController ()
@property (nonatomic, strong) EAGLContext *context;
@property (nonatomic, unsafe_unretained) CADisplayLink *__unsafe_unretained displayLink;
@property (nonatomic) NSString *song1;
+@property (nonatomic, retain) IBOutlet UIButton *everyplayButton;
+@property (nonatomic, retain) IBOutlet UIButton *recordButton;
+@property (nonatomic, retain) IBOutlet UIButton *videoButton;
+
- (BOOL)loadShaders;
- (BOOL)compileShader:(GLuint *)shader type:(GLenum)type file:(NSString *)file;
- (BOOL)linkProgram:(GLuint)prog;
- (BOOL)validateProgram:(GLuint)prog;
@end
@implementation ERViewController
@synthesize animating;
@synthesize context;
@synthesize displayLink;
+@synthesize everyplayButton;
+@synthesize recordButton;
+@synthesize videoButton;
+
- (void)dealloc
{
if (program) {
glDeleteProgram(program);
program = 0;
}
...
[_song1 getCString:buffer maxLength:200 encoding:NSASCIIStringEncoding];
result = fmod_system->createSound(buffer, FMOD_SOFTWARE | FMOD_LOOP_NORMAL, NULL, &sound1);
result = fmod_system->playSound(FMOD_CHANNEL_FREE, sound1, false, &channel);
#endif
// Do any additional setup after loading the view, typically from a nib.
+ [self createButtons];
}
- (void)viewDidUnload
{
[super viewDidUnload];
if (program) {
...
- (BOOL) shouldAutorotate {
return YES;
}
#pragma mark -
+- (void)createButtons {
+ int buttonX = 10;
+ int buttonY = 10;
+ int buttonWidth = 200;
+ int buttonHeight = 40;
+ int padding = 8;
+
+ everyplayButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
+ everyplayButton.frame = CGRectMake(buttonX, buttonY, buttonWidth, buttonHeight);
+ [everyplayButton setTitle: @"Everyplay" forState: UIControlStateNormal];
+ [everyplayButton setTitleColor: [UIColor blackColor] forState: UIControlStateNormal];
+ [everyplayButton setTitleColor: [UIColor yellowColor] forState: UIControlStateHighlighted];
+
+ [everyplayButton addTarget:self action:@selector(everyplayButtonPressed:)
+ forControlEvents:UIControlEventTouchUpInside];
+ [self.view addSubview: everyplayButton];
+
+ buttonY = buttonY + buttonHeight + padding;
+ recordButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
+ recordButton.frame = CGRectMake(buttonX, buttonY, buttonWidth, buttonHeight);
+ [recordButton setTitle: @"Start Recording" forState: UIControlStateNormal];
+ [recordButton setTitleColor: [UIColor blackColor] forState: UIControlStateNormal];
+ [recordButton setTitleColor: [UIColor yellowColor] forState: UIControlStateHighlighted];
+
+ [recordButton addTarget:self action:@selector(recordButtonPressed:)
+ forControlEvents:UIControlEventTouchUpInside];
+ [self.view addSubview: recordButton];
+
+ buttonY = buttonY + buttonHeight + padding;
+ videoButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
+ videoButton.frame = CGRectMake(buttonX, buttonY, buttonWidth, buttonHeight);
+ [videoButton setTitle: @"Play Last Recording" forState: UIControlStateNormal];
+ [videoButton setTitleColor: [UIColor blackColor] forState: UIControlStateNormal];
+ [videoButton setTitleColor: [UIColor yellowColor] forState: UIControlStateHighlighted];
+ videoButton.hidden = YES;
+
+ [videoButton addTarget:self action:@selector(videoButtonPressed:)
+ forControlEvents:UIControlEventTouchUpInside];
+ [self.view addSubview: videoButton];
+}
+
+- (IBAction)everyplayButtonPressed:(id)sender {
+ [[Everyplay sharedInstance] showEveryplay];
+}
+
+- (IBAction)recordButtonPressed:(id)sender {
+ if ([[[Everyplay sharedInstance] capture] isRecording]) {
+ [[[Everyplay sharedInstance] capture] stopRecording];
+ } else {
+ [[[Everyplay sharedInstance] capture] startRecording];
+ }
+}
+
+- (IBAction)videoButtonPressed:(id)sender {
+ [[Everyplay sharedInstance] playLastRecording];
+}
+
+#pragma mark - Delegate Methods
+- (void)everyplayShown {
+ NSLog(@"everyplayShown");
+
+ [self stopAnimation];
+#if USE_AUDIO
+ channel->setMute(true);
+#endif
+}
+
+- (void)everyplayHidden {
+ NSLog(@"everyplayHidden");
+
+ [self startAnimation];
+#if USE_AUDIO
+ channel->setMute(false);
+#endif
+}
+
+- (void)everyplayRecordingStarted {
+ NSLog(@"everyplayRecordingStarted");
+
+ [recordButton setTitle:@"Stop Recording" forState:UIControlStateNormal];
+}
+
+- (void)everyplayRecordingStopped {
+ NSLog(@"everyplayRecordingStopped");
+
+ [recordButton setTitle:@"Start Recording" forState:UIControlStateNormal];
+ videoButton.hidden = NO;
+
+ [[Everyplay sharedInstance] mergeSessionDeveloperData:@{@"testString" : @"hello"}];
+ [[Everyplay sharedInstance] mergeSessionDeveloperData:@{@"testInteger" : @42}];
+}
+
@end- EveryplayTutorial is also available as a finished example (
EveryplayRecord) with some extra addons at everyplay-ios-examples.

