Click here to Skip to main content
15,900,461 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,
we are implementing video chatting between 2persons. here enable/disable buttons is there. when i click enable button video chatting ok, but when click disable button showing error like "
C#
The stream was unable to connect due to a network error. Make sure your connection isn't blocked by a firewall

". pls give some solution on it..

C#
I use the latest opentok Android SDK to development an application. My purpose is to provide a button to let user can publish / unpublish camera. It works to unpublish the camera OT.initPublisher("publisherContainer", publisherOptions).publishVideo(false);, but it doesn't work to republish when I use OT.initPublisher("publisherContainer", publisherOptions).publishVideo(true);.



JavaScript
<script src="//static.opentok.com/webrtc/v2.2/js/opentok.min.js" ></script>

$(document).ready(function () {
        var apikey = "xxxxx";
        var sessionI = "@Session["SessionId"]";
        var token = "@Session["Token"]";
        var videoOn = true;
        var session = OT.initSession(apikey, sessionI);
        
        session.connect(token, function (err) {
            if (err) {
                alert("Vendor  video call disconnected");
            }
            else {
                var publisherOptions = {
                    insertMode: "append",
                    height: "260px",
                    width: "450px",                    
                }
 var publisher = OT.initPublisher("publisherContainer", publisherOptions);
                $('#disablevideo').click(function () {
                    if (videoOn == true)
                    {
                        publisher.destroy();
                        publisher = OT.initPublisher("publisherContainer", publisherOptions).publishVideo(false);
                        videoOn = false;
                        session.publish(publisher);
                        
                    }
                    else {
                        publisher.destroy();
                        publisher = OT.initPublisher("publisherContainer", publisherOptions).publishVideo(true);
                        videoOn = true;
                        session.publish(publisher);
                        
                    }
                });
                session.publish(publisher);
            }
        });
        session.on("streamCreated", function (event) {
            var options = {
                insertMode: 'append',
                height: "450px",
                width: "720px",
            }
            
            session.subscribe(event.stream, 'containerElementId', options)
            $("#vendoename").hide();
            clearInterval(interval);
        });


thank you.
Posted
Updated 6-Jan-16 0:54am
v4
Comments
Richard MacCutchan 5-Jan-16 10:55am    
Don't click the disable button.
Member 12220880 6-Jan-16 1:55am    
hi, i need both. means for video option purpose. audio is always running in chat time, when i click disable button that time only video not visible to another chat user.
Richard MacCutchan 6-Jan-16 3:30am    
Which means absolutely nothing. Please edit your question and provide proper details of the code that is not working.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900