Laravel Video Chat using Socket.IO and WebRTC
composer require php-junior/laravel-video-chat
Laravel 5.5 uses Package Auto-Discovery, so doesn't require you to manually add the ServiceProvider.
If you don't use auto-discovery, add the ServiceProvider to the providers array in config/app.php
PhpJunior\LaravelVideoChat\LaravelVideoChatServiceProvider::class,
php artisan vendor:publish --provider="PhpJunior\LaravelVideoChat\LaravelVideoChatServiceProvider"
And
php artisan migrate
php artisan storage:link
change APP_URL in .env
This is the contents of the published config file:
return [
'relation' => [
'conversations' => PhpJunior\LaravelVideoChat\Models\Conversation\Conversation::class,
'group_conversations' => PhpJunior\LaravelVideoChat\Models\Group\Conversation\GroupConversation::class
],
'user' => [
'model' => App\User::class,
'table' => 'users' // Existing user table name
],
'table' => [
'conversations_table' => 'conversations',
'messages_table' => 'messages',
'group_conversations_table' => 'group_conversations',
'group_users_table' => 'group_users',
'files_table' => 'files'
],
'channel' => [
'new_conversation_created' => 'new-conversation-created',
'chat_room' => 'chat-room',
'group_chat_room' => 'group-chat-room'
],
'upload' => [
'storage' => 'public'
]
];
Uncomment App\Providers\BroadcastServiceProvider
in the providers array of your config/app.php
configuration file
Install the JavaScript dependencies:
npm install
npm install --save laravel-echo js-cookie vue-timeago socket.io socket.io-client webrtc-adapter vue-chat-scroll
If you are running the Socket.IO server on the same domain as your web application, you may access the client library like
<script src="//{{ Request::getHost() }}:6001/socket.io/socket.io.js"></script>
in your application's head
HTML element
Next, you will need to instantiate Echo with the socket.io
connector and a host
.
require('webrtc-adapter');
window.Cookies = require('js-cookie');
import Echo from "laravel-echo"
window.io = require('socket.io-client');
window.Echo = new Echo({
broadcaster: 'socket.io',
host: window.location.hostname + ':6001'
});
Finally, you will need to run a compatible Socket.IO server. Usetlaverdure/laravel-echo-server GitHub repository.
In resources/assets/js/app.js
file:
import VueChatScroll from 'vue-chat-scroll';
import VueTimeago from 'vue-timeago';
Vue.use(VueChatScroll);
Vue.component('chat-room' , require('./components/laravel-video-chat/ChatRoom.vue'));
Vue.component('group-chat-room', require('./components/laravel-video-chat/GroupChatRoom.vue'));
Vue.component('video-section' , require('./components/laravel-video-chat/VideoSection.vue'));
Vue.component('file-preview' , require('./components/laravel-video-chat/FilePreview.vue'));
Vue.use(VueTimeago, {
name: 'timeago', // component name, `timeago` by default
locale: 'en-US',
locales: {
'en-US': require('vue-timeago/locales/en-US.json')
}
})
Run npm run dev
to recompile your assets.
$groups = Chat::getAllGroupConversations();
$conversations = Chat::getAllConversations()
<ul class="list-group">
@foreach($conversations as $conversation)
<li class="list-group-item">
@if($conversation->message->conversation->is_accepted)
<a href="#">
<h2>{{$conversation->user->name}}</h2>
@if(!is_null($conversation->message))
<span>{{ substr($conversation->message->text, 0, 20)}}</span>
@endif
</a>
@else
<a href="#">
<h2>{{$conversation->user->name}}</h2>
@if($conversation->message->conversation->second_user_id == auth()->user()->id)
<a href="accept_request_route" class="btn btn-xs btn-success">
Accept Message Request
</a>
@endif
</a>
@endif
</li>
@endforeach
@foreach($groups as $group)
<li class="list-group-item">
<a href="#">
<h2>{{$group->name}}</h2>
<span>{{ $group->users_count }} Member</span>
</a>
</li>
@endforeach
</ul>
Chat::startConversationWith($otherUserId);
Chat::acceptMessageRequest($conversationId);
$conversation = Chat::getConversationMessageById($conversationId);
<chat-room :conversation="{{ $conversation }}" :current-user="{{ auth()->user() }}"></chat-room>
You can change message send route in component
Chat::sendConversationMessage($conversationId, $message);
You can change video call route . I defined video call route trigger/{id}
method POST
Use $request->all()
for video call.
Chat::startVideoCall($conversationId , $request->all());
Chat::createGroupConversation( $groupName , [ $otherUserId , $otherUserId2 ]);
$conversation = Chat::getGroupConversationMessageById($groupConversationId);
<group-chat-room :conversation="{{ $conversation }}" :current-user="{{ auth()->user() }}"></group-chat-room>
You can change message send route in component
Chat::sendGroupConversationMessage($groupConversationId, $message);
Chat::addMembersToExistingGroupConversation($groupConversationId, [ $otherUserId , $otherUserId2 ])
Chat::removeMembersFromGroupConversation($groupConversationId, [ $otherUserId , $otherUserId2 ])
Chat::leaveFromGroupConversation($groupConversationId);
Run this command php artisan storage:link
Chat::sendFilesInConversation($conversationId , $request->file('files'));
Chat::sendFilesInGroupConversation($groupConversationId , $request->file('files'));
The MIT License (MIT). Please see License File for more information.
Hey dude! Help me out for a couple of
视频上传和播放 上传 视频文件普遍在300MB左右,这样的大小,无法直接上传. 在php的配置文件中,php能上传的文件和页面的超时时间都不允许直接上传. 所以文件分片上传,必不可少. 1.每个分片必须有标识,很容易想到hash. 2.同时上传每个块必须是异步的,所以用ajax 3.同时要做类型的检测,避免上传木马. laravel的aetherupload上传神器,已经写好了这些功能,花点时
我正在使用laravel 5.1.我正在尝试运行数据库种子命令. 我的表名是用户 我的迁移文件如下 2015_11_09_194832_create_users_table.php use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; class CreateUsersTabl
Extends Widget A widget that plays a video from an URL. Import this type with “const {Video} = require('tabris');” Android iOS Methods pause() Pauses the video. state changes to pause and speed to 0.
描述 视频播放组件。 安装 $ npm install rax-video --save 属性 属性 类型 默认值 必填 描述 支持 id string - ✘ id 选择器 src string - ✔️ 视频地址 autoPlay boolean false ✘ 设置视频自动播放 muted boolean false ✘ 是否播放音频 loop boolean false ✘ 是否循环播放
WARNING Weex中内置的<video>组件一般只做demo用途,在你的App中,你应该用你喜欢的视频库重新实现video组件。 Video 组件用于在页面中嵌入视频内容。 text 是唯一合法的子组件。 src, string. 内嵌的视频指向的URL。 play-status, string. 可选值为 play | pause,用来控制视频的播放状态,play 或者 pause,默认值
以下是视频的子类型: BMPEG MP4V-ES vnd.mpegurl BT656 MPV vnd.nokia.interleaved-multimedia CelB mpeg vnd.objectvideo DV mpeg4-generic vnd.sealed.mpeg1 H261 nv vnd.sealed.mpeg4 H263 parityfec vnd.sealed.swf H263-
视频组件 属性 类型 默认值 必填 说明 src string 是 要播放视频的资源地址 autoplay boolean false 否 是否自动播放,只在初始化时有效,不能动态变更 muted boolean false 否 是否静音播放 controls boolean true 否 是否显示默认播放控件(播放/暂停按钮、播放进度、时间),仅安卓支持 loop boolean false 否
Video++ 是一个视频和图像处理库,利用了 C++14 标准的特性简化应用。该库在 G++ 4.9.1, Clang++ 3.5.0 中测试通过,依赖于: the iod library Eigen 3