by sampathdr » Thu Feb 23, 2012 6:13 am
I am try to publish audio only chat stream. But it is not working. can anyone tell is there any missing item in this code.
- Code: Select all
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><title>
</title>
<script src="http://staging.tokbox.com/v0.91/js/TB.min.js" type="text/javascript"></script>
<script type="text/javascript">
var apiKey = '1127';
var sessionId = '14685d1ac5907f4a2814fed28294d3f797f34955'
var EnableVideo = 'False'
var token = 'devtoken';
TB.setLogLevel(TB.DEBUG);
var session = TB.initSession(sessionId);
session.addEventListener('sessionConnected', sessionConnectedHandler);
session.addEventListener('streamCreated', streamCreatedHandler);
session.connect(apiKey, token);
var publisherProperties = new Object();
var publisher;
function sessionConnectedHandler(event)
{
publisherProperties.publishVideo = EnableVideo;
publisher = session.publish('myPublisherDiv', publisherProperties);
publisher.publishVideo(EnableVideo)
subscribeToStreams(event.streams);
}
function streamCreatedHandler(event) {
// Subscribe to any new streams that are created
subscribeToStreams(event.streams);
}
function subscribeToStreams(streams) {
for (var i = 0; i < streams.length; i++) {
// Check that connectionId on the stream to make sure we don't subscribe to ourself
if (streams[i].connection.connectionId == session.connection.connectionId) {
return;
}
// Create the div to put the subscriber element in to
var div = document.createElement('div');
div.setAttribute('id', 'stream' + streams[i].streamId);
document.body.appendChild(div);
// Subscribe to the stream
session.subscribe(streams[i], div.id);
}
}
</script>
</head>
<body bgcolor="#000000">
<div id="logo">
<image src="MainLogoTextNew.png"> </image>
</div>
<div id="myPublisherDiv"></div>
</body>
</html>
Was this post helpful?
(0)