爱吃的o(=•ェ•=)m 2021-12-04 14:56 采纳率: 0%
浏览 941
已结题

Video.js 报错 The media could not be loaded, because the format is not supported.

最近在做项目过程中,使用 Video.js 实现视频播放效果,根据 Video.js Vue版本官方文档提供的例子简单调试了一下,在Chrome 和 Firefox 上都出现错误
VIDEOJS: ERROR: (CODE:4 MEDIA_ERR_SRC_NOT_SUPPORTED) The media could not be loaded, either because the server or network failed or because the format is not supported. 检查了一下发现URL 的路径是没有问题的,想问一下如何解决这个问题?
问题图片:

img

img

// Video.vue部分代码
<template>
  <video-player :options="videoOptions"/>
</template>

<script>
import VideoPlayer from "../components/VideoPlayer.vue"
export default {
  components: {
    VideoPlayer,
  },
  data() {
    return {
      videoOptions: {
        autoplay: false,
    controls: true,
        width: "700px",
        height: "600px",
        preload: "auto",
        controlBar:{
          playToggle: true,
        },
        // html5: {
        //   nativeAudioTracks: false,
        //   nativeVideoTracks: false
        // },
    sources: [
      {
            type: "video/mp4",
        src: require("../assets/video/test2.mp4"),
      }
    ]
    }
  }
  },
</script>

// VideoPlayer 部分代码
<template>
  <div class="player">
    <video ref="videoPlayer" class="video-js"></video>
  </div>
</template>

<script>
import videojs from 'video.js';
export default {
   props: {
    options: {
      type: Object,
      default() {
        return {};
      }
    }
    },
  data() {
    return {
      player: null
    }
  },
  mounted() {
    this.player = videojs(this.$refs.videoPlayer, this.options, function onPlayerReady() {
      console.log('onPlayerReady', this);
    })
  },
  beforeDestroy() {
    if (this.player) {
      this.player.dispose()
    }
  }
}
</script>
  • 写回答

0条回答 默认 最新

    报告相同问题?

    问题事件

    • 系统已结题 12月12日
    • 创建了问题 12月4日

    悬赏问题

    • ¥15 C#中的编译平台的区别影响
    • ¥15 软件供应链安全是跟可靠性有关还是跟安全性有关?
    • ¥15 电脑蓝屏logfilessrtsrttrail问题
    • ¥20 关于wordpress建站遇到的问题!(语言-php)(相关搜索:云服务器)
    • ¥15 【求职】怎么找到一个周围人素质都很高不会欺负他人,并且未来月薪能够达到一万以上(技术岗)的工作?希望可以收到写有具体,可靠,已经实践过了的路径的回答?
    • ¥15 Java+vue部署版本反编译
    • ¥100 对反编译和ai熟悉的开发者。
    • ¥15 带序列特征的多输出预测模型
    • ¥15 Python 如何安装 distutils模块
    • ¥15 关于#网络#的问题:网络是从楼上引一根网线下来,接了2台傻瓜交换机,也更换了ip还是不行