eyeson/eyeson-php
Composer 安装命令:
composer require eyeson/eyeson-php
包简介
PHP SDK for Eyeson API
README 文档
README
eyeson.team PHP library - create powerful video conferences on demand and easily integrate eyeson with your own PHP applications.
The library offers basic features of eyeson API. See the API documentation to get a full overview, create an issue if you found a bug or have a feature request. Feel free to add an issue at the documentation repo for any general questions you might have.
Installation using Composer
# required php version >= 5.4
$ composer require eyeson/eyeson-php
Usage
Provide your api key and quickly join any room using the join method. You can optionally provide configuration options as a 3rd argument.
$eyeson = new Eyeson('<your-eyeson-api-key>'); // Join a new eyeson video meeting by providing a user's name. $room = $eyeson->join('Mike', 'standup meeting'); $room->getUrl(); // https://app.eyeson.team?<token> URL to eyeson.team video GUI // If you do not provide a room name, eyeson will create one for you. Note that // users **will join different rooms on every request**. $room = $eyeson->join('mike@eyeson.team'); // You can add additional details to your user, which will be shown in the // GUI. Choosing a unique identifier will keep the user distinct and ensures // actions are mapped correctly to this record. E.g. joining the room twice will // not lead to two different participants in a meeting. $user = [ 'id' => 'mike@eyeson.team', 'name' => 'Mike', 'avatar' => 'https://mikes.website/avatar.png' ]; $room = $eyeson->join($user, 'daily standup'); $guest = $eyeson->registerGuest('John Doe', $room);
Before running any meeting related function like record, layout, or shutdown, make sure that the meeting/room is ready.
if (!$room->isReady()) { $room = $eyeson->waitReady($room); }
You can control the meeting using a joined room, the actions will be triggered by the user who joined, use a control user on demand.
// Send chat message $eyeson->sendMessage($room, 'hello world!'); // Start a video playback. $playback = $eyeson->playback($room, [ 'url' => 'https://myapp.com/assets/video.webm', 'audio' => true ]); $playback->start(); // Start and stop a recording. $recording = $eyeson->record($room); $recording->start(); // later... $recording->stop(); // check if recording is active $recording->isActive(); // fetch recording details if needed $eyeson->getRecordingById($recordingId); $eyeson->deleteRecordingById($recordingId); $recordingsList = $eyeson->getRecordingsList($room); // Create a snapshot $eyeson->createSnapshot($room); // fetch snapshot details if needed $eyeson->getSnapshotById($snapshotId); $eyeson->deleteSnapshotById($snapshotId); $snapshotsList = $eyeson->getSnapshotsList($room); // Start and stop a broadcast. $broadcast = $eyeson->broadcast($room, [ 'stream_url' => 'https://...' ]); $broadcast->start(); // later... $broadcast->stop(); // check if broadcast is active $broadcast->isActive(); // Get list of meeting participants and filter for only active ("online") $users = $eyeson->getUsersList($room, true); // lock meeting room $eyeson->lockMeeting($room); // Force stop a running meeting. $eyeson->shutdown($room); $list = $eyeson->getAllCurrentMeetings();
Register webhooks to receive updates like new meetings, or recordings in your application.
// Register a webhook $eyeson->addWebhook('https://my.application/hooks/recordings', Eyeson::$webhookRecording); // Clear webhook if not needed anymore $eyeson->clearWebhook();
You can switch from the automatic layout handling to a custom layout and set user positions for the video podium. Note: Use an empty string for an empty position. Additionally, you can hide/show the name inserts in the video.
$layout = $eyeson->layout($room); $layout->apply([ 'layout' => 'auto', 'name' => 'present-lower-3', 'users' => ["5eb3a...994", "5eb3a...d06", ...], 'voice_activation' => true, 'show_names' => false ]); // switch back to automatic layout $layout->useAuto(); // apply fixed custom layout $layout->update($userList); // ["5eb3a...994", "5eb3a...d06"] $layout->showNames(); $layout->hideNames();
Apply overlay and background images. You can send plain text that will automatilcally create an overlay.
$layer = $eyeson->layer($room); $layer->apply([ 'url' => 'https://myapp.com/assets/meetingBackground.jpg', 'z-index' => Eyeson::$layerBackground ]); $layer->setText('Hello World!'); // DEPRECATED! $layer->setImageURL('https://myapp.com/assets/meetingForeground.png'); $layer->setImageURL('https://myapp.com/assets/meetingBackground.jpg', Eyeson::$layerBackground); $layer->sendImageFile('./overlay.png'); $layer->sendImageFile('./background.png', Eyeson::$layerBackground); $layer->clear(); $layer->clear(Eyeson::$layerBackground);
Error handling
API requests can throw an EyesonApiError which is an instance of the PHP
Exception. Its getMessage() method contains the API response error message
and getCode() contains the API response status code.
use EyesonTeam\Eyeson\Exception\EyesonApiError; function startRecording($accessKey) { try { $recording = $eyeson->record($accessKey); return $recording->start(); } catch (EyesonApiError $error) { error_log($error->getCode() . ' - ' . $error->getMessage()); return false; } } startRecording($accessKey);
Permalink API
Since v2.2.0, eyeson-php includes functions to use with Permalink API. You can read more about it here: https://docs.eyeson.com/docs/rest/advanced/permalink_api
$eyeson = new Eyeson('<your-eyeson-api-key>'); $permalink = $eyeson->permalink->create('<username>', ['name' => '<room_name>', 'widescreen' => true]); echo $permalink->getId(); echo $permalink->getUrl(); echo $permalink->getGuestUrl(); echo $permalink->getUserToken(); echo $permalink->getGuestToken(); $permalink = $eyeson->permalink->update('<permalink-id>', ['widescreen' => false]); $permalink = $eyeson->permalink->getById('<permalink-id>'); $permalink = $eyeson->permalink->getAll(['page' => 1, 'limit' => 50, 'expired' => false]); $permalink = $eyeson->permalink->addUser('<permalink-id>', '<username>', ['id' => '<user-id>']); $eyeson->permalink->removeUser('<permalink-id>', '<user-token>'); $room = $eyeson->permalink->joinMeeting('<user-token>'); $room = $eyeson->permalink->registerGuest('<username>', '<guest-token>', ['id' => '<user-id>']); # works only if $permalink->isStarted() === true $eyeson->permalink->delete('<permalink-id>');
Forward stream
Version 2.4.0 adds forward stream support. Learn more about it https://docs.eyeson.com/docs/rest/references/forward
$eyeson = new Eyeson('<your-eyeson-api-key>'); $room = $eyeson->join('Mike', 'standup meeting'); $forward = $eyeson->forward($room); $forward->source('<forward-id>', '<user-id>', 'audio,video', 'https://...'); $forward->mcu('<forward-id>', 'audio,video', 'https://...'); $forward->playback('<forward-id>', '<play-id>', 'audio,video', 'https://...'); $forward->stop('<forward-id>');
Change log
See CHANGELOG.md.
Development
You can use docker to run the testsuite, see the Makefile for details.
$ make build
$ make test
eyeson/eyeson-php 适用场景与选型建议
eyeson/eyeson-php 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 45.87k 次下载、GitHub Stars 达 7, 最近一次更新时间为 2018 年 04 月 04 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「api」 「video」 「eyeson」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 eyeson/eyeson-php 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 eyeson/eyeson-php 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 eyeson/eyeson-php 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Easy to use SDK with grabber for multiple platforms at once like YouTube, Dailymotion, Facebook and more.
The yii2-videojs-widget is a Yii 2 wrapper for the [video.js](http://www.videojs.com/). A JavaScript and CSS library that makes it easier to work with and build on HTML5 video. This is also known as an HTML5 Video Player.
A PSR-7 compatible library for making CRUD API endpoints
Display a video using native HTML5 video
TYPO3 Plugin that displays YouTube-videos faster by loading the video-player on demand while displaying a cacheable preview picture.
The yii2-alipay-widget is a Yii 2 wrapper for the [video.js](http://www.videojs.com/). A JavaScript and CSS library that makes it easier to work with and build on HTML5 video. This is also known as an HTML5 Video Player.
统计信息
- 总下载量: 45.87k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 7
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2018-04-04