uni-app中隐藏进度条后,进入全屏和退出全屏的方法

项目中需要这样一个功能,需要隐藏video原生的进度条,并且还能进入全屏,进入全屏后还能退出全屏。由于原生的video组件在隐藏进度条后就没有进入全屏和退出全屏按钮,此时我们必须要用js去控制进入和退出全屏。

html:

<video id="myVideo"  class="myVideo" :custom-cache="false"
					:src="xxx" :autoplay="false" :controls="false" :page-gesture='true'
					:show-progress="true" :show-play-btn="false" :show-center-play-btn="false"
					:enable-progress-gesture="false" @loadedmetadata="loadedmetadata" @timeupdate="timeupdate"
					@ended="ended" @error="videoErrorCallback" @fullscreenchange="playerFullScreen"
					@click="hideAndShow">
					<cover-view class="cover-container" v-if="onShow&&myVideo">
						<template>
							<cover-view class="currentTim" v-if="onShow&&myVideo">
								{{currentProgress?currentProgress:'00:00'}}
							</cover-view>
							<cover-view class="progress-container">
								<cover-view class="progress" v-if="onShow&&myVideo" :style="{width:progressWidth}">
									<cover-view class="circle" v-if="onShow&&myVideo"></cover-view>
								</cover-view>
								<cover-view class="total-progress" v-if="onShow&&myVideo"></cover-view>
							</cover-view>
							<cover-view class="totalTim" v-if="onShow&&myVideo">{{totalProgress?totalProgress:'00:00'}}
							</cover-view>
						</template>
						<cover-view class="screen" v-if="openScreen&&myVideo" @click="quitFullScreen">退出全屏</cover-view>
						<cover-view class="screen" v-if="!openScreen&&myVideo" @click="getIntoScreen">全屏</cover-view>
					</cover-view>
				</video>

js:

methods:{
        getIntoScreen() {
				this.myVideo = uni.createVideoContext('myVideo')
				// 进入全屏状态
				this.myVideo.requestFullScreen();
				this.openScreen = true;
			},
        quitFullScreen() {
				this.myVideo = uni.createVideoContext('myVideo')
				// 退出全屏状态
				this.myVideo.exitFullScreen();
				this.openScreen = false;
			}
}

注意:cover-view可以覆盖video组件,可以在视频上写一些样式

  • 1
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 11
    评论
你可以使用 `uni-file-picker` 组件来实现文件选择器,并结合进度条来显示上传进度。首先,你需要在项目引入 `uni-file-picker` 组件,并根据需要配置相关参数。 下面是一个示例代码,展示了如何使用 `uni-file-picker` 和进度条: ```html <template> <view> <!-- 文件选择器 --> <uni-file-picker :count="1" @success="onFileSuccess" ></uni-file-picker> <!-- 进度条 --> <uni-progress v-if="showProgress" :percent="uploadProgress" ></uni-progress> </view> </template> <script> export default { data() { return { showProgress: false, // 是否显示进度条 uploadProgress: 0, // 上传进度(百分比) }; }, methods: { onFileSuccess(res) { // 文件选择成功后触发的回调函数 const file = res.tempFiles[0]; // 显示进度条 this.showProgress = true; // 模拟上传过程,每隔一段时间更新进度 const interval = setInterval(() => { if (this.uploadProgress < 100) { this.uploadProgress += 10; } else { // 上传完成,隐藏进度条 this.showProgress = false; clearInterval(interval); } }, 1000); }, }, }; </script> ``` 在上述示例,当用户选择文件后,`uni-file-picker` 组件的 `success` 事件会被触发,然后你可以在 `onFileSuccess` 方法处理文件上传的逻辑。这里使用了一个定时器来模拟上传过程,每隔一段时间更新进度条的值。注意:在实际使用,你需要根据你的具体上传方式和逻辑来更新进度条的值。 希望以上示例对你有帮助!如有其他问题,请随时提问。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 11
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值