uni-app 视频滑动+适配ios底部安全区域

<template>
	<view class="app-video-list">
		<view class="video-list-video">
			<swiper class="swiper" circular :vertical="vertical" @animationfinish="animationfinish">
				<swiper-item v-for="(item,i) in videoList" :key="i">
					<video :src="item.url" :id="'myVideo'+i" style="width: 100%;height:845upx ;" :autoplay="autoplay"
						:loop="loop" :enable-play-gesture="true"></video>
					<cover-view class="bottom-txt">
						<view class="bot-title">
							{{item.title}}
						</view>
					</cover-view>
					<cover-view class="right-box">
						<uni-icons type="heart" color="#fff" size="40"></uni-icons>
						<uni-icons type="redo" color="#fff" size="40"></uni-icons>
					</cover-view>
				</swiper-item>
			</swiper>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				video: null,
				autoplay: false,
				loop: false,
				current: 0,
				nextCurrent: 0,
				vertical: true,
				videoList: []
			}
		},
		onLoad() {
			let videoContext = uni.createVideoContext('myVideo0')
			videoContext.play()
		},
		methods: {
			changeCat(e) {
				this.cateIndex = e
			},
			animationfinish(e) {
				let that = this
				console.log('change');
				this.nextCurrent = e.detail.current
				let lastId = 'myVideo' + that.current
				let id = 'myVideo' + that.nextCurrent
				console.log(lastId + '===id change===' + id);
				let videoContext = uni.createVideoContext(lastId)
				videoContext.pause()
				videoContext = uni.createVideoContext(id)
				videoContext.play()
				this.current = this.nextCurrent
				console.log('finish');
			}
		}
	}
</script>

<style lang="scss">
	.app-video-list {
		width: 100%;
		height: 100vh;
		background-color: #000;
		color: #fff;
		font-size: 28upx;


		.swiper {
			width: 100%;
			height: 100vh;
			display: flex;
			justify-content: center;
			align-items: center;

			.bottom-txt {
				width: 90%;
				height: auto;
				position: fixed;
				bottom: 120upx;
				display: flex;
				justify-content: center;
				align-items: center;
				flex-direction: column;

				.bot-title {
					width: 96%;
					height: auto;
				}

				.tips {
					width: 100%;
					min-height: 60upx;
					display: flex;
					justify-content: flex-start;
					align-items: flex-start;
					flex-direction: row;
					flex-wrap: wrap;

					.bot-tips {
						padding: 10upx 20upx;
						background-color: #c4c4c4;
						font-size: 24upx;
						margin-top: 20upx;
						border-radius: 60upx;
						color: #fff;
						margin-left: 20upx;
						margin-top: 20upx;
					}
				}

			}

			.right-box {
				width: 10%;
				position: fixed;
				right: 0;
				bottom: 220upx;
				display: flex;
				justify-content: center;
				align-items: flex-start;
				flex-direction: column;
			}
		}
	}
</style>

仅限于安卓,不适用于手机任何浏览器和iOS。

适配IOS底部安全区域的CSS

padding-bottom: constant(safe-area-inset-bottom);  /* 兼容 iOS 设备 */
padding-bottom: env(safe-area-inset-bottom); /* 兼容 iPhone X 及以上设备 */

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值