点击视频暂停暂停学习时间

1html 

<div class="listBox">
						<div v-if="type == 1" style="padding: 0 30px">
							<div
								class="viewItem"
								v-for="(file, i) in form.detailVideo"
								:key="i"
								@click="startStudy(file)"
							>
								<i
									:class="
										file.fileType == 1
											? 'el-icon-document'
											: 'el-icon-video-play'
									"
								></i>
								<div class="fileTitle uniline">
									{{ i + 1 }}.
									{{ file.titleName }}
								</div>
								<div>
									<div
										class="pie"
										:style="{
											'--rotate': `rotate(${
												file.watchMinutes / (file.duration * 60 * 1000) > 0.5
													? 1 - file.watchMinutes / (file.duration * 60 * 1000)
													: 0.5 -
													  file.watchMinutes / (file.duration * 60 * 1000)
											}turn)`,
											'--color':
												file.watchMinutes / (file.duration * 60 * 1000) > 0.5
													? '#409eff'
													: '#fff',
										}"
									></div>
									<div
										style="color: #999999; font-size: 12px; line-height: 24px"
									>
										{{
											!file.watchMinutes
												? "未学习"
												: file.watchMinutes >= file.duration * 60 * 1000
												? "已学习"
												: "学习中"
										}}
									</div>
								</div>
							</div>
						</div>
						<div v-else-if="type == 2"></div>
					</div>

 2观看视频的代码

<!-- 文件观看 -->
		<el-dialog
			custom-class="customDialog"
			:close-on-click-modal="false"
			:append-to-body="true"
			:visible.sync="studyVis"
			@before-close="cancelStudy"
			:show-close="false"
			fullscreen
		>
			<div slot="title" class="studyTit" style="display: flex" v-if="studyVis">
				<i
					class="el-icon-arrow-left"
					style="
						font-size: 18px;
						line-height: 24px;
						cursor: pointer;
						font-weight: 600;
					"
					@click="cancelStudy"
				></i>
				<div class="uniline">
					{{ studyForm.fileName }}
				</div>
				<!-- v-if="seeTime" -->
				<div>
					(完成条件:至少学习{{ studyForm.duration }}分钟,当前已学{{
						seeTime
					}})
				</div>
			</div>
			<div v-if="studyVis">
				<div v-if="studyForm.fileType == 1">
					<iframe
						v-if="['pdf'].indexOf(studyForm.type) > -1"
						type="application/x-google-chrome-pdf"
						style="height: calc(100vh - 96px)"
						width="100%"
						align="center"
						scroll="no"
						:src="studyForm.fileUrl"
					></iframe>
					<office-preview
						v-else
						:uri="studyForm.fileUrl"
						style="height: calc(100vh - 96px); overflow: hidden"
					></office-preview>
				</div>

				<div v-else-if="studyForm.fileType == 2">
					<video
						id="video"
						width="100%"
						style="height: calc(100vh - 96px)"
						:src="studyForm.fileUrl.replace('http:', 'https:')"
						autoplay
						controls
						controlslist="nodownload noremoteplayback"
						oncontextmenu="return false"
						disablePictureInPicture
					>
						您的浏览器不支持 video 标签。
					</video>
				</div>
			</div>
		</el-dialog>

3方法

startStudy(file) {
			if (file.fileType == 1) {
				let arr = file.fileName.split(".");
				file.type = arr[arr.length - 1];
				if (["pdf"].indexOf(file.type) > -1) {
					let baseUrl =
						"https://resources.bingyimd.com/crm/statics/pdfjs/web/viewer.html?file=";
					file.fileUrl = baseUrl + file.fileUrl.replace("http:", "https:");
				}
			}
			this.studyForm = file;
			this.studyVis = true;
			this.nowSee = 0;
			watermark.init({
				watermark_txt:
					"火蝠内训资料  严禁泄露  " + this.$session.get(true).user.name, // 水印的内容 测试水印,520
				watermark_color: "#f80d4a", // 水印字体颜色
				watermark_alpha: 0.2, // 水印透明度,要求设置在大于等于0.005
				watermark_width: 120,
				watermark_x_space: 120, // 水印x轴间隔
				watermark_y_space: 100, // 水印y轴间隔
			});
			if (file.fileType == 1) {
				let that = this;
				this.$nextTick(() => {
					if (
						$("iframe") &&
						["doc", "docx", "ppt", "pptx"].indexOf(file.type) > -1
					) {
						$("iframe").eq(0).css({
							"margin-top": "-80px",
							height: "calc(100% + 80px)",
						});
						this.$forceUpdate();
					}

					this.countStudyTime();
				});
			} else {
				let that = this;
				this.$nextTick(() => {
					let myVid = document.getElementById("video");
					if (myVid) {
						// myVid.addEventListener("waiting", () => {//加载中
						// });
						myVid.addEventListener("play", () => {
							//播放
							// this.startTime = Date.now();
							// debugger
							this.isRunning = true;
							this.GetTransferTime();

							// if ((this.isRunning = true)) {
							this.insertVideoStudy();
							// }
							this.countStudyTime();
						});
						myVid.addEventListener("pause", () => {
							//暂停
							if (this.studyVis == true) {
								this.isRunning = false;
								clearInterval(this.intervalTime);
								clearInterval(this.intervalId);
								clearInterval(this.timer);
								// this.insertVideoStudy("stop");
							}
							// else {
							// 	this.countStudyTime();
							// }
						});
					}
				});
			}
			// clearInterval(this.timer);
			// this.countStudyTime();
			this.timeFlag = true;
			this.GetTransferTime();
			this.checkIfLearningIsComplete();
			this.numberOfTimesToBrowseCoursewareFiles();
		},

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值