@x-edu/live-player 0.0.1 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,86 @@
1
+ # 直播播放器
2
+
3
+ 初版,API可能后续会大幅调整
4
+
5
+ ## Demo
6
+
7
+ ```jsx
8
+ import PublicLiveDetail from '@x-edu/live-player'
9
+ import React, { useContext } from 'react'
10
+ import style from './style.module.less'
11
+ import { getLoginUrl, uc } from '@/util/auth/func'
12
+ import UserContext from '@/component/Login/UserContext'
13
+ import { sensorsTrack } from '@/util/sensorsTracking'
14
+
15
+ export default function LiveTest() {
16
+ const loginInfo = useContext(UserContext)
17
+ // 部分直播需要登录后才可以播放,这是要求登录的回调
18
+ const handleLogin = () => {
19
+ window.location.href = getLoginUrl()
20
+ }
21
+ // 直播人数获取后调用,注意直播开始后才有本数据
22
+ const handleoOnlineCountChange = (currentCount) => {
23
+ console.log(currentCount)
24
+ }
25
+ // 直播状态发生变化后触发本事件
26
+ const handleStateChange = (liveInfo) => {
27
+ console.log(liveInfo)
28
+ }
29
+
30
+ // 登录后上报强师额外上报信息
31
+ const handleReportProgress = () => {}
32
+ // 登录且播放后上报强师额外上报信息
33
+ const handleReportTeacherTrain = () => {}
34
+
35
+ const handleSensors = (sensorInfo) => {
36
+ sensorsTrack(sensorInfo)
37
+ }
38
+
39
+ return (
40
+ <div
41
+ style={{
42
+ height: '800px',
43
+ width: '1200px'
44
+ }}
45
+ >
46
+ <PublicLiveDetail
47
+ className={style.live}
48
+ containerClassName={style.container}
49
+ infoClassName={style.info}
50
+ playerClassName={style.player}
51
+ descriptionClassName={style.desc}
52
+ liveId="13aafbce-8ca2-4587-bc6e-eab183c9d5b6"
53
+ appId="e5649925-441d-4a53-b525-51a2f1c4e0a8"
54
+ uc={uc}
55
+ loginInfo={loginInfo}
56
+ handleLogin={handleLogin}
57
+ onOnlineCountChange={handleoOnlineCountChange}
58
+ onStateChange={handleStateChange}
59
+ onReportProgress={handleReportProgress}
60
+ onReportTeacherTrain={handleReportTeacherTrain}
61
+ onSendSensors={handleSensors}
62
+ />
63
+ </div>
64
+ )
65
+ }
66
+ ```
67
+
68
+ ```less
69
+ .container {
70
+ width: 100%;
71
+ height: 100%
72
+ }
73
+
74
+ .live {
75
+ padding: 0 !important;
76
+ margin: 0;
77
+ }
78
+
79
+ .info {
80
+ display: none;
81
+ }
82
+
83
+ .desc {
84
+ display: none;
85
+ }
86
+ ```