0

I have a rails app that I am trying to add OpenTok to. OpenTok uses javascript, and when I go to my view party.html.erb nothing shows up besides the text in my beginning html tags.

<div id="invitation">Invite your friends! Share the url of this page   

localhost:3000/party/<%= @room.id %></div>
<div id="videobox">

</div>
<script src="//static.opentok.com/webrtc/v2.2/js/opentok.min.js" ></script>
<script type="text/javascript">
var apiKey = API_KEY;
var sessionId = <%= @room.sessionId %>;
var token = <%= @tok_token %>;



var session = OT.initSession(apiKey, sessionId);

  session.on("streamCreated", function(event) {
    session.subscribe(event.stream);
  });

  session.connect(token, function(error) {
    var publisher = OT.initPublisher();
    session.publish(publisher);
  });
</script>

</script>

Do I need a seperate javascript file? Thanks for your help.

1
  • I am assuming you added your API_KEY. what is the extra </script> tag doing in the end Commented Oct 1, 2014 at 5:57

2 Answers 2

1

if your OpenTok is related to some DOM elements, maybe you should wrap it to something like:

$(function(){
   ...
});

which will be triggered after loading full page.

Sign up to request clarification or add additional context in comments.

Comments

0

Two ways you can include the java script

1) Download the java script file and put it in your app(app/assets/javascripts) and add this

<script type="text/javascript" src="/assets/opentok.min.js"></script>

your html.erb file

2)Get it from online

<script type="text/javascript" src="https://static.opentok.com/webrtc/v2.2/js/opentok.min.js"></script>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.