Video chat in rails 3


Video streeming is always a challenge for the rails programmer. I am sure After reading this article  every one CAN DO IT EASILY.  :)

Gems used:
      gem 'raydash', '2.1.0'
      gem 'jquery-rails'

Step 1 :
     First generate a new rails project by typing rails new Demo_apps.

Step 2:
   Inside Your gem file add the raydash gem. You can check the version from rubygems.org.

Step 3:
   Go to http://www.raydash.com/ and generate Your user_id, and secret.

Step 4:
   Configure Demo_apps with your user_id and secret with the command:
    rails g raydash:install [userid] [secret]  
    or you can directly go to config/initilizer and create a raydash.rb file                  
    and add your credentials there.   
Step 5:      
     Create an suitable controller and add this
     @token = Raydash.getToken()
         
Step 6:     
    for the view page write this                        
      <%= videostream(@token,"stream") %>
      Where, @token specifies the token we are connecting to, and "stream” are div id.  
      If You want to add video record just add one more line in the view file
      <%= videorecord(@token,"record","640","480","0") %>     
      where @token is the token generated for you and “record” is the div size  and you can
      specify its height width also.

Step 7:
   You can customize and add javascript to change video quality and div size.

Step 8:
   To start video streaming make the create a next link to the view page.
            For the same add a controller action like this.
            def next()
               Raydash.changeStreamRand(session_token,
              :active =>true,:twoWay=>true,
              :custom_Group=>'Your_group')
               render :json => {:ok => true }
            end
 If u want a group chat like video chat and want to switch between different users use this             function
            Raydash.changeStreamNext() instead of  Raydash.changeStreamRand ()

Step 9:
   In Application.html.erb in the header write this code
             <%= raydash_header %>

Step 10:

   Make sure You have flash 11 or higher version installed. And your browser
   must be compatible of doing video chat. And rails version must be greater than 3.

Comments

Popular posts from this blog

Debug Nodejs inside docker container

Swap primary keys between two records in the same table in Postgres

How to add a bootstrap table with fixed header and scrollable body