stream.js 1.2 KB

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