DEV Community

Cover image for Adding Video Chat To Your Laravel App

Adding Video Chat To Your Laravel App

Kofi Mupati on November 12, 2020

Introduction I was required to build a custom video chat application for a Vuejs and Laravel project. I went through a lot of hoops to g...
Collapse
 
ruchitdarji profile image
Ruchit Darji • Edited

Hello Kofi Mupati,

I have one question related to implementing this video call functionality...

Q. I need to display a video call notification and let the user choose between finish the current call and takes the new one or continue in the current call and don't take the new call...

Please Suggest the how to make this feature...

Collapse
 
mupati profile image
Kofi Mupati • Edited

This will take some tweaking. You need to send an event to the caller that will inform them to cancel the call. I've not thought through the use case for multiple incoming calls. This is beyond the scope of what I can offer in a demo application.

Collapse
 
ruchitdarji profile image
Ruchit Darji • Edited

So, All time refresh browser page of video call at both side ???

Because I need hangup first call and attend second call without page refresh...

But you suggest refresh both browsers to call again for same user second time calling...

Thread Thread
 
mupati profile image
Kofi Mupati

that is not necessary. Read more on how to do all that through websocket events and listeners.

Thread Thread
 
ruchitdarji profile image
Ruchit Darji

Hello Kofi Mupati,

Any reference to add a noise canceling filter to the video call...right now if the volume is high there is a lot of ecco...

Thread Thread
 
mupati profile image
Kofi Mupati

I've not looked into that yet.

Thread Thread
 
ruchitdarji profile image
Ruchit Darji

Let us know if you find anything about this. It will be very helpful and grateful for us.

Thread Thread
 
ruchitdarji profile image
Ruchit Darji

Hello Kofi Mupati,

did you find anything related to this echo issue in the video call ???

I have spent many days to solving this issue but not getting anything solution in this.

Please suggest any reference links where can i solve this issue in my video chat application.

Thread Thread
 
mupati profile image
Kofi Mupati

I've not had time to look into that yet.

Thread Thread
 
ruchitdarji profile image
Ruchit Darji

Hello Kofi Mupati,

I have fixed this issue in my video chat functionality..

I have added "muted" parameter in placed user video element div in vue component file.

Many many thanks for your guidance and documentation...

Thread Thread
 
mupati profile image
Kofi Mupati

That's good to know. All the best Ruchit Darji

Thread Thread
 
ruchitdarji profile image
Ruchit Darji

Hello Kofi Mupati,

I have one question related this case...

how to placed video call is automatically ended within 30 seconds if the receiver user cannot accept the incoming call ???

So, Please suggest how can i do this...

Thread Thread
 
mupati profile image
Kofi Mupati

when you place the call, you can set a timer which calls the endCall after the specified period. Play around with the setTimeout function in JavaScript.

Thread Thread
 
ruchitdarji profile image
Ruchit Darji

Thank you again for your guidance...

Collapse
 
nehasahu001 profile image
nehasahu001 • Edited

Hello Kofi Mupati,

Big Thanks to you to help it out.

I followed this steps and I able to impletement on system. And It's working fine for me. But when i try in different device, it's failed to connect. and I got an error like 'Connection Failed'.

Can you please help me here?

Thank you again for your guidance.

Collapse
 
mupati profile image
Kofi Mupati

Are the devices on a different network?

Collapse
 
nehasahu001 profile image
nehasahu001

Yes, it's different network.

Thread Thread
 
mupati profile image
Kofi Mupati

This is where you need to set up a TURN server.

Thread Thread
 
nehasahu001 profile image
nehasahu001

Okay, is it reliable to use this numb.viagenie.ca/ free STUN/TURN server here?

Thread Thread
 
mupati profile image
Kofi Mupati

Not tried it before but you can go ahead and use it.

Thread Thread
 
nehasahu001 profile image
nehasahu001

Thanks a lot!

Thread Thread
 
nehasahu001 profile image
nehasahu001

I tried TURN Server also but still it's same error i am facing. As I found here (github.com/feross/simple-peer/issu...) that it's taking much time to paste the signals. don't you think so? If yes than, is there any improvement in time?

Collapse
 
naeemijaz profile image
Naeem Ijaz

Bro Thanks
I am facing a problem.
i'm Getting Error
DOMException: Failed to construct 'RTCPeerConnection': '' is not a valid URL.
Please Help Me ASAP Because it is my final Year Project
Here is the SS: i.imgur.com/S7AKqHg.png

Collapse
 
mupati profile image
Kofi Mupati

Maybe an error related to the absence of TURN Server

Collapse
 
naeemijaz profile image
Naeem Ijaz

Sir Thankyou So Much For Your Reply
How can i create TURN in my hosting panal.
I'm using shared hosting in NAMECHEAP

