Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Js library not working #23

Closed
alamgira opened this issue Nov 19, 2020 · 7 comments
Closed

Js library not working #23

alamgira opened this issue Nov 19, 2020 · 7 comments

Comments

@alamgira
Copy link

alamgira commented Nov 19, 2020

Hello! Please ensure your meeting is not expired. Therefor only join a meeting if the participant is going to connect immediately, otherwise the meeting will expire after a short period of time. The meeting connected event is received as accepted, you can find this also in the getting started example in the documentation. The event received also provides the localStream on demand, however please note that showing the local stream is only required when using SFU mode so you have to either disable SFU mode or remove the local stream having more than two participants. I'm not sure about your question starting a broadcast without stream but I guess you don't want the participant having to start it. You can create a generic user (that does not need to join) and use the access key to start an RTMP stream. Please double check that you have unique access keys for each participant and the meeting does not expire. The start method is the more convenient method as it does all initialization as well. Best wishes!

Originally posted by @unused in #22 (comment)

This is my current javascript code for start

var state = {local: null, stream: null, connecting: false, audio: true, 
	video: true, screen: false, facingMode: "user",recording :false, 
	streaming:false, youtube:false, facebook:false};
var eyesonModule = window.eyeson;
var eyeson = eyesonModule.default;
var start = function() {
	state.connecting = true;
	var access_key= document.getElementById("access_key").value;
	eyeson.onEvent(handleEvent);
	eyeson.start(access_key);
}

 function handleEvent(event) {
 	console.log('[App] Ignore received event:'+ event.type);
  	console.log(event)
	
    if (event.type !== 'accept') {
      return;
    }

    var div = document.getElementById("video-div");
    state.local = event.localStream;
    add_video(div, state.local);
    state.stream = event.remoteStream;
    add_video(div,state.stream);
    state.connecting = false;
}

I am getting access key by using eyeson php library

$eyeson = new Eyeson($api_key);

$room = $eyeson->join($username, $roomname, array("broadcast_available"=> true, "sfu_mode"=> "disabled"));

$access_key = $room->getAccessKey();
$guest_token = $room->getGuestToken();

Can you please guide me how to start the video conference from this state and also how will a participant join to this meeting from my site (not using eyeson link)

@alamgira
Copy link
Author

Accepted is never called in event handler. I have joined to the meeting from another browser using guest token and eyeson url, still didn't receive "accepted" event.

@unused
Copy link
Contributor

unused commented Nov 20, 2020

I've quickly tested your snippet and it seems to be fine, therefore it might be some issue with your development environment: Please ensure you use localhost for your local development as otherwise your browser of choice might require you to use HTTPS even for local development. Check if there are any error messages or warning received when starting the meeting in your browser. An easy way to test - and comfortable way to prevent meeting expiration - is to join a user and open the default eyeson web UI, then join another participant on the same room and use this access key for testing.

The HTML document I adapted from your code looks like the following. NOTE: I hosted it using a simple local webserver, e.g. using python python -m SimpleHTTPServer 8000 and visiting http://localhost:8000.

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8">
    <title>testing https://github.com/eyeson-team/js-docs/issues/23</title>
  </head>
  <body>
    <form id="start-form">
      <label for="access-key">Access Key</label>
      <input type="text" id="access-key" />
      <button>start</button>
    </form>
    <video id="local-video" width="640" height="480" autoplay playsinline></video>
    <video id="remote-video" width="640" height="480" autoplay playsinline></video>

    <script src="./node_modules/eyeson/dist/eyeson.js"></script>
    <script>
      function addVideo(element, stream) {
        element.srcObject = stream;
        element.play();
      }

      let state = { local: null, stream: null, connecting: false, audio: true,
                    video: true, screen: false, facingMode: "user",recording :false,
                    streaming:false, youtube:false, facebook:false };
      var eyesonModule = window.eyeson;
      var eyeson = eyesonModule.default;

      var start = function(accessKey) {
        state.connecting = true;
        eyeson.onEvent(handleEvent);
        eyeson.start(accessKey);
      }

      function handleEvent(event) {
        console.debug('[App] Ignore received event:'+ event.type, event);

        if (event.type !== 'accept') {
          return;
        }

        var divLocal = document.getElementById("local-video");
        state.local = event.localStream;
        addVideo(divLocal, state.local);
        var divRemote = document.getElementById("remote-video");
        state.stream = event.remoteStream;
        addVideo(divRemote, state.stream);
        state.connecting = false;
      }

      document.getElementById("start-form")
        .addEventListener('submit', function(event) {
          event.preventDefault();
          event.stopPropagation();
          var accessKey = document.getElementById("access-key").value;
          console.debug("start meeting with:", accessKey);
          start(accessKey);
        });
    </script>

@unused
Copy link
Contributor

unused commented Nov 20, 2020

I have joined to the meeting from another browser using guest token and eyeson url, still didn't receive "accepted" event.

Sorry I missed that one. Could you join the meeting with the eyeson web UI or did it fail as well?

@alamgira
Copy link
Author

hello yes i can join the meeting using eyeson url (one session with access key and the other one with guest token)
My localhost wasn't working and therefore i uploaded to my server with https support.

@unused unused closed this as completed Nov 20, 2020
@alamgira
Copy link
Author

alamgira commented Nov 20, 2020

It still didn't work with https @unused . The current failure i am talking about is on https

@unused unused reopened this Nov 23, 2020
@unused
Copy link
Contributor

unused commented Nov 23, 2020

What error message are you receiving, can you check the logs? Did you test with the document provided?

@alamgira
Copy link
Author

It is working now. it was https issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants