9433cfb9创建于 2025年12月31日历史提交
<template>
  <view class="dialog-container">
    <video id="myVideo" src="https://qiniu-web-assets.dcloud.net.cn/video/sample/2minute-demo.mp4"
      title="这里是 dialogPage 中的 video"></video>
    <view class="dialog-content">
      <button class="mt-10" @click="requestFullScreen">
        requestFullScreen
      </button>
      <button class="mt-10" @click="exitFullScreen">
        exitFullScreen
      </button>
      <button class="mt-10" @click="closeThisPage">
        closeThisPage
      </button>
    </view>
  </view>
</template>

<script>
  export default {
    data() {
      return {
        title: 'dialogPage Video',
        backgroundColorContent: 'transparent'
      }
    },
    onBackPress() {
      this.exitFullScreen()
      return true
    },
    methods: {
      requestFullScreen() {
        uni.createVideoContext('myVideo')?.requestFullScreen(null)
      },
      exitFullScreen() {
        uni.createVideoContext('myVideo')?.exitFullScreen()
      },
      closeThisPage() {
        uni.closeDialogPage({
          dialogPage: this.$page
        })
      }
    }
  }
</script>

<style>
  .dialog-container {
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.3);
    display: flex;
    justify-content: center;
    align-items: center;
  }

  .dialog-content {
    width: 80%;
    padding: 10px;
    background-color: #fff;
    border-radius: 6px;
  }
</style>