Quick Start Guide
Once you signup for a StreamAPI account you will see your API key and Secret key in the API Settings page. You will need these for all HTTP API calls.
API Settings
The first step in getting started is creating one or more themes. A theme is a layout and skin set. It defines the look and feel of your Flash streaming interface. A simple theme may only include a single video feed and a more complex one might include multiple video feeds, text chat, and buttons that provide additional functionality. You should design your theme to match the look of your site or brand. You create themes using the Theme Editor from within your StreamAPI control panel.
Theme editor
A typical theme might include a Host video and one or more Guest video components. It may also include User List, Simple Button, Text Input, and Chat Text components.
Simple default theme (4:3 video feed with text chat)
When the host wants to begin broadcasting you create a new session using the REST API and pass the Private Host ID and Public Host ID in the Flash embed for them as Flashvar parameters.
When a viewer wants to begin watching the host's broadcast you display a Flash embed with the Public Host ID of the Host's session passed as a Flashvar parameter.
1) Create your custom themes
From the "Theme Editor" navigation link, click the "New Theme" button to launch the Theme Editor with a new blank theme.
When you save a new theme a skinPath and layoutPath will be generated. These paths are static and will not change when you save the same theme again. You will reference them when generating HTML embed code.
2) Create a session
For a user to broadcast a video stream you will need to create a new StreamAPI session.
API calls, such as creating a new session, are always made directly from your server to StreamAPI. No REST API requests are ever made directly from your user's web browser to StreamAPI.
Request
POST http://api.streamapi.com/service/session/create
rid => 123456
sig => ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGH
Optional request parameters
- site_user_id This sets the public_hostid to your own site's user ID. So if in your database a user has id 123456 that will also be the public_hostid for their stream.
- username Displayed as the name of the user in a User List component or onscreen overlay in the Host video.
Response
private_hostid
C0UC4WO3ATORK259QL1STSIZO7RB1G5I
public_hostid
1745122342
Client API example (Perl)
use WWW::StreamAPI;
my $streamapi = WWW::StreamAPI->new(
secret_key => 'YOUR_SECRET_KEY_HERE',
api_key => 'YOUR_API_KEY_HERE',
);
my ($private_hostid, $public_hostid) = $streamapi->create_session(
username => 'Peter',
site_user_id => 123456, # Optionally overrides public_hostid
);
3) Embed the session.
Every StreamAPI session has a private host ID and a public host ID associated with it. The private session ID is to be given only to the broadcaster themselves. The public host ID is used to view the stream by viewers.
The public hostID and private host ID are embeded as Flashvar arguments for the broadcaster:
<div id="player_container"></div>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/swfobject/2.1/swfobject.js"></script>
<script type="text/javascript">
swfobject.embedSWF("http://static.streamapi.com/flash/loader.swf", "player_container", "500", "500", "9", "", {
'app' : 'custom.swf',
'siteID' : '1265428111',
'publicHostID' : '1745122342',
'layoutPath' : '/themes/126/542/811/1/theme_03d2cdd0-1d8b-11de-a2c3-f7f8349311a2.xml',
'skinPath' : '/themes/126/542/811/1/skin_03d2cdd0-1d8b-11de-a2c3-f7f8349311a2.xml',
'privateHostID' : 'C0UC4WO3ATORK259QL1STSIZO7RB1G5I',
'userType' : 'host'
}, {
allowfullscreen: "true",
allowscriptaccess: "true"
});
</script type="text/javascript">
The viewer side embed uses the public host ID:
<div id="player_container"></div>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/swfobject/2.1/swfobject.js"></script>
<script type="text/javascript">
swfobject.embedSWF("http://static.streamapi.com/flash/loader.swf", "player_container", "500", "500", "9", "", {
'app' : 'custom.swf',
'siteID' : '1265428111',
'layoutPath' : '/themes/126/542/811/1/theme_03d2cdd0-1d8b-11de-a2c3-f7f8349311a2.xml',
'skinPath' : '/themes/126/542/811/1/skin_03d2cdd0-1d8b-11de-a2c3-f7f8349311a2.xml',
'publicHostID' : '1745122342',
'userType' : 'viewer'
}, {
allowfullscreen: "true",
allowscriptaccess: "true"
});
</script type="text/javascript">
SWFObject
The embedding examples shown here utlize the SWFObject javascript library for generating embed codes. http://code.google.com/p/swfobject/. This is the recommended way of generating proper HTML Flash embeds. You are also free to generate them manually or using a different library.