// 利用element-ui的上传组件,读取视频文件
export function readMediaFile(file) {
return new Promise((resolve, reject) => {
const reader = new FileReader()
reader.readAsArrayBuffer(file.raw)
reader.onloadend = (e) => {
const buffer = e.target.result
const videoBlob = new Blob([new Uint8Array(buffer)], { type: 'video/mp4' })
const url = window.URL.createObjectURL(videoBlob)// 此处url内容形如 blob:http://localhost:9528/9018e430-d6f4-4c8a-95a7-2ea0f255a906
const realUrl = url.slice(5)//截取并保留http开头的内容
resolve(realUrl)
}
reader.onerror = (e) => {
reject(e)
}
})
}
……
computed: {
player() {
return this.$refs.videoPlayer.player
},
sources() {
return [{
type: 'video/mp4',
src: this.$store.getters[functionNames.configEventConfigMoudule + functionNames.videoUrl]
}]
}
},
watch: {
sources: {
deep: true,
handler(newVal) {
this.playerOptions.sources = newVal
}
}
},
现在的问题:
url带 blob:
url不带blob: