stream.js
1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// 一个stream 对应一个 player
import { DEFAULT_PLAYER_CONFIG } from "../common/constants.js";
class Stream {
constructor(options) {
Object.assign(this, DEFAULT_PLAYER_CONFIG, {
userID: "", // 该stream 关联的userID
streamType: "", // stream 类型 [main small] aux
streamID: "", // userID + '_' + streamType
isVisible: true, // 手Q初始化时不能隐藏 puser和player 否则黑屏。iOS 微信初始化时不能隐藏,否则同层渲染失败,player会置顶
hasVideo: false,
hasAudio: false,
volume: 0, // 音量大小 0~100
playerContext: undefined, // playerContext 依赖component context来获取,目前只能在渲染后获取
}, options);
}
reset() {
if (this.playerContext) {
this.playerContext.stop();
this.playerContext = undefined;
}
Object.assign(this, DEFAULT_PLAYER_CONFIG, {
userID: "", // 该stream 关联的userID
streamType: "", // stream 类型 [main small] aux
streamID: "",
isVisible: true,
hasVideo: false,
hasAudio: false,
volume: 0, // 音量大小 0~100
playerContext: undefined,
});
}
setProperty(options) {
Object.assign(this, options);
}
}
export default Stream;