Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8728591
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T08:40:32+00:00 2026-06-13T08:40:32+00:00

I looked at these links http://www.tokbox.com/opentok/api/tools/js/documentation/overview/publish.html http://www.tokbox.com/opentok/api/tools/js/tutorials/overview but their are no examples for publishingunpublishing

  • 0

I looked at these links

http://www.tokbox.com/opentok/api/tools/js/documentation/overview/publish.html

http://www.tokbox.com/opentok/api/tools/js/tutorials/overview

but their are no examples for publishingunpublishing manually, that is, publishing/unpublishing without using ‘streamCreated’/’streamDestroyed’ event handler respectively.

The reason I want to do this is that I have a button to publish/unpublish so that the user can do it at will.

Is there a way to do this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T08:40:33+00:00Added an answer on June 13, 2026 at 8:40 am

    Yes and it is very simple. Check out the prepublish source code to see how. There are 2 functions, startPublishing() and stopPublishing() which achieve this.

    Primarily they use session.publish(publisher);to publish and session.unpublish(publisher); to unpublish.

    Here is code I have used to work off:

    // Called by a button to start publishing to the session
    function startPublishing() {
        if (!publisher) {
            var parentDiv = document.getElementById("myCamera");
            var publisherDiv = document.createElement('div'); // Create a div for the publisher to replace
            publisherDiv.setAttribute('id', 'opentok_publisher');
            parentDiv.appendChild(publisherDiv);
            var publisherProps = {
                width : VIDEO_WIDTH,
                height : VIDEO_HEIGHT
            };
            publisher = TB.initPublisher(apiKey, publisherDiv.id, publisherProps); // Pass the replacement div id and properties
            session.publish(publisher);
            show('unpublishLink');
            hide('publishLink');
        }
    }
    
    //Called by a button to stop publishing to the session
    function stopPublishing() {
        if (publisher) {
            session.unpublish(publisher);
        }
        publisher = null;
    
        show('publishLink');
        hide('unpublishLink');
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm following a tutorial on Zend Framework here (http://www.ibm.com/developerworks/opensource/tutorials/os-php-zend2/section2.html). I barely got started, but
I looked at this site example: http://www.codesampler.com/dx9src/dx9src_6.htm But the code is rather weird: it
I have looked at the documentation on MSDN about these 2 functions. However, I
I'm trying my hand at jQuery Address http://www.asual.com/jquery/address/ On a click event I set
I'm trying to run the example found here: http://thysmichels.com/2012/01/31/java-based-hdfs-api-tutorial/ But when I go to
I have looked at the following links, but nothing seems concrete. Secure HTTP Post
I'm adding a unit converter to my website from this link: http://www.unitconversion.org/faq.html And as
Here's my code for my Facebook share link: <a href=<%= HttpUtility.UrlPathEncode(http://www.facebook.com/sharer.php?u=http://www.apoads.com+ Request.Url.PathAndQuery) %> title=Share
I have implemented a paging UIScrollView following this excellent tutorial: http://www.iosdevnotes.com/2011/03/uiscrollview-paging/ The UIScrollView works
I wanna change APN settings in a phone. Looked the api and there is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.