play.vue 26 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025
  1. <template>
  2. <div class="pc-player-container">
  3. <div class="pc-player-wrapper">
  4. <div class="pc-player-left">
  5. <div class="video-section">
  6. <div class="video-title">{{ media.name || tpl.name }}</div>
  7. <div class="video-player-wrap">
  8. <video-player v-if="options.sources.length" id="myVideo1" ref="videoPlayer" :playsinline="true" @pause="onPlayerPause($event)"
  9. @timeupdate="onPlayerTimeupdate($event)" @play="onPlayerStart($event)" @ready="playerReadied"
  10. @ended="onPlayerEnded($event)" @error="onPlayerError($event)"
  11. :globalOptions="{controls:true}" :options="options">
  12. </video-player>
  13. </div>
  14. <div class="dialog-footer pt30">
  15. <el-row class="media-footer">
  16. <el-col :span="6" class="media-time">
  17. <span>{{curTimes|useTime}}</span>
  18. <strong>/</strong>
  19. <span>{{media.duration|useTime}}</span>
  20. </el-col>
  21. <el-col :span="12" class="media-center">
  22. <span class="volume-control">
  23. <span class="vol-icon" @click="toggleMute">音量</span>
  24. <el-slider class="volume-slider" :value="volume" :min="0" :max="1" :step="0.05"
  25. @input="setVolume"></el-slider>
  26. </span>
  27. <span class="pip-control">
  28. <span class="pip-icon" :class="{ 'is-active': isPiP }" @click="togglePiP">{{ isPiP ? '退出画中画' : '画中画' }}</span>
  29. </span>
  30. </el-col>
  31. <el-col :span="6" class="media-select">
  32. <div style="margin-top:0px;float: right;">
  33. <el-select placeholder="流畅" :value="mediaType" class="media-el-select" @change="changeMedia">
  34. <el-option label="流畅" value="ld"></el-option>
  35. <el-option label="标清" value="hls"></el-option>
  36. </el-select>
  37. </div>
  38. </el-col>
  39. </el-row>
  40. </div>
  41. </div>
  42. </div>
  43. <div class="panel-toggle" @click="showPanel = !showPanel">
  44. <i :class="showPanel ? 'el-icon-d-arrow-right' : 'el-icon-d-arrow-left'"></i>
  45. </div>
  46. <div class="pc-player-right" v-show="showPanel">
  47. <div class="playlist-header">
  48. <div class="playlist-title">
  49. <i class="el-icon-video-list"></i>
  50. 课程列表
  51. </div>
  52. <div class="playlist-header-row">
  53. <div class="playlist-count">
  54. 共 {{ list.length }} 个视频
  55. <span class="finished-count" v-if="finishedCount">,已完成 {{ finishedCount }} 个</span>
  56. </div>
  57. <el-switch
  58. v-model="hideFinished"
  59. active-text="隐藏已完成"
  60. inactive-text=""
  61. size="small"
  62. ></el-switch>
  63. </div>
  64. </div>
  65. <div class="playlist-body">
  66. <div class="playlist-item" v-for="(item, index) in filteredList" :key="item.id" :class="{
  67. 'is-active': media.id === item.id,
  68. 'is-finished': item.isFinish == 1,
  69. 'is-current-playing': media.id === item.id && onPlay
  70. }" @click="loadMedia(item)">
  71. <div class="item-index" :class="{ 'active-index': media.id === item.id }">
  72. <span v-if="item.isFinish == 1" class="finish-badge">
  73. <i class="el-icon-check"></i>
  74. </span>
  75. <span v-else>{{ index + 1 }}</span>
  76. </div>
  77. <div class="item-info">
  78. <div class="item-name">{{ item.name }}</div>
  79. <div class="item-meta">
  80. <span class="item-duration">学时:{{ item.xs / 10 }}</span>
  81. <span class="item-progress">{{item|percent}}%</span>
  82. </div>
  83. </div>
  84. <div class="item-action">
  85. <el-button v-if="media.id === item.id && onPlay" type="warning" size="mini" icon="el-icon-video-pause"
  86. circle @click.stop="doPause"></el-button>
  87. <el-button v-else-if="media.id === item.id" type="primary" size="mini" icon="el-icon-video-play" circle
  88. @click.stop="doPlay"></el-button>
  89. <el-button v-else type="text" size="mini" icon="el-icon-video-play"
  90. @click.stop="loadMedia(item)">播放</el-button>
  91. </div>
  92. </div>
  93. <div class="playlist-empty" v-if="list.length === 0">
  94. <i class="el-icon-document"></i>
  95. <p>暂无视频</p>
  96. </div>
  97. </div>
  98. </div>
  99. </div>
  100. </div>
  101. </template>
  102. <script>
  103. import { mapActions } from "vuex";
  104. import {
  105. getPercent
  106. } from '@/utils/index.js'
  107. import {
  108. videoPlayer
  109. } from 'vue-video-player';
  110. import 'video.js/dist/video-js.css'
  111. import {
  112. httpServer
  113. } from "@/components/httpServer/httpServer.js";
  114. export default {
  115. data() {
  116. return {
  117. courseId: 0,
  118. mediaId: 0,
  119. media: {},
  120. options: {
  121. controls: true,
  122. autoplay: true,
  123. muted: true,
  124. loop: false,
  125. preload: "auto",
  126. language: 'zh-CN',
  127. aspectRatio: '16:9',
  128. fluid: true,
  129. sources: [],
  130. poster: '',
  131. notSupportedMessage: '无法播放媒体源',
  132. playtimes: '',
  133. controlBar: {
  134. timeDivider: true,
  135. durationDisplay: true,
  136. remainingTimeDisplay: false,
  137. fullscreenToggle: true
  138. }
  139. },
  140. curTimes: 0,
  141. tpl: {},
  142. info: {isBan:0},
  143. list: [],
  144. timer: false,
  145. tickNum: 0,
  146. prevTime: 0,
  147. isReady: false,
  148. onPlay: false,
  149. volume: 0.5,
  150. isMuted: false,
  151. mediaType: 'hls',
  152. hasSeeked: false,
  153. hideFinished: false,
  154. showPanel: true,
  155. hiddenStartTime: 0,
  156. hiddenBasePosition: 0,
  157. isPiP: false
  158. };
  159. },
  160. components: {
  161. videoPlayer
  162. },
  163. computed: {
  164. finishedCount() {
  165. return this.list.filter(i => i.isFinish == 1).length;
  166. },
  167. filteredList() {
  168. if (this.hideFinished) {
  169. return this.list.filter(i => i.isFinish != 1)
  170. }
  171. return this.list
  172. },
  173. playPercent() {
  174. if (!this.media.duration) return 0;
  175. if(this.media.isFinish ==1) return 100;
  176. return +((this.curTimes / this.media.duration) * 100).toFixed(1);
  177. }
  178. },
  179. filters: {
  180. percent(item){
  181. if( item.isFinish == 1) return 100;
  182. return (item.position * 100 / item.duration).toFixed(1)
  183. },
  184. useTime(val) {
  185. val = parseInt(val) || 0
  186. let timestr = ""
  187. let hour = parseInt(val / 3600);
  188. let min = parseInt(val / 60 % 60);
  189. let sec = parseInt(val % 60);
  190. if (hour < 10) hour = "0" + hour;
  191. if (min < 10) min = "0" + min;
  192. if (sec < 10) sec = "0" + sec;
  193. return hour + ":" + min + ":" + sec
  194. }
  195. },
  196. methods: {
  197. getCourse() {
  198. let param = {
  199. courseId: this.courseId
  200. }
  201. httpServer("course.getCourse", param).then(res => {
  202. if (res.code == 200) {
  203. let {
  204. info,
  205. extra,
  206. list,
  207. tpl
  208. } = res.data;
  209. this.info = Object.assign(info, extra || {});
  210. this.tpl = tpl || {};
  211. this.list = list.map((item) => {
  212. item.percent = getPercent(item) || 0;
  213. return item;
  214. })
  215. let target = null
  216. if (this.mediaId) {
  217. target = this.list.find(i => i.id == this.mediaId || i.mediaId == this.mediaId)
  218. }
  219. if (!target) {
  220. target = this.list.find(i => i.isFinish != 1)
  221. }
  222. if (!target && this.list.length) {
  223. target = this.list[0]
  224. }
  225. if (target) {
  226. this.loadMedia(target)
  227. }
  228. }
  229. })
  230. },
  231. handleVisibilityChange() {
  232. if (document.hidden) {
  233. let myPlayer = this.$refs.videoPlayer && this.$refs.videoPlayer.player
  234. if (myPlayer && myPlayer.currentTime) {
  235. this.hiddenStartTime = Date.now()
  236. this.hiddenBasePosition = myPlayer.currentTime() || 0
  237. }
  238. } else if (this.hiddenStartTime) {
  239. let elapsed = (Date.now() - this.hiddenStartTime) / 1000
  240. let estimated = this.hiddenBasePosition + elapsed
  241. this.hiddenStartTime = 0
  242. if (estimated < (this.media.duration || Infinity)) {
  243. this.setposition(estimated)
  244. }
  245. }
  246. },
  247. onEnterPiP() {
  248. this.isPiP = true
  249. },
  250. onLeavePiP() {
  251. this.isPiP = false
  252. },
  253. async enterPiP() {
  254. if (!document.pictureInPictureEnabled || this.isPiP) return
  255. let player = this.$refs.videoPlayer && this.$refs.videoPlayer.player
  256. if (!player) return
  257. let video = player.tech_ && player.tech_.el_
  258. if (video && video.requestPictureInPicture) {
  259. try { await video.requestPictureInPicture() } catch (e) {}
  260. }
  261. },
  262. async exitPiP() {
  263. if (document.pictureInPictureElement) {
  264. try { await document.exitPictureInPicture() } catch (e) {}
  265. }
  266. },
  267. togglePiP() {
  268. if (document.pictureInPictureElement) {
  269. this.exitPiP()
  270. } else {
  271. this.enterPiP()
  272. }
  273. },
  274. setVolume(val) {
  275. this.volume = val
  276. this.isMuted = val === 0
  277. let player = this.$refs.videoPlayer && this.$refs.videoPlayer.player
  278. if (player && player.volume) {
  279. player.volume(val)
  280. player.muted(this.isMuted)
  281. }
  282. },
  283. changeMedia(val) {
  284. if (!val || !this.mediaUrl) return;
  285. let mediaUrl = this.mediaUrl;
  286. if (val == 'ld') {
  287. mediaUrl = mediaUrl.replace('/hls/', '/ld/');
  288. } else {
  289. mediaUrl = mediaUrl.replace('/ld/', '/hls/');
  290. }
  291. this.mediaType = val;
  292. this.onPlay = false
  293. this.curTimes = 0
  294. this.hasSeeked = false
  295. this.options = {
  296. ...this.options,
  297. sources: [{
  298. src: mediaUrl + (mediaUrl.includes('?') ? '&' : '?') + '_t=' + Date.now(),
  299. type: "application/x-mpegURL"
  300. }],
  301. html5: {
  302. hls: {
  303. xhrSetup(xhr) {
  304. xhr.setRequestHeader('Cache-Control', 'no-cache, no-store, must-revalidate')
  305. xhr.setRequestHeader('Pragma', 'no-cache')
  306. }
  307. }
  308. },
  309. playtimes: this.media.position || 0,
  310. autoplay: true
  311. }
  312. },
  313. startTick() {
  314. console.log("startTick")
  315. let tick = this.tryTick;
  316. if (this.timer) clearInterval(this.timer);
  317. this.timer = setInterval(tick, 5 * 1000);
  318. },
  319. stopTick() {
  320. console.log("stopTick")
  321. if (this.timer) clearInterval(this.timer);
  322. },
  323. tryTick() {
  324. let that = this;
  325. try {
  326. that.tick()
  327. } catch (err) {
  328. that.reportErr("play", '' + err.message)
  329. }
  330. },
  331. playerReadied(player) {
  332. this.isReady = true
  333. let video = player.tech_ && player.tech_.el_
  334. if (video) {
  335. video.addEventListener('enterpictureinpicture', this.onEnterPiP)
  336. video.addEventListener('leavepictureinpicture', this.onLeavePiP)
  337. }
  338. if (this.media.position > 5 && this.media.position < this.media.duration - 10) {
  339. setTimeout(() => {
  340. this.setposition(this.media.position)
  341. }, 300)
  342. }
  343. },
  344. onPlayerError(event) {
  345. console.error("Video error:", event)
  346. },
  347. onPlayerTimeupdate(player) {
  348. let curTimes = player.currentTime();
  349. this.curTimes = curTimes || 0
  350. if (this.media.isFinish) {
  351. return;
  352. }
  353. },
  354. safePlay(player) {
  355. if (!player) return
  356. try {
  357. const p = player.play()
  358. if (p && p.catch) p.catch(() => {})
  359. } catch (e) {}
  360. },
  361. setposition(position) {
  362. if( position < 10) return;
  363. if (position > this.media.duration) position = this.media.duration;
  364. let player = this.$refs.videoPlayer && this.$refs.videoPlayer.player;
  365. if (!player || !player.currentTime) return;
  366. player.currentTime(position);
  367. this.safePlay(player)
  368. if (this.media.isFinish) return;
  369. if (this.media.position >= this.media.duration - 10 && !this.media.isFinish) {
  370. this.tick(true)
  371. }
  372. },
  373. onPlayerPause(event) {
  374. this.reportErr("play", 'pause');
  375. // this.stopTick()
  376. this.onPlay = false
  377. },
  378. onPlayerEnded(event) {
  379. this.reportErr("play", 'end');
  380. this.tick(true)
  381. this.playNext()
  382. },
  383. playNext() {
  384. if(this.tpl.courseCode.indexOf('-')==-1){
  385. return;
  386. }
  387. let currentIndex = this.list.findIndex(i => i.id === this.media.id)
  388. let nextItem = null
  389. for (let i = currentIndex + 1; i < this.list.length; i++) {
  390. if (this.list[i].isFinish != 1) {
  391. nextItem = this.list[i]
  392. break
  393. }
  394. }
  395. if (!nextItem) {
  396. for (let i = 0; i < currentIndex; i++) {
  397. if (this.list[i].isFinish != 1) {
  398. nextItem = this.list[i]
  399. break
  400. }
  401. }
  402. }
  403. if (nextItem) {
  404. this.$message.success(`即将播放: ${nextItem.name}`)
  405. setTimeout(() => {
  406. this.loadMedia(nextItem)
  407. }, 1000)
  408. }
  409. },
  410. onClose() {
  411. this.reportErr("play", 'close')
  412. this.doPause()
  413. },
  414. doPause() {
  415. this.stopTick()
  416. this.onPlay = false
  417. let myPlayer = this.$refs.videoPlayer && this.$refs.videoPlayer.player
  418. if (myPlayer) myPlayer.pause()
  419. },
  420. doPlay() {
  421. this.onPlay = true
  422. this.startTick();
  423. if (!this.$refs.videoPlayer || !this.$refs.videoPlayer.player) return;
  424. this.safePlay(this.$refs.videoPlayer.player)
  425. this.tickNum = 0
  426. },
  427. onPlayerStart() {
  428. console.log("onPlayerStart")
  429. this.reportErr("play", 'start');
  430. },
  431. toggleMute() {
  432. this.isMuted = !this.isMuted
  433. let player = this.$refs.videoPlayer && this.$refs.videoPlayer.player
  434. if (player && player.volume) {
  435. player.muted(this.isMuted)
  436. }
  437. },
  438. reportErr(action, msg) {
  439. httpServer("course.report", { action, msg }, true)
  440. },
  441. getPlayerTime() {
  442. if (this.hiddenStartTime) {
  443. let elapsed = (Date.now() - this.hiddenStartTime) / 1000
  444. let estimated = this.hiddenBasePosition + elapsed
  445. let myPlayer = this.$refs.videoPlayer && this.$refs.videoPlayer.player
  446. if (myPlayer && myPlayer.currentTime) {
  447. let actual = myPlayer.currentTime()
  448. if (actual >= estimated - 0.5) {
  449. this.hiddenStartTime = 0
  450. return actual
  451. }
  452. }
  453. return Math.min(estimated, this.media.duration || 1/0)
  454. }
  455. let myPlayer = this.$refs.videoPlayer && this.$refs.videoPlayer.player
  456. if (myPlayer && myPlayer.currentTime) {
  457. return myPlayer.currentTime()
  458. }
  459. return 0
  460. },
  461. tick(force = false) {
  462. console.log("tick", this.tickNum)
  463. let media = this.media;
  464. this.tickNum++
  465. if (this.media.isFinish) {
  466. return;
  467. }
  468. let myPlayer = this.$refs.videoPlayer && this.$refs.videoPlayer.player;
  469. if (!myPlayer) return;
  470. let curTimes = parseInt(this.getPlayerTime());
  471. this.curTimes = curTimes || 0
  472. let isFinish = force ? 1 : 0
  473. if (curTimes >= media.duration) isFinish = 1;
  474. if (window.navigator.webdriver) {
  475. this.reportErr("play", 'webdriver');
  476. this.doPause()
  477. return
  478. }
  479. let param = {
  480. id: media.id,
  481. position: curTimes,
  482. isFinish
  483. };
  484. let that = this
  485. httpServer("course.tick", param, true).then(res => {
  486. if (res.code == 200) {
  487. let {
  488. skip,
  489. position,
  490. pause,
  491. msg,
  492. closed
  493. } = res.data
  494. if(closed){
  495. that.doPause();
  496. that.$message.errorMsg(msg, 10)
  497. return
  498. }
  499. if (pause) {
  500. that.doPause();
  501. that.$message.errorMsg(msg, 10)
  502. setTimeout(() => that.playNext(), 10*1000)
  503. return
  504. }
  505. if (!skip) {
  506. let diff = Math.abs(position - curTimes);
  507. if (diff > 3) {
  508. that.setposition(position)
  509. }
  510. }
  511. Object.assign(that.media, res.data)
  512. if( res.data.isFinish == 1){
  513. that.playNext()
  514. }
  515. }
  516. })
  517. },
  518. loadMedia(item) {
  519. this.media = item;
  520. this.stopTick()
  521. httpServer('course.GetMedia', {
  522. id: item.id
  523. }).then(res => {
  524. if (res.code != 200) return;
  525. let {
  526. mediaUrl,
  527. id,
  528. position,
  529. marks,
  530. duration
  531. } = res.data || {};
  532. if(position < 10) position = 0;
  533. this.mediaUrl = mediaUrl;
  534. this.media.position = position;
  535. this.media.duration = duration;
  536. this.media.id = id;
  537. this.curTimes = 0
  538. this.onPlay = false
  539. this.hasSeeked = false
  540. this.hiddenStartTime = 0
  541. this.options = {
  542. ...this.options,
  543. sources: [{
  544. src: mediaUrl,
  545. type: "application/x-mpegURL"
  546. }],
  547. html5: {
  548. hls: {
  549. overrideNative: true
  550. }
  551. },
  552. playtimes: this.media.position || 0,
  553. autoplay: true
  554. }
  555. this.startTick()
  556. });
  557. }
  558. },
  559. created() {
  560. document.addEventListener('visibilitychange', this.handleVisibilityChange)
  561. let { uid, token, courseId, mediaId } = this.$route.query
  562. this.courseId = +courseId || +this.$route.params.courseId
  563. this.mediaId = mediaId || this.$route.query.mediaId || 0
  564. if (uid) localStorage.uid = uid
  565. if (token) localStorage.token = token
  566. if (this.courseId) {
  567. this.getCourse()
  568. }
  569. },
  570. beforeDestroy() {
  571. document.removeEventListener('visibilitychange', this.handleVisibilityChange)
  572. this.exitPiP()
  573. this.stopTick()
  574. let player = this.$refs.videoPlayer && this.$refs.videoPlayer.player
  575. if (player) {
  576. let video = player.tech_ && player.tech_.el_
  577. if (video) {
  578. video.removeEventListener('enterpictureinpicture', this.onEnterPiP)
  579. video.removeEventListener('leavepictureinpicture', this.onLeavePiP)
  580. }
  581. }
  582. this.reportErr("play", 'destroy')
  583. }
  584. }
  585. </script>
  586. <style>
  587. @import url("./play.css");
  588. .pc-player-container {
  589. min-height: 100vh;
  590. background: #f0f2f5;
  591. padding: 20px;
  592. box-sizing: border-box;
  593. }
  594. .pc-player-wrapper {
  595. max-width: 1440px;
  596. margin: 0 auto;
  597. display: flex;
  598. gap: 20px;
  599. height: calc(100vh - 40px);
  600. }
  601. .pc-player-left {
  602. flex: 1;
  603. min-width: 0;
  604. display: flex;
  605. flex-direction: column;
  606. }
  607. .panel-toggle {
  608. flex-shrink: 0;
  609. width: 20px;
  610. display: flex;
  611. align-items: center;
  612. justify-content: center;
  613. cursor: pointer;
  614. color: #999;
  615. font-size: 14px;
  616. user-select: none;
  617. transition: color 0.2s;
  618. }
  619. .panel-toggle:hover {
  620. color: #409EFF;
  621. }
  622. .video-section {
  623. background: #fff;
  624. border-radius: 12px;
  625. box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
  626. overflow: hidden;
  627. }
  628. .video-title {
  629. padding: 16px 20px;
  630. font-size: 16px;
  631. font-weight: 600;
  632. color: #1a1a2e;
  633. border-bottom: 1px solid #f0f0f0;
  634. white-space: nowrap;
  635. overflow: hidden;
  636. text-overflow: ellipsis;
  637. }
  638. .video-player-wrap {
  639. width: 100%;
  640. background: #000;
  641. touch-action: none;
  642. }
  643. .video-player-wrap .video-js {
  644. width: 100%;
  645. }
  646. .video-info-bar {
  647. padding: 12px 20px;
  648. display: flex;
  649. align-items: center;
  650. gap: 16px;
  651. border-top: 1px solid #f0f0f0;
  652. }
  653. .video-time {
  654. font-size: 14px;
  655. color: #666;
  656. white-space: nowrap;
  657. font-variant-numeric: tabular-nums;
  658. }
  659. .time-current {
  660. color: #409EFF;
  661. font-weight: 600;
  662. }
  663. .time-sep {
  664. margin: 0 4px;
  665. color: #ccc;
  666. }
  667. .video-progress {
  668. flex: 1;
  669. min-width: 100px;
  670. }
  671. .video-status {
  672. flex-shrink: 0;
  673. }
  674. .pc-player-right {
  675. width: 380px;
  676. flex-shrink: 0;
  677. background: #fff;
  678. border-radius: 12px;
  679. box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
  680. display: flex;
  681. flex-direction: column;
  682. overflow: hidden;
  683. }
  684. .playlist-header {
  685. padding: 16px 20px 12px;
  686. border-bottom: 1px solid #f0f0f0;
  687. flex-shrink: 0;
  688. }
  689. .playlist-header-row {
  690. display: flex;
  691. align-items: center;
  692. justify-content: space-between;
  693. margin-top: 6px;
  694. }
  695. .playlist-title {
  696. font-size: 16px;
  697. font-weight: 600;
  698. color: #1a1a2e;
  699. margin-bottom: 4px;
  700. }
  701. .playlist-title i {
  702. margin-right: 6px;
  703. color: #409EFF;
  704. }
  705. .playlist-count {
  706. font-size: 12px;
  707. color: #999;
  708. }
  709. .finished-count {
  710. color: #67C23A;
  711. }
  712. .playlist-body {
  713. flex: 1;
  714. overflow-y: auto;
  715. padding: 8px 0;
  716. }
  717. .playlist-body::-webkit-scrollbar {
  718. width: 6px;
  719. }
  720. .playlist-body::-webkit-scrollbar-thumb {
  721. background: #ddd;
  722. border-radius: 3px;
  723. }
  724. .playlist-body::-webkit-scrollbar-track {
  725. background: transparent;
  726. }
  727. .playlist-item {
  728. display: flex;
  729. align-items: center;
  730. padding: 12px 20px;
  731. cursor: pointer;
  732. transition: all 0.2s ease;
  733. border-left: 3px solid transparent;
  734. gap: 12px;
  735. }
  736. .playlist-item:hover {
  737. background: #f5f7fa;
  738. }
  739. .playlist-item.is-active {
  740. background: #ecf5ff;
  741. border-left-color: #409EFF;
  742. }
  743. .playlist-item.is-finished {
  744. opacity: 0.65;
  745. }
  746. .playlist-item.is-current-playing {
  747. background: #ecf5ff;
  748. border-left-color: #409EFF;
  749. }
  750. .item-index {
  751. width: 28px;
  752. height: 28px;
  753. border-radius: 50%;
  754. background: #f0f2f5;
  755. display: flex;
  756. align-items: center;
  757. justify-content: center;
  758. font-size: 12px;
  759. font-weight: 600;
  760. color: #666;
  761. flex-shrink: 0;
  762. transition: all 0.2s;
  763. }
  764. .item-index.active-index {
  765. background: #409EFF;
  766. color: #fff;
  767. }
  768. .finish-badge {
  769. color: #67C23A;
  770. font-size: 14px;
  771. }
  772. .item-info {
  773. flex: 1;
  774. min-width: 0;
  775. }
  776. .item-name {
  777. font-size: 14px;
  778. color: #333;
  779. font-weight: 500;
  780. white-space: nowrap;
  781. overflow: hidden;
  782. text-overflow: ellipsis;
  783. margin-bottom: 2px;
  784. }
  785. .is-finished .item-name {
  786. color: #999;
  787. text-decoration: line-through;
  788. }
  789. .is-active .item-name {
  790. color: #409EFF;
  791. }
  792. .item-meta {
  793. display: flex;
  794. gap: 12px;
  795. font-size: 12px;
  796. color: #999;
  797. }
  798. .item-progress {
  799. color: #409EFF;
  800. }
  801. .is-finished .item-progress {
  802. color: #67C23A;
  803. }
  804. .item-action {
  805. flex-shrink: 0;
  806. }
  807. .playlist-empty {
  808. text-align: center;
  809. padding: 60px 20px;
  810. color: #ccc;
  811. }
  812. .playlist-empty i {
  813. font-size: 48px;
  814. display: block;
  815. margin-bottom: 12px;
  816. }
  817. .playlist-empty p {
  818. font-size: 14px;
  819. margin: 0;
  820. }
  821. .dialog-footer {
  822. padding: 0 16px;
  823. border-top: 1px solid #f0f0f0;
  824. background: #fafafa;
  825. }
  826. .dialog-footer.pt30 {
  827. padding: 8px 16px;
  828. }
  829. .media-footer {
  830. display: flex;
  831. align-items: center;
  832. line-height: 1;
  833. }
  834. .media-time {
  835. font-size: 14px;
  836. color: #666;
  837. white-space: nowrap;
  838. font-variant-numeric: tabular-nums;
  839. display: flex;
  840. align-items: center;
  841. gap: 4px;
  842. }
  843. .media-center {
  844. display: flex;
  845. align-items: center;
  846. justify-content: center;
  847. }
  848. .bicon {
  849. font-size: 22px !important;
  850. padding: 4px !important;
  851. }
  852. .volume-control {
  853. display: inline-flex;
  854. align-items: center;
  855. gap: 6px;
  856. }
  857. .vol-icon {
  858. font-size: 12px;
  859. font-weight: 600;
  860. cursor: pointer;
  861. color: #606266;
  862. user-select: none;
  863. line-height: 1;
  864. }
  865. .vol-icon:hover {
  866. color: #409EFF;
  867. }
  868. .volume-slider {
  869. width: 300px !important;
  870. }
  871. .volume-slider .el-slider__runway {
  872. height: 4px;
  873. }
  874. .volume-slider .el-slider__bar {
  875. height: 4px;
  876. }
  877. .volume-slider .el-slider__button {
  878. width: 12px;
  879. height: 12px;
  880. }
  881. .pip-control {
  882. display: inline-flex;
  883. align-items: center;
  884. margin-left: 12px;
  885. }
  886. .pip-icon {
  887. font-size: 12px;
  888. font-weight: 600;
  889. cursor: pointer;
  890. color: #606266;
  891. user-select: none;
  892. line-height: 1;
  893. padding: 4px 8px;
  894. border: 1px solid #dcdfe6;
  895. border-radius: 4px;
  896. transition: all 0.2s;
  897. }
  898. .pip-icon:hover {
  899. color: #409EFF;
  900. border-color: #c6e2ff;
  901. background: #ecf5ff;
  902. }
  903. .pip-icon.is-active {
  904. color: #409EFF;
  905. border-color: #409EFF;
  906. background: #ecf5ff;
  907. }
  908. .media-select {
  909. display: flex;
  910. align-items: center;
  911. justify-content: flex-end;
  912. }
  913. .media-el-select {
  914. width: 80px;
  915. }
  916. .media-el-select .el-input__inner {
  917. height: 28px;
  918. line-height: 28px;
  919. font-size: 12px;
  920. }
  921. @media (max-width: 900px) {
  922. .pc-player-wrapper {
  923. flex-direction: column;
  924. height: auto;
  925. }
  926. .pc-player-right {
  927. width: 100%;
  928. max-height: 400px;
  929. }
  930. .pc-player-container {
  931. padding: 0;
  932. min-height: auto;
  933. }
  934. .panel-toggle {
  935. display: none;
  936. }
  937. .video-section {
  938. border-radius: 0;
  939. }
  940. .video-title {
  941. padding: 10px 12px;
  942. font-size: 14px;
  943. }
  944. .dialog-footer.pt30 {
  945. padding: 6px 10px;
  946. }
  947. .media-footer {
  948. flex-wrap: wrap;
  949. gap: 6px;
  950. }
  951. .media-center {
  952. display: none;
  953. }
  954. .volume-slider {
  955. width: 100px !important;
  956. }
  957. .media-select {
  958. display: none;
  959. }
  960. .pc-player-right {
  961. display: none;
  962. }
  963. }
  964. </style>