New satnadalone publisher

Ask questions about the JavaScript API here

New satnadalone publisher

Postby giladani » Tue Jun 12, 2012 10:54 am

Hi John,

I saw the new APIs that were released, and I wanted to make sure that I follow.
If I user
var pulisher = TB.initPublisher();


- When is the publisher 'ready' for me to connect him to the finish? Should I just listen to "accessAllowed"? Is that enough?
-I assume that I can use the same publisher to publishe session A, then unpublish session A and publish session B, is that correct?

Regarding the camera & mic testing:
- I noted the new APIs, this is great. but regarding camera testing: Can I trust the "devicesDetectedHandler" to provide a selected camera object (i.e. event.selectedCamera.status) to provide the correct camera status? I know that before when it was called from the device panel, it might have sent "unknown" status sometimes...


Thanks,
Gil.
Was this post helpful? (0)
giladani
 
Posts: 187
Joined: Wed Apr 11, 2012 8:05 am
Thumbs Up: 2

Re: New satnadalone publisher

Postby song » Tue Jun 12, 2012 3:15 pm

Hi,

When you do var publisher = TB.initPublisher('divId'), you create a publishing window on the browser. This allows user to look at themselves and do necessary makeup, change webcam/audio settings, etc. Then when they are ready, you can do session.publish(publisher)

I would assume you have a button, so users click on it to connect when they are ready.
Yes that is correct. You can use that to publish to session A and to sessionB

You can trust devicesDetectedHandler. You might have gotten 'unknown' status if flash detected a device but did not know what it is.
Was this post helpful? (0)
song
 
Posts: 1667
Joined: Tue Jan 17, 2012 12:50 pm
Thumbs Up: 4

Re: New satnadalone publisher

Postby giladani » Wed Jun 13, 2012 12:03 am

Another question.... The new & old Apis for flash dialog events and allow/deny. Now connected to publisher instead of session, right?
But these events may dispatch befor I get the chance to register - so what happens if I don't register fast enough? I do plan to register as the first thing. Before detect devices.


Gil.
Was this post helpful? (0)
giladani
 
Posts: 187
Joined: Wed Apr 11, 2012 8:05 am
Thumbs Up: 2

Re: New satnadalone publisher

Postby giladani » Wed Jun 13, 2012 3:55 am

And... the publishH264 - this was per sessionConnected event, should't that be for a publisher now?

Gil.
Was this post helpful? (0)
giladani
 
Posts: 187
Joined: Wed Apr 11, 2012 8:05 am
Thumbs Up: 2

Re: New satnadalone publisher

Postby jtsai » Wed Jun 13, 2012 11:29 am

If you register right afterwards, then allow/deny events will always be on time to be called. We have code in the swf to make sure this happens. Also, for publishH264, since we built it off the previous publisher, it will wait until you join the session to display the information.

John
Was this post helpful? (1)
Very helpful resource: Devs Checklist
Examples with OpenTok: Examples
User avatar
jtsai
 
Posts: 1976
Joined: Wed Sep 14, 2011 3:00 pm
Thumbs Up: 157

Re: New satnadalone publisher

Postby giladani » Thu Jun 14, 2012 6:06 am

Hi John,

This is my code:

Code: Select all

 var publish_properties = {
         //reportMicLevels : true,
         publishAudio : true,
         microphoneEnabled : true,
         microphoneGain : 100,
         publishVideo : true,
         mirror : true,
         
         width:  cam_width,                 //156,
         height: (cam_width / 4) * 3 ,       //117,
         
         //encodedWidth : remote_cam_width,  // 1..640
         //encodedHeight : (remote_cam_width / 4) * 3,  // 1..640
         
         wmode : "opaque", // Needed for Faceboook
         style: {
            backgroundImageURI: Drupal.settings.open_tok.my_background_img
         }
   };
var publisher = TB.initPublisher(api_key, "myCam", publish_properties);
publisher.addEventListener("accessAllowed", accessAllowedHandler);

function accessAllowedHandler(event) {
      my.publisher.detectDevices();
}

function devicesDetectedHandler(event) {


   if (event.cameras.length < 1) {
       console.warn('No cameras');   
        return false;
    }
   console.log(event);
   console.log("camera is " + event.selectedCamera.status);
}





I do see myself in the camera, but I get 'inactive' state.
Was this post helpful? (0)
giladani
 
Posts: 187
Joined: Wed Apr 11, 2012 8:05 am
Thumbs Up: 2

Re: New satnadalone publisher

Postby giladani » Thu Jun 14, 2012 10:30 am

I think that I found the problem. If you call the detect devices right after "allow" handler, then it says the camera is inactive. If you just wait 1 second, it works.

Gil.
Was this post helpful? (0)
giladani
 
Posts: 187
Joined: Wed Apr 11, 2012 8:05 am
Thumbs Up: 2

Re: New satnadalone publisher

Postby giladani » Fri Jun 15, 2012 6:58 am

John,

Assuming that my publisher is not connected to any session.

What's the revert API call to TB.initPublisher() ??
How do I remove it from my DOM?
Was this post helpful? (0)
giladani
 
Posts: 187
Joined: Wed Apr 11, 2012 8:05 am
Thumbs Up: 2

Re: New satnadalone publisher

Postby ankur » Fri Jun 15, 2012 7:00 am

Was this post helpful? (1)
ankur
 
Posts: 315
Joined: Thu Jun 02, 2011 12:37 am
Thumbs Up: 12


Return to JavaScript



Who is online

Users browsing this forum: No registered users and 1 guest

cron