@conecli/cone-render 0.9.1-shop2.8 → 0.10.1-beta.0

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.
Files changed (56) hide show
  1. package/dist/api/index.ts +1 -1
  2. package/dist/assets/icon_blue_info.svg +1 -0
  3. package/dist/common/const.ts +1 -1
  4. package/dist/common/environmentType.ts +1 -0
  5. package/dist/common/index.h5.ts +1 -1
  6. package/dist/common/index.jd.ts +1 -1
  7. package/dist/common/index.ts +1 -1
  8. package/dist/common/index.weapp.ts +1 -1
  9. package/dist/common/jdplayerSdk.ts +1 -0
  10. package/dist/common/sgmCustomCode.ts +1 -0
  11. package/dist/common/wxappApi.jd.ts +1 -0
  12. package/dist/components/ErrorBoundary.tsx +1 -1
  13. package/dist/components/base/CustomScrollView/index.jd.tsx +1 -0
  14. package/dist/components/base/CustomScrollView/index.module.scss +7 -0
  15. package/dist/components/base/CustomVideo/index.tsx +1 -1
  16. package/dist/components/base/InOrOutViewObserver/index.tsx +1 -1
  17. package/dist/components/base/LazyLayoutLoad/index.tsx +1 -1
  18. package/dist/components/base/LazyLoadImage/index.h5.tsx +1 -1
  19. package/dist/components/base/NetworkDataError/index.tsx +1 -1
  20. package/dist/components/debug/DebugLayout/index.module.scss +67 -0
  21. package/dist/components/debug/DebugLayout/index.tsx +1 -0
  22. package/dist/components/debug/DebugLayout/utils.ts +1 -0
  23. package/dist/components/decorate/EmptyFloorModule/index.tsx +1 -1
  24. package/dist/components/floorItem.jd.tsx +1 -1
  25. package/dist/components/floorItem.weapp.tsx +1 -1
  26. package/dist/components/isv/Floor/index.tsx +1 -1
  27. package/dist/components/remoteFloorItem.tsx +1 -1
  28. package/dist/interface/common.ts +1 -1
  29. package/dist/interface/component.ts +1 -1
  30. package/dist/interface/jumpEventReport.ts +1 -1
  31. package/dist/interface/service.ts +1 -1
  32. package/dist/interface/utils.ts +1 -1
  33. package/dist/jumpEventReport/base.ts +1 -1
  34. package/dist/jumpEventReport/createReportFloorData.ts +1 -1
  35. package/dist/jumpEventReport/index.h5.ts +1 -1
  36. package/dist/jumpEventReport/index.jd.ts +1 -1
  37. package/dist/jumpEventReport/jumpUrlConfig/base.ts +1 -1
  38. package/dist/jumpEventReport/web.jxwxapp.ts +1 -0
  39. package/dist/jumpEventReport/web.tjapp.ts +1 -0
  40. package/dist/jumpEventReport/web.tjm.ts +1 -0
  41. package/dist/open/api/environment.ts +1 -1
  42. package/dist/open/api/index.ts +1 -1
  43. package/dist/open/api/track.ts +1 -1
  44. package/dist/sass/app.h5.scss +5 -0
  45. package/dist/service/requestServer.ts +1 -1
  46. package/dist/utils/connectNativeJsBridge.ts +1 -1
  47. package/dist/utils/draExceptionAndProfile.ts +1 -1
  48. package/dist/utils/h5Utils.ts +1 -1
  49. package/dist/utils/index.h5.ts +1 -1
  50. package/dist/utils/index.ts +1 -1
  51. package/dist/utils/index.weapp.ts +1 -1
  52. package/dist/utils/jm-common.js +1 -1
  53. package/dist/utils/sgmCodeUtils.ts +1 -0
  54. package/dist/utils/utils.ts +1 -1
  55. package/package.json +42 -39
  56. package/dist/customHooks/useDocumentVisibilitychange.ts +0 -1
