Fix video preview error

pull/59/head
guqing 2019-11-18 17:15:56 +08:00
parent 7e73bb3805
commit e25a401935
3 changed files with 565 additions and 559 deletions

1028
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -24,10 +24,10 @@
"vue-clipboard2": "^0.3.0", "vue-clipboard2": "^0.3.0",
"vue-codemirror-lite": "^1.0.4", "vue-codemirror-lite": "^1.0.4",
"vue-count-to": "^1.0.13", "vue-count-to": "^1.0.13",
"vue-dplayer": "0.0.10",
"vue-filepond": "^5.1.3", "vue-filepond": "^5.1.3",
"vue-ls": "^3.2.1", "vue-ls": "^3.2.1",
"vue-router": "^3.1.3", "vue-router": "^3.1.3",
"vue-video-player": "^5.0.2",
"vuejs-logger": "^1.5.3", "vuejs-logger": "^1.5.3",
"vuex": "^3.1.1" "vuex": "^3.1.1"
}, },
@ -127,4 +127,4 @@
"last 2 versions", "last 2 versions",
"not ie <= 10" "not ie <= 10"
] ]
} }

View File

@ -26,15 +26,14 @@
style="width: 100%;" style="width: 100%;"
> >
</a> </a>
<video-player <d-player
class="video-player-box" ref="player"
:options="videoOptions"
v-show="videoPreviewVisible" v-show="videoPreviewVisible"
ref="videoPlayer" class="video-player-box"
:options="playerOptions"
:playsinline="true"
style="width: 100%;" style="width: 100%;"
> >
</video-player> </d-player>
</div> </div>
</a-skeleton> </a-skeleton>
</a-col> </a-col>
@ -162,16 +161,16 @@
<script> <script>
import { mixin, mixinDevice } from '@/utils/mixin.js' import { mixin, mixinDevice } from '@/utils/mixin.js'
import { videoPlayer } from 'vue-video-player'
import 'video.js/dist/video-js.css'
import attachmentApi from '@/api/attachment' import attachmentApi from '@/api/attachment'
import photoApi from '@/api/photo' import photoApi from '@/api/photo'
import VueDPlayer from 'vue-dplayer'
import 'vue-dplayer/dist/vue-dplayer.css'
export default { export default {
name: 'AttachmentDetailDrawer', name: 'AttachmentDetailDrawer',
mixins: [mixin, mixinDevice], mixins: [mixin, mixinDevice],
components: { components: {
videoPlayer 'd-player': VueDPlayer
}, },
data() { data() {
return { return {
@ -181,24 +180,13 @@ export default {
photoPreviewVisible: false, photoPreviewVisible: false,
videoPreviewVisible: false, videoPreviewVisible: false,
nonsupportPreviewVisible: false, nonsupportPreviewVisible: false,
playerOptions: { player: {},
// videojs options videoOptions: {
muted: true, lang: 'zh-cn',
language: 'zh-CN', video: {
aspectRatio: '16:9', url: '',
fluid: true, type: 'auto'
controls: true, }
loop: false,
playbackRates: [0.7, 1.0, 1.5, 2.0],
sources: [
{
type: 'video/mp4',
src: 'https://cdn.theguardian.tv/webM/2015/07/20/150716YesMen_synd_768k_vp8.webm'
}
],
poster: '/static/images/author.jpg',
width: document.documentElement.clientWidth,
notSupportedMessage: '此视频暂无法播放,请稍后再试'
} }
} }
}, },
@ -225,10 +213,8 @@ export default {
created() { created() {
this.loadSkeleton() this.loadSkeleton()
}, },
computed: { mounted() {
player() { this.player = this.$refs.player
return this.$refs.videoPlayer.player
}
}, },
watch: { watch: {
visible: function(newValue, oldValue) { visible: function(newValue, oldValue) {
@ -320,39 +306,29 @@ export default {
var prefix = mediaType.split('/')[0] var prefix = mediaType.split('/')[0]
if (prefix === 'video' || prefix === 'flv') { if (prefix === 'video' || prefix === 'flv') {
this.videoPreviewVisible = true //
this.photoPreviewVisible = false this.handlePreviewVisible(false, true, false)
this.nonsupportPreviewVisible = false
//
var lastIndex = attachment.path.lastIndexOf('?')
var path = attachment.path.substring(0, lastIndex)
// //
this.$set(this.playerOptions.sources, 0, { this.$set(this.videoOptions.video, 'url', path)
type: mediaType, this.$log.debug('video url', path)
src: attachment.path
})
console.log(this.playerOptions.sources)
} else if (prefix === 'image') { } else if (prefix === 'image') {
this.photoPreviewVisible = true this.handlePreviewVisible(true, false, false)
this.videoPreviewVisible = false
this.nonsupportPreviewVisible = false
} else { } else {
this.nonsupportPreviewVisible = true this.handlePreviewVisible(false, false, true)
this.videoPreviewVisible = false
this.photoPreviewVisible = false
} }
} }
},
handlePreviewVisible(photo, video, nonsupport) {
// 使vue,
this.$set(this, 'photoPreviewVisible', photo)
this.$set(this, 'videoPreviewVisible', video)
this.$set(this, 'nonsupportPreviewVisible', nonsupport)
} }
// handleDownLoadPhoto(attachment) {
// var path = attachment.path
// var index = path.lastIndexOf('/')
// var filename = path.substr(index+1, path.length)
// // chrome/firefox
// var aTag = document.createElement('a')
// aTag.download = filename
// aTag.href = path//URL.createObjectURL(blob)
// aTag.target = '_blank'
// aTag.click()
// URL.revokeObjectURL(aTag.href)
// }
} }
} }
</script> </script>