Still a WIP! with bugs not yet fixed, features not yet finished. Only supports Android for the time being, iOS version to be added soon
Cordova Agora Plugin is based on Agora Media SDK 1.4.2 (http://agora.io/) to achieve in-app real-time video chat for your cordova app.
cordova plugin add https://github.com/KevinWang15/cordova-plugin-agora-video-chat.git
After installing this plugin, a global variable agora
is created and is accessible through Javascript
-
Setup SDK Key Call it after deviceReady !
agora.setKey('*********************************');
If you don't have an API key yet, head to http://agora.io/ for one.
-
Join Channel
agora.joinChannel('ChannelName')
Joins a specific channel (channel name is arbitrary) and starts video-chatting with other people on the same channel
Enumeration values used in Agora SDK are stored in: agora.Enum
.
Specifically, there are
agora.Enum.UserOfflineReason
agora.Enum.ChannelProfile
agora.Enum.VideoProfile
agora.Enum.ErrorCode
agora.Enum.WarnCode
agora.Enum.Quality
document.addEventListener('CordovaAgora.' + EVENT_NAME,function(data){})
//e.g. document.addEventListener('CordovaAgora.onLeaveChannel',function(){console.log('User has left channel!');});
|EVENT_NAME|data| |---|---|--| |onJoinChannelSuccess|String channel, int uid, int elapsed| |onRejoinChannelSuccess|String channel, int uid, int elapsed| |onWarning|int warn| |onApiCallExecuted|String api, int error| |onCameraReady|无| |onVideoStopped|无| |onAudioQuality|int uid, int quality, short delay, short lost| |onAudioVolumeIndication|(int uid,int volume)[] speakers, int totalVolume| |onNetworkQuality|int quality| |onUserMuteAudio|int uid, boolean muted| |onRemoteVideoStat|int uid, int delay, int receivedBitrate, int receivedFrameRate| |onLocalVideoStat|int sentBitrate, int sentFrameRate| |onFirstRemoteVideoFrame|int uid, int width, int height, int elapsed| |onFirstLocalVideoFrame|int width, int height, int elapsed| |onConnectionInterrupted|无| |onConnectionLost|无| |onError|int err| |onFirstRemoteVideoDecoded|int uid, int width, int height, int elapsed| |onUserJoined|int uid, int elapsed| |onUserOffline|int uid, int reason| |onUserMuteVideo|int uid, boolean muted| |onRtcStats|int totalDuration, int txBytes, int rxBytes, int txKBitRate, int rxKBitRate, int lastmileQuality, int users, double cpuTotalUsage, double cpuAppUsage| |onLeaveChannel|int totalDuration, int txBytes, int rxBytes, int txKBitRate, int rxKBitRate, int lastmileQuality, int users, double cpuTotalUsage, double cpuAppUsage|
具体请参考 agora.io 的文档
注意:iOS版本现在只支持CordovaAgora.onLeaveChannel
,而且没有额外的参数
agora.startLoggingAllEvents()
agora.stopLoggingAllEvents()
只有一位用户(主讲人),发送视频给其他用户。 其他用户连接,不发送视频,但可以和主讲人语音互动。
agora.startLecture(channel);
//作为主讲人
agora.joinLecture(channel);
//作为听众
-
Leave Channel
agora.leaveChannel()
Android 6.0+ 将权限改成了运行时动态向用户询问获取,可能导致插件崩溃。 解决方法:将android:targetSdkVersion设置为19
More features coming soon