@@ -1 +1 @@
1
- import React, { useCallback, useEffect, useRef, useState } from 'react'
2
1
  isH5,
3
2
  addHttps,
4
3
  isH5AndJingGouMini,
5
4
  isH5AndJdShopView,
6
5
  (props: ComponentInterFace.CustomVideoProps, ref: any) => {
7
6
  const {
8
7
  style,
9
8
  videoStyle,
10
9
  src,
11
10
  width,
12
11
  height,
13
12
  controls,
14
13
  poster,
15
14
  autoplay,
16
15
  loop,
17
16
  showMuteBtn,
18
17
  muteButtonPostion,
19
18
  showFullscreenBtn,
20
19
  muteBtnPicSrcObj,
21
20
  muteBtnClassName,
22
21
  muteBtnStyle,
23
22
  objectFit,
24
23
  mockAutoplay,
25
24
  threshold,
26
25
  onPlayCallback,
27
26
  onPauseCallback,
28
27
  onVideoApiCall,
29
28
  inViewCallback,
30
29
  outViewCallback,
31
30
  } = props
32
31
  const [videoMutedState, setVideoMutedState] = useState(MUTED)
33
32
  const manualPauseStateRef = useRef(false)
34
33
  const initPlayStatusRef = useRef(false)
35
34
  const isInViewStateRef = useRef(false)
36
35
  const disposeRef = useRef<Function | null>()
37
36
  ref === null && (ref = useRef<HTMLVideoElement | null>())
38
37
 
39
38
  const playVideo = useCallback(() => {
40
39
  if (ref && ref.current) {
41
40
  const result = ref.current.play()
42
41
  result &&
43
42
  result
44
43
  .then(() => {
45
44
  console.log('播放成功')
46
45
  })
47
46
  .catch((e) => {
48
47
  console.log('playVideo Error:', e.message)
49
48
  })
50
49
  }
51
50
  }, [])
52
51
 
53
52
  const pauseVideo = useCallback(() => {
54
53
  if (ref && ref.current) {
55
54
  console.log('pauseVideo')
56
55
  ref.current.pause()
57
56
  }
58
57
  }, [])
59
58
 
60
59
  useEffect(() => {
61
60
  if (!isH5 || !ref.current) return
62
61
  if (autoplay && mockAutoplay) {
63
62
 
64
63
  const callInitAutoplay = () => {
65
64
  console.log(
66
65
  'callInitAutoplay:',
67
66
  autoplay,
68
67
  'initPlayStatusRef:',
69
68
  initPlayStatusRef.current,
70
69
  'isInViewStateRef:',
71
70
  isInViewStateRef.current,
72
71
  'paused:',
73
72
  ref.current.paused,
74
73
  )
75
74
  if (
76
75
  autoplay &&
77
76
  mockAutoplay &&
78
77
  !initPlayStatusRef.current &&
79
78
  isInViewStateRef.current &&
80
79
  ref.current.paused
81
80
  ) {
82
81
  console.log('callInitAutoplay playVideo')
83
82
  playVideo()
84
83
  }
85
84
  }
86
85
  const onWeixinJSBridgeReady = (e) => {
87
86
  console.log('onWeixinJSBridgeReady:', e.type)
88
87
  callInitAutoplay()
89
88
  }
90
89
  const onTouchstart = (e) => {
91
90
  console.log('onTouchstart:', e.type)
92
91
  callInitAutoplay()
93
92
  }
94
93
  const onScroll = (e) => {
95
94
  console.log('onScroll:', e.type)
96
95
  callInitAutoplay()
97
96
  }
98
97
  const onPlay = (e) => {
99
98
  console.log('onPlay:', e.type)
100
99
  if (!initPlayStatusRef.current) {
101
100
  const dispose = disposeRef.current
102
101
  console.log('onPlay dispose:', dispose)
103
102
  dispose && dispose()
104
103
  disposeRef.current = null
105
104
  }
106
105
  initPlayStatusRef.current = true
107
106
  }
108
107
  document?.addEventListener('WeixinJSBridgeReady', onWeixinJSBridgeReady)
109
108
  document?.addEventListener('touchstart', onTouchstart)
110
109
  document?.addEventListener('scroll', onScroll)
111
110
  ref.current.addEventListener('play', onPlay)
112
111
  const dispose = () => {
113
112
  console.log('调用dispose')
114
113
  document?.removeEventListener(
115
114
  'WeixinJSBridgeReady',
116
115
  onWeixinJSBridgeReady,
117
116
  )
118
117
  document?.removeEventListener('touchstart', onTouchstart)
119
118
  document?.removeEventListener('scroll', onScroll)
120
119
  ref?.current?.removeEventListener('play', onPlay)
121
120
  }
122
121
  disposeRef.current = dispose
123
122
  }
124
123
  !autoplay && (manualPauseStateRef.current = true)
125
124
  const handleVideoPlayApiCall = () => {
126
125
  if (!isH5 || !ref.current) return
127
126
  playVideo()
128
127
  manualPauseStateRef.current = false
129
128
  }
130
129
  const handleVideoPauseApiCall = () => {
131
130
  if (!isH5 || !ref.current) return
132
131
  pauseVideo()
133
132
  manualPauseStateRef.current = true
134
133
  }
135
134
 
136
135
  const handleVideoSeekApiCall = (position: number) => {
137
136
  console.log('video定位至', position)
138
137
  if (!isH5 || !ref.current) return
139
138
  if (typeof position === 'undefined' || typeof position !== 'number')
140
139
  return
141
140
  ref.current.currentTime = position
142
141
  }
143
142
 
144
143
  if (onVideoApiCall) {
145
144
  onVideoApiCall({
146
145
  play: handleVideoPlayApiCall,
147
146
  pause: handleVideoPauseApiCall,
148
147
  seek: handleVideoSeekApiCall,
149
148
  })
150
149
  }
151
150
  return () => {
152
151
  const dispose = disposeRef.current
153
152
  dispose && dispose()
154
153
  disposeRef.current = null
155
154
  }
156
155
  }, [])
157
156
 
158
157
  const handleMuted = useCallback(() => {
159
158
  if (!isH5 || !ref.current) return
160
159
  const handleMutedState = ref.current.muted
161
160
  if (handleMutedState === true) {
162
161
  ref.current.muted = false
163
162
  setVideoMutedState(false)
164
163
  } else {
165
164
  ref.current.muted = true
166
165
  setVideoMutedState(true)
167
166
  }
168
167
  }, [videoMutedState])
169
168
 
170
169
  const handleVideoInViewCallback = useCallback(() => {
171
170
  if (!isH5 || !ref.current) return
172
171
  isInViewStateRef.current = true
173
172
  console.log(
174
173
  '进入可视区域,initPlayStatusRef:',
175
174
  initPlayStatusRef.current,
176
175
  'isInViewStateRef:',
177
176
  isInViewStateRef.current,
178
177
  )
179
178
  if (
180
179
  autoplay &&
181
180
  mockAutoplay &&
182
181
  !initPlayStatusRef.current &&
183
182
  ref.current.paused
184
183
  ) {
185
184
  console.log('进入可视区域了 callInitAutoplay playVideo')
186
185
  playVideo()
187
186
  } else if (!manualPauseStateRef.current && ref.current.paused) {
188
187
  playVideo()
189
188
  }
190
189
  typeof inViewCallback === 'function' && inViewCallback()
191
190
  }, [])
192
191
 
193
192
  const handleVideoOutViewCallback = useCallback(() => {
194
193
  if (!isH5 || !ref.current) return
195
194
  isInViewStateRef.current = false
196
195
  console.log(
197
196
  '不在可视区域, 视频暂停了, isInViewStateRef:',
198
197
  isInViewStateRef.current,
199
198
  )
200
199
  pauseVideo()
201
200
  typeof outViewCallback === 'function' && outViewCallback()
202
201
  }, [])
203
202
 
204
203
  const getVideoWidthAndHeightStyle = () => {
205
204
  const style = {}
206
205
  width && (style['width'] = width)
207
206
  height && (style['height'] = height)
208
207
  return style
209
208
  }
210
209
 
211
210
  const getMuteBtnBackgroundImageStyle = useCallback(() => {
212
211
  const isMutedPicSrc = muteBtnPicSrcObj?.IS_MUTED
213
212
  const notMutedPicSrc = muteBtnPicSrcObj?.NOT_MUTED
214
213
  const finalIsMutedPicSrc =
215
214
  typeof isMutedPicSrc !== 'undefined' && isMutedPicSrc !== ''
216
215
  ? isMutedPicSrc
217
216
  : DEFAULT_MUTE_BTN_PIC.IS_MUTED
218
217
  const finalNotMutedPicSrc =
219
218
  typeof notMutedPicSrc !== 'undefined' && notMutedPicSrc !== ''
220
219
  ? notMutedPicSrc
221
220
  : DEFAULT_MUTE_BTN_PIC.NOT_MUTED
222
221
  return {
223
222
  backgroundImage: `url(${
224
223
  videoMutedState ? finalIsMutedPicSrc : finalNotMutedPicSrc
225
224
  })`,
226
225
  }
227
226
  }, [videoMutedState])
228
227
  console.log('autoplay:', autoplay, 'muted:', MUTED)
229
228
  console.log('isH5:', isH5, 'isH5AndJingGouMini:', isH5AndJingGouMini)
230
229
  return src ? (
231
230
  <InOrOutViewObserver
232
231
  inViewCallback={handleVideoInViewCallback}
233
232
  outViewCallback={handleVideoOutViewCallback}
234
233
  threshold={threshold}
235
234
  >
236
235
  {isH5 ? (
237
236
  <View
238
237
  className={customVideoStyle['d-video-wrap']}
239
238
  style={{ ...style, ...getVideoWidthAndHeightStyle() }}
240
239
  >
241
240
  <video
242
241
  style={{ ...videoStyle }}
243
242
  className={customVideoStyle['d-video-play']}
244
243
  src={src}
245
244
  controls={controls}
246
245
  poster={poster ? addHttps(poster) : ''}
247
246
  ref={ref}
248
247
  loop={loop}
249
248
  autoPlay={autoplay}
250
249
  muted={MUTED}
251
250
  x5-playsinline="true"
252
251
  playsInline
253
252
  webkit-playsinline="true"
254
253
  controlsList={
255
254
  isH5AndJdShopView
256
255
  ? 'nodownload nofullscreen noremoteplayback'
257
256
  : ''
258
257
  }
259
258
  onPlay={onPlayCallback}
260
259
  onPause={onPauseCallback}
261
260
  />
262
261
  {!controls && showMuteBtn && (
263
262
  <View
264
263
  className={classNames(
265
264
  customVideoStyle['d-video-mute-btn'],
266
265
  customVideoStyle[`d-mute-btn-${muteButtonPostion}`],
267
266
  `${muteBtnClassName}`,
268
267
  )}
269
268
  style={{ ...getMuteBtnBackgroundImageStyle(), ...muteBtnStyle }}
270
269
  onClick={handleMuted}
271
270
  ></View>
272
271
  )}
273
272
  </View>
274
273
  ) : (
275
274
  <Video
276
275
  style={{ ...videoStyle }}
277
276
  ref={ref}
278
277
  className={customVideoStyle['d-video-play']}
279
278
  src={src}
280
279
  controls={controls}
281
280
  poster={poster ? addHttps(poster) : ''}
282
281
  loop={loop}
283
282
  autoplay={autoplay}
284
283
  muted={MUTED}
285
284
  showMuteBtn={showMuteBtn}
286
285
  showFullscreenBtn={showFullscreenBtn}
287
286
  objectFit={objectFit}
288
287
  onPlay={onPlayCallback}
289
288
  onPause={onPauseCallback}
290
289
  />
291
290
  )}
292
291
  </InOrOutViewObserver>
293
292
  ) : null
294
293
  },