Thread Thread
 
mupati profile image
Kofi Mupati

get a digitalocean droplet and use the following tutorial: ourcodeworld.com/articles/read/117...

but before that, comment out the following block of code and check whether it will work.

        config: {
          iceServers: [
            {
              urls: this.turn_url,
              username: this.turn_username,
              credential: this.turn_credential,
            },
          ],
        },
Enter fullscreen mode Exit fullscreen mode
Collapse
 
alvinluo666 profile image
Alvin Luo

Bro Thanks for your explanation.
I am facing a problem :
I implement it the same as you , I do it in localhost , I do not use turn server , when I call a user from another user , it works fine. But second time I call it and get an error say : Fails To set remote answer ! Pls help me

Collapse
 
mupati profile image
Kofi Mupati

Were you able to establish the call between the 2 participants? Note that this video call is limited to only 2 people and not a group call. At times you'd have to refresh both browsers to call again. Obviously, this is a demo and one has to consider a number of things to make it very production-ready.

Collapse
 
dariochiappello profile image
Darío Chiappello

I have this problem when I click the call button.

{message: "Failed to connect to Pusher.", exception: "Illuminate\Broadcasting\BroadcastException",…}
exception: "Illuminate\Broadcasting\BroadcastException"
file:"\vendor\laravel\framework\src\Illuminate\Broadcasting\Broadcasters\PusherBroadcaster.php"
line: 122
message: "Failed to connect to Pusher."

Collapse
 
mupati profile image
Kofi Mupati

You must install and configure pusher. You must create an account and add the credentials.

Collapse
 
sargischshmarityan profile image
Sargis

Hello Kofi Mupati,

I am currently working on a project where I have to create a video chat, but it doesn't have to be just 2 people talking to each othe. In my project there are groups and users join the groups they need. Now the calls should be in groups only and anyone from that group should be able to join the call. Now my question is: is it possible to use your implementation within my project. Will it work?

Collapse
 
mupati profile image
Kofi Mupati

this implementation is not scalable at all. it's more of proof of concept and for my personal studies. Send me a message as scientificgh[at]gmail.com if you are open to consulting.

Collapse
 
hbakouane profile image
hbakouane

A great article, Thanks.

Collapse
 
stanliwise profile image
stanliwise

such a nice article!
Nice

Collapse
 
khophi profile image
KhoPhi

Such a detailed article. Thanks.
Going to check out the github project.

Collapse
 
rameshphp profile image
Ramesh-php

Hi Mupati

I'm getting error, logged in different user and different browser also. But all the user to show offline only.

Collapse
 
crazeetee profile image
Timothy Kimemia

can someone explain/guide how to reduce or remove the echo from the video when connected?

Collapse
 
sanjaikumar profile image
sanjai-kumar • Edited

Hello @mupati , I need to record the video Chat conversation .Please Gudie me how to do using Video chat .

Collapse
 
fnnaeem1881 profile image
Mehedi Hasan

Hello Kofi Mupati,

I'm following all your steps but it doesn't work, none of my users are doing online shows, how can i fix this problem

Collapse
 
mupati profile image
Kofi Mupati

Please check your pusher setup and configuration

Collapse
 
fnnaeem1881 profile image
Mehedi Hasan

allready configuration my pusher account , but did not work , you can check my env

Thread Thread
 
mupati profile image
Kofi Mupati

That’s the possible reason I can think of at the moment unless I see your code. Kindly go through the comments to see some of the recommendations that helped others

Collapse
 
abbasnezhad profile image
Nazanin • Edited

Hi deer Mupati

could I Add just audio Chat To Laravel App.( like telegram or whatsApp)?
I want just massage and audio chat.

please suggest and help me how to make that.

Collapse
 
mupati profile image
Kofi Mupati

It's possible.

Collapse
 
josuemart555 profile image
Josuemart555

Excuse me, does anyone have documentation on how to make an app with Laravel for voice calls with a voip api, please

Collapse
 
mupati profile image
Kofi Mupati

I've not done that before but looks like an interesting thing to explore. You can as well find out if a platform provides some SDKs for integration

Collapse
 
samuel_aliu_79865b5c07c30 profile image
Samuel Aliu

where is the tutorial all i'm seeing is " Liquid syntax error: Unknown tag 'endraw' "

Collapse
 
vardgesk profile image
Vardges

Hello Kofi Mupati,

Tell me pleasе what if user is busy. How to define ?

Collapse
 
mupati profile image
Kofi Mupati

Of the top of my head I think you can have a property in the user object say: isBusy: false. When the call is established between the 2, you update that property.
When you get an incoming call, you check that property before you accept. If busy you can decline by sending a message to the call via websockets(pusher)