0.0.29 • Published 4 months ago

@x-edu/live-player v0.0.29

Weekly downloads
-
License
-
Repository
-
Last release
4 months ago

直播播放器

初版,API可能后续会大幅调整

Demo

PublicLiveDetail 直播详情页

import { PublicLiveDetail, getLiveOnlineCount } from '@x-edu/live-player'
import React, { useContext } from 'react'
import style from './style.module.less'
import { getLoginUrl, uc } from '@/util/auth/func'
import UserContext from '@/component/Login/UserContext'
import { sensorsTrack } from '@/util/sensorsTracking'

export default function LiveTest() {
  const loginInfo = useContext(UserContext)

  // 获取直播人数请在直播开始之后调用并显示
  // 直播结束之后也不应显示
  useEffect(() => {
    const test = async () => {
      const count = await getLiveOnlineCount('13aafbce-8ca2-4587-bc6e-eab183c9d5b6')
      console.log(count)
    }
    test()
  }, [])

  // 部分直播需要登录后才可以播放,这是要求登录的回调
  const handleLogin = () => {
    window.location.href = getLoginUrl()
  }
  // 直播人数获取后调用,注意直播开始后才有本数据
  const handleoOnlineCountChange = (currentCount) => {
    console.log(currentCount)
  }
  // 直播状态发生变化后触发本事件
  const handleStateChange = (liveInfo) => {
    console.log(liveInfo)
  }

  // 登录后上报强师额外上报信息
  const handleReportProgress = () => {}
  // 登录且播放后上报强师额外上报信息
  const handleReportTeacherTrain = () => {}

  const handleSensors = (sensorInfo) => {
    sensorsTrack(sensorInfo)
  }

  return (
    <div
      style={{
        height: '800px',
        width: '1200px'
      }}
    >
      <PublicLiveDetail
        className={style.live}
        containerClassName={style.container}
        infoClassName={style.info}
        playerClassName={style.player}
        descriptionClassName={style.desc}
        liveId="13aafbce-8ca2-4587-bc6e-eab183c9d5b6"
        appId="e5649925-441d-4a53-b525-51a2f1c4e0a8"
        uc={uc}
        loginInfo={loginInfo}
        handleLogin={handleLogin}
        onOnlineCountChange={handleoOnlineCountChange}
        onStateChange={handleStateChange}
        onReportProgress={handleReportProgress}
        onReportTeacherTrain={handleReportTeacherTrain}
        onSendSensors={handleSensors}
      />
    </div>
  )
}
.container {
  width: 100%;
  height: 100%
}

.live {
  padding: 0 !important;
  margin: 0;
}

.info {
  display: none;
}

.desc {
  display: none;
}

直播列表页

import { PublicLiveList } from '@x-edu/live-player'
import React, { useContext } from 'react'
import style from './style.module.less'
import { getLoginUrl, uc } from '@/util/auth/func'
import UserContext from '@/component/Login/UserContext'

export default function LiveTest() {
  const loginInfo = useContext(UserContext)

  // 部分直播需要登录后才可以播放,这是要求登录的回调
  const handleLogin = (item) => {
    // 处理必须登陆的情况
    window.location.href = getLoginUrl()
  }

  const handleDetailClick = (item) => {
    // 根据 item 决定怎么跳转详情页
    // 默认跳转中小学直播详情 window.open(`https://basic.smartedu.cn/publicLive/${liveId}}`)
  }
 
  return (
    <div>
      <PublicLiveList
        scopeType='e_teacher_studio' // 适用范围,如名师工作室:e_teacher_studio 机构工作室:e_inst_studio 专家工作室:e_expert_studio 精准匹配
        scopeId='xxx' // 适用id,如专家工作室id 精准匹配,必须有scope_type才生效
        containerClassName={style.container} // 容器样式
        uc={uc} // 登陆状态下必填
        loginInfo={loginInfo} // 登陆状态下必填,特别的里面的 userInfo
        handleLogin={handleLogin} // 用于需要强制登陆的回调,会传传入当前直播作为参数
        onDetailClick={handleDetailClick}
      />
    </div>
  )
}

预生产

import { 
  PublicLiveDetail,
  getLiveOnlineCount,
  PublicLiveList
} from '@x-edu/live-player/dist/XEduLivePlayerPre.common'
0.0.29

4 months ago

0.0.28

5 months ago

0.0.27

6 months ago

0.0.26

6 months ago

0.0.25

6 months ago

0.0.24

6 months ago

0.0.23

6 months ago

0.0.22

7 months ago

0.0.21

7 months ago

0.0.20

7 months ago

0.0.19

9 months ago

0.0.18

10 months ago

0.0.17

10 months ago

0.0.16

10 months ago

0.0.15

10 months ago

0.0.14

10 months ago

0.0.13

10 months ago

0.0.12

10 months ago

0.0.11

10 months ago

0.0.10

10 months ago

0.0.1-0.beta.6

10 months ago

0.0.1-0.beta.5

10 months ago

0.0.1-0.beta.4

10 months ago

0.0.1-0.beta.3

10 months ago

0.0.1-0.beta.2

10 months ago

0.0.1-0.beta.1

10 months ago

0.0.9

11 months ago

0.0.8

11 months ago

0.0.7

11 months ago

0.0.6

11 months ago

0.0.5

11 months ago

0.0.4

11 months ago

0.0.3

11 months ago

0.0.2

11 months ago

0.0.1

11 months ago