Several partners have been asking us about the options around getting access to media streams as they come and go from an iOS device. While more robust media access features are further off, I wanted to take some time to explore the options an iOS developer can play with today.
The UIKit view hierarchy integrates with a fairly simple animation and compositing API. Every instance of UIView is backed by an animation layer (CALayer), which can be accessed (and manipulated) without much complexity. A neat thing about CALayer is that you render its contents at any time using the
renderInContext: method. Most often, your render target is the window, which is managed by the UIKit view hierarchy, so none of this knowledge is particularly compelling. Unless of course, you wanted to render the contents of the animation layer to a bitmap in memory to perform, say, facial recognition with the iOS 5 CIDetector.
The OpenTok iOS SDK lets you use OpenTok video sessions in apps you build for iPad, iPhone, and iPod touch devices. This means you can use OpenTok video sessions that connect iOS users with each other and with web clients.
Update: March 13, 2014 – Please note that this blog post references the archiving functionality in our OpenTok 1.0 platform. This feature is no longer being supported. Learn more about archiving using our OpenTok 2.0 platform.
Minutegrams is a webapp to send video messages via email.
In this tutorial, let’s build a video recorder with the Tokbox API.
- We need ‘rElement’ div to put our recorder in, and ‘pElement’ div to put player in.
Step 2: Create a Tokbox recorder Manager object
This past week Pasha from PuppetSmith.com wanted to create a simple way for the admins on his site to publish a stream and have all non-admins as viewers. You could certainly build this functionality yourself with the full API, but it would be nice to have a quick solution for this common scenario.
You can visit the GitHub repo for the plug-in here.
Here is a sample implementation in PHP that generates a token, passes it down to the widget, then initializes.
Next weekend is our second HAPI Hack Weekend at our office in San Francisco and we’re excited to have a bunch of interesting APIs there to hack with. One API that I’m particularly excited about is Face.com, which gives developers a set of methods for easy face recognition.
I created a simple app to introduce the basics of using OpenTok with Face.com:
You can now attach metadata for each client that connects to a session. For example, you can add information about the connecting user. When a client connects to the session, all existing clients connected to the session can access the metadata for the new connection.
You add this metadata by passing it into the generate_token() method of the OpenTok server-side library. The metadata is then securely embedded in the token string. Here’s an example, using the OpenTok PHP library:
The plugin is hosted at github.com:
Using the jQuery plugin, you can fully integrate OpenTok into your jQuery-based apps.
To use the plug-in, include the OpenTok, jQuery, and jquery.opentok scripts in your HTML page:
The first plugin is the _OT.widget, which makes it simple to create a videochat widget similar to the HTML embed widget seen here.
You are developing a multi-user OpenTok application and you need a way to pass data between user in real-time.
Use Session.signal() to notify user when there is new data on the server to be retrieved.
In this tutorial I will show you how to implement this solution by creating a simple chat app that uses OpenTok signals to pass data between users in an OpenTok session. The app will allow connected users to communicate through both video chat and text chat.
I will use Rails for the backend portion of the app, however this technique can be applied to any server-side technology. I also use jQuery for DOM manipulation and AJAX and the OT_LayoutContainer class created and explained in this blog post for managing the layout of the video streams.