123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249 |
- <template>
- <view>
- <uni-popup ref="popupRef" :animation="false" :is-mask-click="false"
- mask-background-color="rgba(255, 255, 255, 0.6);" class="ezy-popup-width-all">
- <view class="ezy-dajx-page">
- <view class="icon-title-navBar-box">
- <view @click="handleBack" class="nav-bar-icon"></view>
- <view class="nav-bar-title">单元测试</view>
- </view>
- <view class="shiti-frame-box">
- <view class="dajx-content-box">
- <!-- 思路分析 -->
- <view class="slfx-title"></view>
- <!-- <view class="slfx-content"> {{data.answer}}</view> -->
- <rich-text class="slfx-content" :nodes="data.answer"></rich-text>
- <!-- 视频讲解 -->
- <view class="spjj-title"></view>
- <view class="ezy-video-box">
- <!-- 这里放视频 ↓ -->
- <view class="ezy-video" ref="videoContent" id="wgy-player-test" :playAuth="playAuth"
- :change:playAuth="renderScript.receiveMsg" :videoId="videoId"
- :change:videoId="renderScript.videoIdFun" :hideFlag="hideFlag"
- :change:hideFlag="renderScript.hideFlagFun" :seekTime="seekTime"
- :change:seekTime="renderScript.seekTimeFun">
- </view>
- </view>
- </view>
- </view>
- </view>
- </uni-popup>
- </view>
- </template>
- <script>
- import {
- onLoad,
- onReady
- } from '@dcloudio/uni-app';
- import {
- getVideoAuth,
- } from "@/api/shipin.js"
- export default {
- data() {
- return {
- pageData: null, //上个页面获取的视频参数(视频id)
- playAuth: "", //播放凭证
- progressMarkers: [],
- videoId: "", //阿里云视频id
- seekTime: '',
- hideFlag: 'show',
- data: {},
- }
- },
- onHide() {
- console.log('onHideonHideonHideonHide');
- this.hideFlag = 'hide'
- },
- onUnload() {
- console.log('onUnloadonUnloadonUnloadonUnloadonUnload');
- this.hideFlag = 'hide'
- },
- methods: {
- showPopup(item) {
- this.data = item;
- this.videoId = item.jiangjie
- //this.videoId = 'b997f16cb9cb474cb93526cff77d8801'
- // this.progressMarkers = item.progressMarkers
- this.getLive(); //获取播放凭证
- this.$refs.popupRef.open()
- },
- handleBack(item) {
- this.$refs.popupRef.close()
- },
- getLive() {
- let req = {
- videoId: this.videoId
- }
- getVideoAuth(req).then(res => {
- this.playAuth = res.data
- })
- },
- markersClick(data) {
- this.seekTime = ""
- this.$nextTick(() => {
- this.seekTime = data.offset
- });
- },
- },
- created() {
- // console.log("getLive")
- // this.getLive(); //获取播放凭证
- },
- }
- </script>
- <script module="renderScript" lang="renderjs">
- export default {
- mounted() {
- console.log("renderScript1")
- // 在适合的生命周期,通过script和link标签引入播放器sdk、css
- },
- data() {
- return {
- player: null,
- playAuth: '',
- videoId: '',
- progressMarkers: [],
- seekTime: '',
- isFirst: -1,
- }
- },
- methods: {
- receiveMsg(newValue, oldValue, ownerInstance, instance) {
- if (newValue) {
- this.playAuth = newValue
- this.loadWebPlayerSDK()
- }
- },
- videoIdFun(newValue, oldValue, ownerInstance, instance) {
- if (newValue) {
- this.videoId = newValue
- }
- },
- hideFlagFun(newValue, oldValue, ownerInstance, instance) {
- if (this.player) {
- this.player.pause()
- }
- },
- progressMarkersMsg(newValue, oldValue, ownerInstance, instance) {
- if (newValue) {
- this.progressMarkers = newValue
- }
- },
- seekTimeFun(newValue, oldValue, ownerInstance, instance) {
- if (newValue) {
- console.log(newValue, 'newValuenewValuenewValuenewValuenewValue')
- console.log(this.player.getStatus(), 'newValuenewValuenewValuenewValuenewValue')
- this.player.play()
- this.player.seek(newValue)
- // this.player.seek(newValue)
- }
- },
- playAli() {
- if (this.isFirst == 0) {
- this.isFirst = -1
- return;
- }
- this.player = null;
- //配置播放器
- var player = new Aliplayer({
- id: "wgy-player-test",
- "vid": this.videoId,
- "playauth": this.playAuth,
- extraInfo: { poster: 'noposter' },
- // "playConfig": {
- // "EncryptType": 'AliyunVoDEncryption'
- // },
- "skinLayout": [{
- "name": "bigPlayButton",
- "align": "blabs",
- "x": 30,
- "y": 80
- },
- {
- "name": "controlBar",
- "align": "blabs",
- "x": 0,
- "y": 0,
- "children": [{
- "name": "progress",
- "align": "blabs",
- "x": 0,
- "y": 44
- },
- {
- "name": "playButton",
- "align": "tl",
- "x": 15,
- "y": 12
- },
- {
- "name": "fullScreenButton",
- "align": "tr",
- "x": 10,
- "y": 12
- },
- {
- "name": "timeDisplay",
- "align": "tr",
- "x": 10,
- "y": 5
- }
- ]
- }
- ],
- "qualitySort": "asc",
- "format": "mp4",
- "mediaType": "video",
- "encryptType": 1,
- "progressMarkers": this.progressMarkers,
- "width": '100%',
- "height": '500px',
- "autoplay": false,
- "isLive": false,
- "rePlay": false,
- "playsinline": true,
- "preload": false,
- "controlBarVisibility": "hover",
- "useH5Prism": true
- }, function(player) {});
- this.player = player;
- player.one('canplay', function() {
- console.log('canplay', this.player.tag);
- player.tag.play();
- });
- this.isFirst ++;
- },
- loadWebPlayerSDK() {
- return new Promise((resolve, reject) => {
- const s_tag = document.createElement('script'); // 引入播放器js
- s_tag.type = 'text/javascript';
- s_tag.src = 'https://g.alicdn.com/de/prismplayer/2.9.6/aliplayer-min.js';
- s_tag.charset = 'utf-8';
- s_tag.onload = () => {
- this.playAli()
- resolve();
- }
- document.body.appendChild(s_tag);
- const l_tag = document.createElement('link'); // 引入播放器css
- l_tag.rel = 'stylesheet';
- l_tag.href =
- 'https://g.alicdn.com/de/prismplayer/2.9.6/skins/default/aliplayer-min.css';
- document.body.appendChild(l_tag);
- });
- },
- }
- }
- </script>
|