295
294
  const buildType = process.env.BUILD_TYPE
296
295
  const mockAutoplay = buildType === BUILD_TYPE.DECORATE ? false : true
297
296
  return mockAutoplay
298
297
  style: {},
299
298
  videoStyle: {},
300
299
  className: '',
301
300
  src: '',
302
301
  width: '100%',
303
302
  height: '100%',
304
303
  controls: false,
305
304
  poster: '',
306
305
  autoplay: true,
307
306
  mockAutoplay: getDefaultMockAutoplay(),
308
307
  loop: true,
309
308
  showMuteBtn: true,
310
309
  muteButtonPostion: 'topLeft',
311
310
  muteBtnPicSrcObj: DEFAULT_MUTE_BTN_PIC,
312
311
  muteBtnClassName: '',
313
312
  muteBtnStyle: {},
314
313
  showFullscreenBtn: false,
315
314
  objectFit: 'cover',
316
315
  threshold: 0.6,
316
+ import React, { useCallback, useEffect, useRef, useState } from 'react'
317
317
  (props: ComponentInterFace.CustomVideoProps, ref: any) => {
318
318
  const {
319
319
  isSystemVideo,
320
320
  style,
321
321
  videoStyle,
322
322
  src,
323
323
  width,
324
324
  height,
325
325
  controls,
326
326
  id,
327
327
  poster,
328
328
  autoplay: isvAutoplay,
329
329
  loop,
330
330
  showMuteBtn: isvShowMuteBtn,
331
331
  muteButtonPostion,
332
332
  showFullscreenBtn,
333
333
  muteBtnPicSrcObj,
334
334
  muteBtnClassName,
335
335
  muteBtnStyle,
336
336
  objectFit,
337
337
  mockAutoplay,
338
338
  threshold,
339
339
  onPlayCallback,
340
340
  onPauseCallback,
341
341
  onVideoApiCall,
342
342
  inViewCallback,
343
343
  outViewCallback,
344
344
  } = props
345
345
  const {
346
346
  wifiVideoAutoPlay,
347
347
  } = global.info.sysInfo
348
348
  const isFollowAppVideoPlayStatus = global.getDynamicConfig('isFollowAppVideoPlayStatus')
349
349
  let showMuteBtn = isvShowMuteBtn
350
350
  let autoplay = isvAutoplay
351
351
  if (isSystemVideo) {
352
352
  showMuteBtn = false
353
353
  autoplay = wifiVideoAutoPlay
354
354
  } else {
355
355
  if (isvAutoplay && isFollowAppVideoPlayStatus) {
356
356
  autoplay = wifiVideoAutoPlay
357
357
  }
358
358
  }
359
359
  console.log(
360
360
  'CustomVideo',
361
361
  'isSystemVideo:',
362
362
  isSystemVideo,
363
363
  'wifiVideoAutoPlay:',
364
364
  wifiVideoAutoPlay,
365
365
  ',isvAutoplay:',
366
366
  isvAutoplay,
367
367
  ',isFollowAppVideoPlayStatus:',
368
368
  isFollowAppVideoPlayStatus,
369
369
  ',autoplay:',
370
370
  autoplay,
371
371
  ',id:',
372
372
  id,
373
373
  )
374
374
  const [videoMutedState, setVideoMutedState] = useState(MUTED)
375
375
  const lastPlayStatusRef = useRef(-1)
376
376
  const manualPauseStateRef = useRef(false)
377
377
  const initPlayStatusRef = useRef(false)
378
378
  const isInViewStateRef = useRef(false)
379
379
  const disposeRef = useRef<Function | null>()
380
380
  ref === null && (ref = useRef<HTMLVideoElement | null>())
381
381
 
382
382
  const playVideo = useCallback(() => {
383
383
  if (ref && ref.current) {
384
384
  console.log(`CustomVideo id:${id} 开始播放视频`)
385
385
  const result = ref.current.play()
386
386
  result &&
387
387
  result
388
388
  .then(() => {
389
389
  console.log(`播放视频成功`)
390
390
  })
391
391
  .catch(e => {
392
392
  console.log('playVideo Error:', e.message)
393
393
  })
394
394
  }
395
395
  }, [])
396
396
 
397
397
  const pauseVideo = useCallback(() => {
398
398
  if (ref && ref.current) {
399
399
  console.log(`CustomVideo id:${id} 暂停视频`)
400
400
  ref.current.pause()
401
401
  }
402
402
  }, [])
403
403
 
404
404
  useEffect(() => {
405
405
  if (!isH5 || !ref.current) return
406
406
  if (autoplay && mockAutoplay) {
407
407
 
408
408
  const callInitAutoplay = () => {
409
409
  console.log(
410
410
  `CustomVideo id:${id} 触发初始化autoplay callInitAutoplay`,
411
411
  )
412
412
  if (
413
413
  autoplay &&
414
414
  mockAutoplay &&
415
415
  !initPlayStatusRef.current &&
416
416
  isInViewStateRef.current &&
417
417
  ref.current.paused
418
418
  ) {
419
419
  playVideo()
420
420
  }
421
421
  }
422
422
  const onWeixinJSBridgeReady = e => {
423
423
  callInitAutoplay()
424
424
  }
425
425
  const onTouchstart = e => {
426
426
  callInitAutoplay()
427
427
  }
428
428
  const onScroll = e => {
429
429
  callInitAutoplay()
430
430
  }
431
431
  const onPlay = e => {
432
432
  if (!initPlayStatusRef.current) {
433
433
  const dispose = disposeRef.current
434
434
  dispose && dispose()
435
435
  disposeRef.current = null
436
436
  }
437
437
  initPlayStatusRef.current = true
438
438
  }
439
439
  document?.addEventListener('WeixinJSBridgeReady', onWeixinJSBridgeReady)
440
440
  document?.addEventListener('touchstart', onTouchstart)
441
441
  document?.addEventListener('scroll', onScroll)
442
442
  ref.current.addEventListener('play', onPlay)
443
443
  const dispose = () => {
444
444
  console.log('调用dispose')
445
445
  document?.removeEventListener(
446
446
  'WeixinJSBridgeReady',
447
447
  onWeixinJSBridgeReady,
448
448
  )
449
449
  document?.removeEventListener('touchstart', onTouchstart)
450
450
  document?.removeEventListener('scroll', onScroll)
451
451
  ref?.current?.removeEventListener('play', onPlay)
452
452
  }
453
453
  disposeRef.current = dispose
454
454
  }
455
455
  const handleVideoPlayApiCall = () => {
456
456
  if (!isH5 || !ref.current) return
457
457
  playVideo()
458
458
  manualPauseStateRef.current = false
459
459
  }
460
460
  const handleVideoPauseApiCall = () => {
461
461
  if (!isH5 || !ref.current) return
462
462
  manualPauseStateRef.current = true
463
463
  pauseVideo()
464
464
  }
465
465
 
466
466
  const handleVideoSeekApiCall = (position: number) => {
467
467
  if (!isH5 || !ref.current) return
468
468
  if (typeof position === 'undefined' || typeof position !== 'number')
469
469
  return
470
470
  ref.current.currentTime = position
471
471
  }
472
472
 
473
473
  if (onVideoApiCall) {
474
474
  onVideoApiCall({
475
475
  play: handleVideoPlayApiCall,
476
476
  pause: handleVideoPauseApiCall,
477
477
  seek: handleVideoSeekApiCall,
478
478
  })
479
479
  }
480
480
  return () => {
481
481
  const dispose = disposeRef.current
482
482
  dispose && dispose()
483
483
  disposeRef.current = null
484
484
  }
485
485
  }, [])
486
486
 
487
487
  const handleMuted = useCallback(() => {
488
488
  if (!isH5 || !ref.current) return
489
489
  const handleMutedState = ref.current.muted
490
490
  if (handleMutedState === true) {
491
491
  ref.current.muted = false
492
492
  setVideoMutedState(false)
493
493
  } else {
494
494
  ref.current.muted = true
495
495
  setVideoMutedState(true)
496
496
  }
497
497
  }, [videoMutedState])
498
498
 
499
499
  const handleVideoInViewCallback = useCallback(() => {
500
500
  if (!isH5 || !ref.current) return
501
501
  console.log(
502
502
  `
503
503
  )} CustomVideo handleVideoInViewCallback id:${id} 进入可视区域 lastPlayStatusRef.current:${lastPlayStatusRef.current},paused:${ref.current.paused}`,
504
504
  )
505
505
  isInViewStateRef.current = true
506
506
  if (
507
507
  autoplay &&
508
508
  mockAutoplay &&
509
509
  !initPlayStatusRef.current &&
510
510
  ref.current.paused
511
511
  ) {
512
512
  console.log(`CustomVideo id:${id} 首次进入可视区域`)
513
513
  playVideo()
514
514
  } else if (lastPlayStatusRef.current === 1 && ref.current.paused) {
515
515
  console.log(`CustomVideo id:${id} 非首次进入可视区域`)
516
516
  playVideo()
517
517
  }
518
518
  typeof inViewCallback === 'function' && inViewCallback()
519
519
  }, [])
520
520
 
521
521
  const handleVideoOutViewCallback = useCallback(() => {
522
522
  if (!isH5 || !ref.current) return
523
523
  isInViewStateRef.current = false
524
524
  console.log(
525
525
  `CustomVideo handleVideoOutViewCallback id:${id} 不在可视区域,视频暂停,lastPlayStatusRef:${lastPlayStatusRef.current}`,
526
526
  )
527
527
  pauseVideo()
528
528
  typeof outViewCallback === 'function' && outViewCallback()
529
529
  }, [])
530
530
 
531
531
  const getVideoWidthAndHeightStyle = () => {
532
532
  const style = {}
533
533
  width && (style['width'] = width)
534
534
  height && (style['height'] = height)
535
535
  return style
536
536
  }
537
537
 
538
538
  const getMuteBtnBackgroundImageStyle = useCallback(() => {
539
539
  const isMutedPicSrc = muteBtnPicSrcObj?.IS_MUTED
540
540
  const notMutedPicSrc = muteBtnPicSrcObj?.NOT_MUTED
541
541
  const finalIsMutedPicSrc =
542
542
  typeof isMutedPicSrc !== 'undefined' && isMutedPicSrc !== ''
543
543
  ? isMutedPicSrc
544
544
  : DEFAULT_MUTE_BTN_PIC.IS_MUTED
545
545
  const finalNotMutedPicSrc =
546
546
  typeof notMutedPicSrc !== 'undefined' && notMutedPicSrc !== ''
547
547
  ? notMutedPicSrc
548
548
  : DEFAULT_MUTE_BTN_PIC.NOT_MUTED
549
549
  return {
550
550
  backgroundImage: `url(${
551
551
  videoMutedState ? finalIsMutedPicSrc : finalNotMutedPicSrc
552
552
  })`,
553
553
  }
554
554
  }, [videoMutedState])
555
555
  return src ? (
556
556
  <InOrOutViewObserver
557
557
  inViewCallback={handleVideoInViewCallback}
558
558
  outViewCallback={handleVideoOutViewCallback}
559
559
  threshold={threshold}
560
560
  >
561
561
  {isH5 ? (
562
562
  <View
563
563
  className={customVideoStyle['d-video-wrap']}
564
564
  style={{ ...style, ...getVideoWidthAndHeightStyle() }}
565
565
  >
566
566
  <video
567
567
  style={{ ...videoStyle }}
568
568
  className={classNames(customVideoStyle['d-video-play'], {
569
569
  'd-video-forbid-fullscreen-button': isSystemVideo,
570
570
  })}
571
571
  id={id}
572
572
  data-jd-video={true}
573
573
  src={src}
574
574
  controls={controls}
575
575
  poster={poster ? addHttps(poster) : ''}
576
576
  ref={ref}
577
577
  loop={loop}
578
578
  autoPlay={autoplay}
579
579
  muted={MUTED}
580
580
  x5-playsinline="true"
581
581
  playsInline
582
582
  webkit-playsinline="true"
583
583
  controlsList={
584
584
  isH5AndJdShopView
585
585
  ? 'nodownload nofullscreen noremoteplayback'
586
586
  : ''
587
587
  }
588
588
  onPlay={e => {
589
589
  lastPlayStatusRef.current = 1
590
590
  onPlayCallback && onPlayCallback(e)
591
591
  }}
592
592
  onPause={e => {
593
593
  if (isInViewStateRef.current) {
594
594
  lastPlayStatusRef.current = 0
595
595
  }
596
596
  onPauseCallback && onPauseCallback(e)
597
597
  }}
598
598
  />
599
599
  {!controls && showMuteBtn && (
600
600
  <View
601
601
  className={classNames(
602
602
  customVideoStyle['d-video-mute-btn'],
603
603
  customVideoStyle[`d-mute-btn-${muteButtonPostion}`],
604
604
  `${muteBtnClassName}`,
605
605
  )}
606
606
  style={{ ...getMuteBtnBackgroundImageStyle(), ...muteBtnStyle }}
607
607
  onClick={handleMuted}
608
608
  ></View>
609
609
  )}
610
610
  </View>
611
611
  ) : (
612
612
  <Video
613
613
  style={{ ...videoStyle }}
614
614
  ref={ref}
615
615
  className={customVideoStyle['d-video-play']}
616
616
  src={src}
617
617
  id={id}
618
618
  controls={controls}
619
619
  poster={poster ? addHttps(poster) : ''}
620
620
  loop={loop}
621
621
  data-jd-video={true}
622
622
  autoplay={autoplay}
623
623
  muted={MUTED}
624
624
  showMuteBtn={showMuteBtn}
625
625
  showFullscreenBtn={showFullscreenBtn}
626
626
  objectFit={objectFit}
627
627
  onPlay={e => {
628
628
  lastPlayStatusRef.current = 1
629
629
  onPlayCallback && onPlayCallback(e)
630
630
  }}
631
631
  onPause={e => {
632
632
  if (isInViewStateRef.current) {
633
633
  lastPlayStatusRef.current = 0
634
634
  }
635
635
  onPauseCallback && onPauseCallback(e)
636
636
  }}
637
637
  />
638
638
  )}
639
639
  </InOrOutViewObserver>
640
640
  ) : null
641
641
  },
642
642
  return process.env.BUILD_TYPE !== BUILD_TYPE.DECORATE
643
643
  isSystemVideo: false,
644
644
  id: '',
645
645
  style: {},
646
646
  videoStyle: {},
647
647
  className: '',
648
648
  src: '',
649
649
  width: '100%',
650
650
  height: '100%',
651
651
  controls: false,
652
652
  poster: '',
653
653
  autoplay: true,
654
654
  mockAutoplay: getDefaultMockAutoplay(),
655
655
  loop: true,
656
656
  showMuteBtn: true,
657
657
  muteButtonPostion: 'topLeft',
658
658
  muteBtnPicSrcObj: DEFAULT_MUTE_BTN_PIC,
659
659
  muteBtnClassName: '',
660
660
  muteBtnStyle: {},
661
661
  showFullscreenBtn: false,
662
662
  objectFit: 'cover',
663
663
  threshold: 0.6,