liushengqiang 2 роки тому
батько
коміт
e710b4d962
1 змінених файлів з 64 додано та 1 видалено
  1. 64 1
      src/views/coursewarePlay/index.tsx

+ 64 - 1
src/views/coursewarePlay/index.tsx

@@ -3,6 +3,7 @@ import {
   Icon,
   Loading,
   Popup,
+  showDialog,
   showToast,
   Slider,
   Swipe,
@@ -18,7 +19,8 @@ import {
   ref,
   watch,
   Transition,
-  TransitionGroup
+  TransitionGroup,
+  onBeforeUnmount
 } from 'vue'
 import iconBack from './image/back.svg'
 import styles from './index.module.less'
@@ -241,6 +243,8 @@ export default defineComponent({
             type: 'fullscreen'
           }
         })
+        //检测是否录屏
+        handleLimitScreenRecord()
       })
     }
     const getDetail = async () => {
@@ -281,6 +285,39 @@ export default defineComponent({
       }
     }
 
+    //录屏时间触发
+    const handleLimitScreenRecord = async () => {
+      const result = await promisefiyPostMessage({
+        api: 'getDeviceStatus',
+        content: { type: 'video' }
+      })
+      const { status } = result?.content || {}
+      if (status == '1') {
+        data.itemList.forEach((item: any) => (item.autoPlay = false))
+        handleStop()
+        showDialog({
+          title: '温馨提示',
+          message: '课件内容请勿录屏',
+          beforeClose: () => {
+            return new Promise(async (resolve) => {
+              const { content } =
+                (await promisefiyPostMessage({
+                  api: 'getDeviceStatus',
+                  content: { type: 'video' }
+                })) || {}
+              if (content?.status == '1') {
+                resolve(false)
+              } else {
+                const activeItem = data.itemList[popupData.activeIndex]
+                togglePlay(activeItem, true)
+                resolve(true)
+              }
+            })
+          }
+        })
+      }
+    }
+
     onMounted(() => {
       const hasVip = handleCheckVip()
       if (!hasVip) {
@@ -298,7 +335,32 @@ export default defineComponent({
       getDetail()
       getCourseSchedule()
       window.addEventListener('message', iframeHandle)
+
+      //禁止录屏 ios
+      listenerMessage('setVideoPlayer', (result) => {
+        if (result?.content?.status == 'pause'){
+          handleLimitScreenRecord()
+        }
+      })
+
+      // 安卓
+      postMessage({
+        api: 'limitScreenRecord',
+        content: {
+          type: 1
+        }
+      })
+    })
+
+    onBeforeUnmount(() => {
+      postMessage({
+        api: 'limitScreenRecord',
+        content: {
+          type: 0
+        }
+      })
     })
+
     const playRef = ref()
     // 返回
     const goback = () => {
@@ -475,6 +537,7 @@ export default defineComponent({
             item.autoPlay = true
             nextTick(() => {
               item.videoEle?.play()
+              console.error(item.videoEle)
             })
           }
         }