Commit 6481301a authored by 彭云飞's avatar 彭云飞
Browse files

LIVE-39451-- 优化多场景项目,修改文档

parent 7b2a8f0c
# RN 云课堂集成文档
# RN 多场景集成文档
## 1. 概述
......@@ -50,7 +50,7 @@ $ npm install
│ │ ├── PolyvUserConfig.js
│ │ └── PolyvLogin.js
│ └── sdk
│ └── PolyvCloudClassLoginModule.js
│ └── PolyvSceneLoginModule.js
如果只是需要使用到 sdk 的功能,把 sdk 目录下的文件拉到 RN 项目中即可。demo 中的功能则需要使用到 demo 目录下的文件。
......@@ -115,13 +115,97 @@ $ npm install
#### 2.1.4 使用方法
云课堂的插件 PolyvCloudClassLoginModule.js 提供了如下接口:
云课堂的插件 PolyvSceneRNModule.js 提供了如下接口:
| 函数名 | 参数 | 功能说明 | 是否有返回值 |
| :------------ | ------------------------------------------------------------ | ---------------- | ------------ |
| init | vodKey:加密串(必填)<br/>decodeKey:加密密钥(必填)<br/>decodeIv:加密向量(必填)<br/>viewerId:观看者 ID(必填)<br/>nickName:观看者昵称(选填) | SDK 初始化 | 是 |
| liveLogin | userId:账号 ID(必填)<br/>channelId:频道号(必填)<br/>appId:应用 ID(必填)<br/>appSecret:应用密钥(必填) | 直播登录 | 是 |
| playbackLogin | userId:账号 ID(必填)<br/>channelId:频道号(必填)<br/>vodId:回放视频 ID(必填)<br/>appId:应用 ID(必填)<br/>appSecret:应用密钥(必填) | 回放登录 | 是 |
##### API
###### 1. setViewerInfo
设置参观者用户信息
方法:`setViewerInfo()`
```javascript
PolyvSceneRNModule.setViewerInfo(viewerId, viewerName, viewerAvatar)
```
**参数:**
| 名称 | 类型 | 说明 |
| :----------- | :----- | :------------------------------------- |
| viewerId | string | 用户唯一标识,用于登录socket、发送日志 |
| viewerName | string | 用户昵称,用于登录socket、发送日志 |
| viewerAvatar | string | 用户头像地址,用于登陆socket |
**返回值:**
```javascript
@returns {Promise<{code: *, message: *}|{code: number}>}
```
###### 2. setConfig
设置直播账号配置信息;建议通过服务器加密存储获取,然后在本地进行解密后再设置。启动应用后应当设置,设置完成后可进入多场景观看页。
方法:`setConfig()`
```javascript
PolyvSceneRNModule.setConfig(userId, appId, appSecret)
```
**参数:**
| 名称 | 类型 | 说明 |
| :-------- | :----- | :------- |
| userId | string | 用户ID |
| appId | string | 应用ID |
| appSecret | string | 应用密钥 |
**返回值:**
```javascript
@returns {Promise<{code: *, message: *}|{code: number}>}
```
###### 3.loginLive
登录直播(云课堂、直播带货)
方法 `loginLive()`
**参数:**
| 名称 | 类型 | 说明 |
| :-------- | :----- | :------------------------------ |
| handler | number | 组件节点 |
| type | int | 观看的场景1-云课堂; 2-直播带货 |
| channelId | string | 频道号 |
**返回值:**
```javascript
@returns {Promise<{code: *, message: *}|{code: number}>}
```
###### 4. playbackLogin
登录回放(云课堂、直播带货)
方法 `playbackLogin()`
**参数:**
| 名称 | 类型 | 说明 |
| :-------- | :----- | :------------------------------------- |
| handler | number | 组件节点 |
| sceneType | int | 观看的场景1-云课堂; 2-直播带货 |
| channelId | string | 频道号 |
| vid | string | 回放视频videoId |
| vodType | int | 回放视频类型。[0-回放列表;1-点播列表] |
**返回值:**
```javascript
@returns {Promise<{code: *, message: *}|{code: number}>}
```
以上函数的返回值参见 2.1.5。
......@@ -339,4 +423,4 @@ static BOOL RCTParseUnused(const char **input)
RCTReadString(input, "__attribute__((__unused__))") ||
RCTReadString(input, "__attribute__((unused))");
}
```
```
\ No newline at end of file
......@@ -12,16 +12,16 @@
NS_ASSUME_NONNULL_BEGIN
typedef NS_ENUM(NSInteger, PolyvCloudClassErrorCode) {
PolyvCloudClassError_Success = 0,
PolyvCloudClassError_NoAppId = -1,
PolyvCloudClassError_NoAppSecret = -2,
PolyvCloudClassError_NoViewerId = -3,
PolyvCloudClassError_NoUserId = -4,
PolyvCloudClassError_NoChannelId = -5,
PolyvCloudClassError_NoVodId = -6,
PolyvCloudClassError_LoginFailed = -10,
///服务器或者其它未知错误
PolyvCloudClassError_Other = -99,
PolyvCloudClassError_Success = 0,
PolyvCloudClassError_NoAppId = -1,
PolyvCloudClassError_NoAppSecret = -2,
PolyvCloudClassError_NoViewerId = -3,
PolyvCloudClassError_NoUserId = -4,
PolyvCloudClassError_NoChannelId = -5,
PolyvCloudClassError_NoVodId = -6,
PolyvCloudClassError_LoginFailed = -10,
///服务器或者其它未知错误
PolyvCloudClassError_Other = -99,
};
@interface PolyvSceneRNModule : NSObject<RCTBridgeModule>
......
......@@ -23,12 +23,12 @@
viewerName:(NSString *)viewerName
viewerAvatar:(NSString *)viewerAvatar
viewerType:(NSUInteger)viewerType {
PLVRoomViewUser *user = [[PLVRoomViewUser alloc] init];
user.viewerId = viewerId;
user.viewerName = viewerName;
user.viewerAvatar = viewerAvatar;
user.viewerType = viewerType;
return user;
PLVRoomViewUser *user = [[PLVRoomViewUser alloc] init];
user.viewerId = viewerId;
user.viewerName = viewerName;
user.viewerAvatar = viewerAvatar;
user.viewerType = viewerType;
return user;
}
@end
......@@ -42,22 +42,22 @@
static PLVLiveSDKConfig *_sdkConfig = nil;
+ (instancetype)sharedSDK {
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
_sdkConfig = [[super allocWithZone:NULL] init];
});
return _sdkConfig;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
_sdkConfig = [[super allocWithZone:NULL] init];
});
return _sdkConfig;
}
+ (void)configViewUserWithUserId:(NSString *)viewerId
viewerName:(NSString *)viewerName
viewerAvatar:(NSString *)viewerAvatar
viewerType:(NSUInteger)viewerType {
PLVRoomViewUser *viewUser = [PLVRoomViewUser viewUserWithUserId:viewerId
viewerName:viewerName
viewerAvatar:viewerAvatar
viewerType:viewerType];
[[self sharedSDK] setViewUser:viewUser];
PLVRoomViewUser *viewUser = [PLVRoomViewUser viewUserWithUserId:viewerId
viewerName:viewerName
viewerAvatar:viewerAvatar
viewerType:viewerType];
[[self sharedSDK] setViewUser:viewUser];
}
@end
......@@ -1885,9 +1885,9 @@
2D16E6871FA4F8E400B85C8A /* Frameworks */,
A8FE9D56310252DBBD5D488C /* Pods */,
);
indentWidth = 2;
indentWidth = 4;
sourceTree = "<group>";
tabWidth = 2;
tabWidth = 4;
usesTabs = 0;
};
83CBBA001A601CBA00E9B192 /* Products */ = {
......@@ -1946,7 +1946,7 @@
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0940;
ORGANIZATIONNAME = Facebook;
ORGANIZATIONNAME = Polyv;
TargetAttributes = {
13B07F861A680F5B00A75B9A = {
DevelopmentTeam = 8BMZBNN3Q5;
......
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "group:PolyvRNCloudClassDemo.xcodeproj">
</FileRef>
<FileRef
location = "group:Pods/Pods.xcodeproj">
</FileRef>
</Workspace>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
......@@ -2,37 +2,52 @@
"images" : [
{
"idiom" : "iphone",
"size" : "29x29",
"scale" : "2x"
"scale" : "2x",
"size" : "20x20"
},
{
"idiom" : "iphone",
"size" : "29x29",
"scale" : "3x"
"scale" : "3x",
"size" : "20x20"
},
{
"idiom" : "iphone",
"size" : "40x40",
"scale" : "2x"
"scale" : "2x",
"size" : "29x29"
},
{
"idiom" : "iphone",
"size" : "40x40",
"scale" : "3x"
"scale" : "3x",
"size" : "29x29"
},
{
"idiom" : "iphone",
"size" : "60x60",
"scale" : "2x"
"scale" : "2x",
"size" : "40x40"
},
{
"idiom" : "iphone",
"size" : "60x60",
"scale" : "3x"
"scale" : "3x",
"size" : "40x40"
},
{
"idiom" : "iphone",
"scale" : "2x",
"size" : "60x60"
},
{
"idiom" : "iphone",
"scale" : "3x",
"size" : "60x60"
},
{
"idiom" : "ios-marketing",
"scale" : "1x",
"size" : "1024x1024"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
"author" : "xcode",
"version" : 1
}
}
\ No newline at end of file
}
......@@ -5,7 +5,7 @@
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleDisplayName</key>
<string>云课堂RN版</string>
<string>多场景RN版</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
......
......@@ -32,7 +32,6 @@ export default class PolyvLogin extends Component {
loginInfo: {},
tabIndex: 0,
liveScene: 1,
switchVodType: false,
}
this.handleNavigationChange = this.handleNavigationChange.bind(this)
}
......@@ -106,7 +105,7 @@ export default class PolyvLogin extends Component {
console.log(`login_click`)
if (this.state.tabIndex == 1) {//回放
this.state.loginInfo = PolyvViewManager.refCollection['PlayBackLogin'].state.playbackInfo
this.state.loginInfo = PolyvViewManager.refCollection['PlayBackLogin'].state.playbackInfo;
} else {
this.state.loginInfo = PolyvViewManager.refCollection['LiveLogin'].state.liveInfo
}
......@@ -141,7 +140,7 @@ export default class PolyvLogin extends Component {
}
})
} else {//回放登录
var vodType = this.state.switchVodType ? 1 : 0;
var vodType = loginInfo.switchVodType ? 1 : 0;
PolyvSceneModule.playbackLogin(findNodeHandle(this), this.state.liveScene, loginInfo.channelId, loginInfo.vid, vodType)
.then(ret => {
this.state.pressed = false
......@@ -176,24 +175,20 @@ export default class PolyvLogin extends Component {
</View>
<View style={styles.center}>
<View style={{ flexDirection: 'row' }} >
<View style={[styles.sceneSection]}>
<Text style={[styles.sceneText, this.state.liveScene === 1 ? { backgroundColor: '#2B98F0' } : { backgroundColor: '#A8D6F8' }]}
onPress={() => this.setState({ liveScene: 1 })}
>云课堂场景</Text>
</View>
<View style={[styles.sceneSection]}>
<Text style={[styles.sceneText, this.state.liveScene === 2 ? { backgroundColor: '#2B98F0' } : { backgroundColor: '#A8D6F8' }]}
onPress={() => this.setState({ liveScene: 2 })}
>直播带货场景</Text>
</View>
<View style={{ display: 'flex', flexDirection: 'row', width: width * 0.8, marginBottom: 50 }} >
<Text
style={[
styles.sceneSection, { marginRight: 10 },
this.state.liveScene === 1 ? { backgroundColor: '#2B98F0' } : { backgroundColor: '#A8D6F8' }]}
onPress={() => this.setState({ liveScene: 1 })}
>云课堂场景</Text>
<Text
style={[
styles.sceneSection, { marginLeft: 10 },
this.state.liveScene === 2 ? { backgroundColor: '#2B98F0' } : { backgroundColor: '#A8D6F8' }]}
onPress={() => this.setState({ liveScene: 2 })}
>直播带货场景</Text>
</View>
{/* <View style={{ flexDirection: 'row' ,paddingBottom:30}} >
<Text>回放视频是点播列表</Text>
<Switch style={{ marginLeft: 20 }} value={this.state.switchVodType}
onValueChange={value => this.setState({ switchVodType: value })} />
</View> */}
</View>
</View>
)
......@@ -271,6 +266,7 @@ class PlayBackLogin extends Component {
userId: PolyvUserConfig.User.inputUserId,
vid: PolyvUserConfig.User.inputVid,
},
switchVodType: false,
}
PolyvViewManager.refCollection['PlayBackLogin'] = this
}
......@@ -318,6 +314,18 @@ class PlayBackLogin extends Component {
}}>
{this.state.playbackInfo.vid}
</TextInput>
<View style={[{ flexDirection: 'row' }, styles.input]} >
<Text style={{ flex: 0.3 }}>点播列表</Text>
<Switch
style={{ flex: 0.7 }}
value={this.state.playbackInfo.switchVodType}
trackColor={{ true: "#2B98F0" }}
onValueChange={(value) => {
this.state.playbackInfo.switchVodType = value;
this.setState({ playbackInfo: this.state.playbackInfo })
}}
/>
</View>
</ScrollView>);
}
}
......@@ -369,7 +377,6 @@ const styles = StyleSheet.create({
backgroundColor: "gray"
},
input: {
display: 'flex',
alignItems: 'center',
height: 42,
......@@ -412,13 +419,7 @@ const styles = StyleSheet.create({
textAlign: 'center',
justifyContent: 'center',
alignItems: 'center',
paddingTop: 10,
paddingBottom: 50,
},
sceneText: {
width: width * 0.4,
padding: 10,
textAlign: 'center',
color: 'white'
}
color: 'white',
},
});
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment