@x-edu/live-player 0.0.12 → 0.0.14

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/src/demo/List.jsx CHANGED
@@ -2,24 +2,24 @@ import React, { useEffect, useState } from 'react'
2
2
  import { UC } from '@sdp.nd/nd-uc-sdk'
3
3
  import Live from '../App'
4
4
 
5
- const uc = new UC({
6
- env: 'ncet-xedu',
7
- sdpAppId: 'e5649925-441d-4a53-b525-51a2f1c4e0a8',
8
- origins: {
9
- UC: 'https://uc-gateway.ykt.eduyun.cn',
10
- SSO: 'https://sso.basic.smartedu.cn'
11
- },
12
- isGlobalSDKCacheEnabled: true
13
- })
14
5
  // const uc = new UC({
15
- // env: 'preproduction',
16
- // sdpAppId: '331593d3-af38-456e-bdb8-5263525608f4',
6
+ // env: 'ncet-xedu',
7
+ // sdpAppId: 'e5649925-441d-4a53-b525-51a2f1c4e0a8',
17
8
  // origins: {
18
- // UC: 'https://uc-gateway.beta.101.com',
19
- // SSO: 'https://ysc-sso.ykt.eduyun.cn'
9
+ // UC: 'https://uc-gateway.ykt.eduyun.cn',
10
+ // SSO: 'https://sso.basic.smartedu.cn'
20
11
  // },
21
12
  // isGlobalSDKCacheEnabled: true
22
13
  // })
14
+ const uc = new UC({
15
+ env: 'preproduction',
16
+ sdpAppId: '331593d3-af38-456e-bdb8-5263525608f4',
17
+ origins: {
18
+ UC: 'https://uc-gateway.beta.101.com',
19
+ SSO: 'https://ysc-sso.ykt.eduyun.cn'
20
+ },
21
+ isGlobalSDKCacheEnabled: true
22
+ })
23
23
 
24
24
  export default function List() {
25
25
  const [ucInstance, setUcInstance] = useState(uc)
@@ -34,7 +34,9 @@ export default function List() {
34
34
  try {
35
35
  await ucInstance.login({
36
36
  loginName: '18695708674',
37
- password: 'gyh123456'
37
+ password: 'Gyh.2233'
38
+ // loginName: '18695708674',
39
+ // password: 'gyh123456'
38
40
  })
39
41
  const account = ucInstance.getCurrentAccount()
40
42
  const info = await account.getAccountInfo()
@@ -7,7 +7,6 @@ import style from './index.module.less'
7
7
  import AnchorOnTheWay from './AnchorOnTheWay'
8
8
 
9
9
  function LiveStatus({
10
- isStreamLive,
11
10
  handleLogin,
12
11
  userInfo,
13
12
  liveInfo,
@@ -27,6 +26,7 @@ function LiveStatus({
27
26
  const isPaused = liveInfo.status === PUBLIC_LIVE_STATUS.PASUED
28
27
  const isOffline = liveInfo.status === PUBLIC_LIVE_STATUS.OFFLINE
29
28
  const isRecordLive = liveInfo.type === PUBLIC_LIVE_MODE.RECORDED
29
+ const isStreamLive = liveInfo.type === PUBLIC_LIVE_MODE.LIVING && (liveInfo.sub_type === SUB_TYPE.OUTSIDE || liveInfo.sub_type === SUB_TYPE.REBROADCAST)
30
30
 
31
31
  // 当前时间是否在回放时间开始前, 如果没有回放开始时间, 则直接判断未回放还没生成
32
32
  const isBeforeRecordTime = liveInfo.replay_begin_time
@@ -45,7 +45,6 @@ const shouldfixedLoading = window.navigator.userAgent.indexOf('iPad') > -1
45
45
  || isInWX()
46
46
 
47
47
  export default function LiveVideo({
48
- isStreamLive,
49
48
  handleLogin,
50
49
  userInfo,
51
50
  liveInfo,
@@ -126,7 +125,7 @@ export default function LiveVideo({
126
125
  onRequestFullScreen()
127
126
  })
128
127
  aliPlayer.on('liveStreamStop', (err) => {
129
- setIsLiveLoadError(true)
128
+ setIsLiveException(true)
130
129
  console.warn(`liveStreamStop: isOnline ${window.navigator.onLine}`)
131
130
  console.error('liveStreamStop', err)
132
131
  })
@@ -169,7 +168,6 @@ export default function LiveVideo({
169
168
  {showAliPlayer && <AliPlayer options={options} onReady={handleVideoReady} />}
170
169
  {supportM3u8 && (
171
170
  <LiveStatus
172
- isStreamLive={isStreamLive}
173
171
  handleLogin={handleLogin}
174
172
  userInfo={userInfo}
175
173
  visitTime={visitTime}
@@ -8,7 +8,6 @@ import LiveStatus from '../LiveStatus'
8
8
  import style from './index.module.less'
9
9
 
10
10
  export default function RecordVideo({
11
- isStreamLive,
12
11
  userInfo,
13
12
  liveInfo,
14
13
  visitTime,
@@ -134,7 +133,6 @@ export default function RecordVideo({
134
133
  onReady={handleVideoReady}
135
134
  />
136
135
  <LiveStatus
137
- isStreamLive={isStreamLive}
138
136
  userInfo={userInfo}
139
137
  visitTime={visitTime}
140
138
  diffTime={diffTime}
@@ -11,9 +11,10 @@ import {
11
11
  import { getIMLiveInfo, getGuestIMLiveInfo } from '@/service/imBroadcasts'
12
12
  import Loading from '@/component/status/Loading'
13
13
  import {
14
- PUBLIC_LIVE_STATUS, PUBLIC_LIVE_MODE, SUB_TYPE
14
+ PUBLIC_LIVE_STATUS, PUBLIC_LIVE_MODE, PUBLIC_LIVE_PUSH_TOPIC, PUBLIC_LIVE_PUSH_EVENT, SUB_TYPE
15
15
  } from '@/config/publicLive'
16
16
  import { getUrlQuery } from '@/util/url'
17
+ import ImPush from '@/util/push'
17
18
  import { getRecordLiveStatus } from '@/util/live'
18
19
  import { isEmpty } from '@/util/object'
19
20
  // import IMChatroom from '@/component/IMChatroom'
@@ -78,6 +79,7 @@ export default function PublicLiveDetail({
78
79
  const isLiveToReplay = !replay
79
80
  const isStreamLive = liveInfo
80
81
  && liveInfo.type === PUBLIC_LIVE_MODE.LIVING
82
+ && (liveInfo.sub_type === SUB_TYPE.OUTSIDE || liveInfo.sub_type === SUB_TYPE.REBROADCAST)
81
83
 
82
84
  const handleStatusChange = async (status) => {
83
85
  const newLiveInfo = {
@@ -195,6 +197,12 @@ export default function PublicLiveDetail({
195
197
  }
196
198
  data.imInfo = imLiveInfoResp
197
199
  }
200
+ // 推流直播不加载im push
201
+ if (data.type === PUBLIC_LIVE_MODE.LIVING && data.sub_type === SUB_TYPE.OUTSIDE) {
202
+ // nothing
203
+ } else {
204
+ await ImPush.init()
205
+ }
198
206
  // 如果是转播或者是推流 直接播放(用于调试模式)
199
207
  const { preview } = getUrlQuery() // 后台点预览会加这个参数
200
208
  const generateInfo = preview ? Object.assign(data, {
@@ -205,6 +213,27 @@ export default function PublicLiveDetail({
205
213
  init()
206
214
  }, [])
207
215
 
216
+ useEffect(() => {
217
+ if (!liveInfo || liveInfo.sub_type === SUB_TYPE.OUTSIDE) {
218
+ return
219
+ }
220
+ const handler = (data) => {
221
+ const { extraFields = {} } = data
222
+ console.log('public Live:', data)
223
+ if (extraFields.event === PUBLIC_LIVE_PUSH_EVENT.STATUS_CHANGE && extraFields.liveId === liveId) {
224
+ console.log(`public Live: receive push status ${parseInt(extraFields.status, 10)}`)
225
+ handleStatusChange(parseInt(extraFields.status, 10))
226
+ }
227
+ }
228
+ ImPush.addTopicListener(`${PUBLIC_LIVE_PUSH_TOPIC}_${liveId}`, handler)
229
+ return () => {
230
+ if (!liveInfo || liveInfo.sub_type === SUB_TYPE.OUTSIDE) {
231
+ return
232
+ }
233
+ ImPush.removeTopicListener(`${PUBLIC_LIVE_PUSH_TOPIC}_${liveId}`, handler)
234
+ }
235
+ }, [!!liveInfo])
236
+
208
237
  useEffect(() => {
209
238
  if (userInfo) {
210
239
  onReportProgress()
@@ -381,7 +410,6 @@ export default function PublicLiveDetail({
381
410
  : isRecordLive
382
411
  ? (
383
412
  <RecordVideo
384
- isStreamLive={isStreamLive}
385
413
  userInfo={userInfo}
386
414
  liveInfo={liveInfo}
387
415
  visitTime={visitTime}
@@ -398,7 +426,6 @@ export default function PublicLiveDetail({
398
426
  )
399
427
  : (
400
428
  <LiveVideo
401
- isStreamLive={isStreamLive}
402
429
  handleLogin={handleLogin}
403
430
  userInfo={userInfo}
404
431
  liveInfo={liveInfo}
@@ -443,8 +470,7 @@ export default function PublicLiveDetail({
443
470
  } */}
444
471
  </div>
445
472
  {
446
- !isReplayMode && !isRecordLive
447
- && liveInfo.sub_type !== SUB_TYPE.NET_DRAGON
473
+ !isReplayMode && !isRecordLive && isStreamLive
448
474
  && liveInfo.status !== PUBLIC_LIVE_STATUS.COMPLETEED
449
475
  && (
450
476
  <LineSwitch
@@ -23,7 +23,7 @@ export default function Action({
23
23
  const { status, live_id: liveId, begin_time: beginTime } = data
24
24
  const [curAction, setCurAction] = useState(() => {
25
25
  let actionNum
26
- if (status === 1) {
26
+ if (status === 1 || status === 3) {
27
27
  actionNum = 1
28
28
  } else if (status === 2) {
29
29
  actionNum = 2
@@ -11,7 +11,8 @@ import style from './index.module.less'
11
11
  const TagName = {
12
12
  0: '预告',
13
13
  1: '直播中',
14
- 2: '回放'
14
+ 2: '回放',
15
+ 3: '直播中' // 实际是暂停
15
16
  }
16
17
 
17
18
  export default function ListItem({
@@ -56,7 +57,7 @@ export default function ListItem({
56
57
  className={style.avatar}
57
58
  />
58
59
  <div className={classNames(style.tag, style[`tag${status}`])}>
59
- {status === 1 ? <img src={PlayImg} alt="" /> : null}
60
+ {status === 1 || status === 3 ? <img src={PlayImg} alt="" /> : null}
60
61
  {TagName[status]}
61
62
  </div>
62
63
  </div>
@@ -39,7 +39,7 @@
39
39
  background-color: #FF7826;
40
40
  }
41
41
 
42
- .tag1 { // 直播中
42
+ .tag1, .tag3 { // 直播中
43
43
  background-color: #1E62EC;
44
44
  padding: 0 5px;
45
45
 
@@ -19,7 +19,7 @@ const StatusEnum = [
19
19
  },
20
20
  {
21
21
  label: '直播中',
22
- value: 1
22
+ value: '1,3'
23
23
  },
24
24
  {
25
25
  label: '预告',