index.html
- Code: Select all
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>OpenTok Getting Started</title>
<script src="http://static.opentok.com/webrtc/v2.0/js/TB.min.js" type="text/javascript"></script>
<script type="text/javascript">
var apiKey = '******';
var token = '*****';
var sessionId = '*****';
var session = TB.initSession(sessionId);
session.addEventListener('sessionConnected', sessionConnectedHandler);
session.addEventListener('streamCreated', streamCreatedHandler);
session.connect(apiKey, token);
function sessionConnectedHandler(event) {
subscribeToStreams(event.streams);
session.publish();
}
function streamCreatedHandler(event) {
subscribeToStreams(event.streams);
}
function subscribeToStreams(streams) {
for (i = 0; i < streams.length; i++) {
var stream = streams[i];
if (stream.connection.connectionId != session.connection.connectionId) {
session.subscribe(stream);
}
}
}
</script>
</head>
<body>
</body>
</html>
I also tried
- Code: Select all
function sessionConnectedHandler(event) {
subscribeToStreams(event.streams);
publisher = TB.initPublisher(apiKey, 'myPublisherDiv');
session.publish(publisher);
}
...
<body>
<div id="myPublisherDiv"></div>
</body>
...
I tested locally at "file:///home/********/Downloads/index.html" in Chrome v23 at different platform, OSX, Win7, Ubuntu.
All I got on the web page is a black rectangular on the left up corner.
Error message from Console:
OT.rtc.Publisher.onStreamAvailableError Permission Denied
Uncaught ReferenceError: reason is not defined
(Please refer to attachment for detailed console screenshot)
I run the diagnose scan tool provided in the forum, the only minor issue pops out is: Port 443 should be open, Failed to connect
I am so confused, since I can successfully run the tutorial at http://tokbox.com/opentok/api/tools/js_webrtc/tutorials/helloworld.html.
----------------------------------------------------------------
I also tried the flash javaScript API, by utilizing the example source code, the Chrome simply keeps gave Connection Timeout alert message.