Audio Only stream

Ask questions about the JavaScript API here

Audio Only stream

Postby 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)
sampathdr
 
Posts: 4
Joined: Wed Feb 22, 2012 10:57 pm
Thumbs Up: 1

Re: Audio Only stream

Postby mumm » Thu Feb 23, 2012 11:23 pm

In your publisher.publishVideo() call you are passing in a string 'False'. Change that from a string to the boolean value false.
Was this post helpful? (1)
mumm
 
Posts: 392
Joined: Wed May 18, 2011 12:10 am
Thumbs Up: 28

Re: Audio Only stream

Postby sampathdr » Fri Feb 24, 2012 3:07 am

Thanks "mumm" it works :)
Was this post helpful? (1)
sampathdr
 
Posts: 4
Joined: Wed Feb 22, 2012 10:57 pm
Thumbs Up: 1


Return to JavaScript



Who is online

Users browsing this forum: No registered users and 2 guests

cron