如何在Vue-plyr中播放本地视频?
How to play a local video in Vue-plyr?
我可以 vue-plyr
像这样处理 YouTube 视频:
<template>
<section id="vision" class="vision">
<vue-plyr>
<div data-plyr-provider="youtube" data-plyr-embed-id="bTqVqk7FSmY"></div>
</vue-plyr>
</section>
</template>
但是当我尝试使用 doc 中描述的本地视频时:
<template>
<section id="vision" class="vision">
<vue-plyr :options="options">
<video
controls
crossorigin
playsinline
>
<source
size="1080"
src="../../videos/cgi_neutral.mp4"
type="video/mp4"
/>
</video>
</vue-plyr>
</section>
</template>
我得到一个错误:
Uncaught Error: Module parse failed: Unexpected character ' ' (1:0)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
(Source code omitted for this binary file)
at Object../resources/videos/cgi_neutral.mp4 (app.js:92053)
at __webpack_require__ (app.js:92132)
at Module../node_modules/babel-loader/lib/index.js??clonedRuleSet-5.use[0]!./node_modules/vue-loader/dist/templateLoader.js??ruleSet[1].rules[2]!./node_modules/vue-loader/dist/index.js??ruleSet[0].use[0]!./resources/vue/sections/vision.vue?vue&type=template&id=0c8fcfd8&scoped=true (app.js:39037)
at __webpack_require__ (app.js:92132)
at Module../resources/vue/sections/vision.vue?vue&type=template&id=0c8fcfd8&scoped=true (app.js:87992)
at __webpack_require__ (app.js:92132)
at Module../resources/vue/sections/vision.vue (app.js:87291)
at __webpack_require__ (app.js:92132)
at Module../node_modules/babel-loader/lib/index.js??clonedRuleSet-5.use[0]!./node_modules/vue-loader/dist/index.js??ruleSet[0].use[0]!./resources/vue/index.vue?vue&type=script&setup=true&lang=js (app.js:36141)
at __webpack_require__ (app.js:92132)
./resources/videos/cgi_neutral.mp4 @ app.js:92053
__webpack_require__ @ app.js:92132
./node_modules/babel-loader/lib/index.js??clonedRuleSet-5.use[0]!./node_modules/vue-loader/dist/templateLoader.js??ruleSet[1].rules[2]!./node_modules/vue-loader/dist/index.js??ruleSet[0].use[0]!./resources/vue/sections/vision.vue?vue&type=template&id=0c8fcfd8&scoped=true @ app.js:39037
__webpack_require__ @ app.js:92132
./resources/vue/sections/vision.vue?vue&type=template&id=0c8fcfd8&scoped=true @ app.js:87992
__webpack_require__ @ app.js:92132
./resources/vue/sections/vision.vue @ app.js:87291
__webpack_require__ @ app.js:92132
./node_modules/babel-loader/lib/index.js??clonedRuleSet-5.use[0]!./node_modules/vue-loader/dist/index.js??ruleSet[0].use[0]!./resources/vue/index.vue?vue&type=script&setup=true&lang=js @ app.js:36141
__webpack_require__ @ app.js:92132
./resources/vue/index.vue?vue&type=script&setup=true&lang=js @ app.js:87384
__webpack_require__ @ app.js:92132
./resources/vue/index.vue @ app.js:86765
__webpack_require__ @ app.js:92132
./resources/js/router.js @ app.js:39210
__webpack_require__ @ app.js:92132
./resources/js/app.js @ app.js:39103
__webpack_require__ @ app.js:92132
(anonymous) @ app.js:92297
__webpack_require__.O @ app.js:92169
(anonymous) @ app.js:92299
(anonymous) @ app.js:92301
This git issue 说要安装 scss-loader
但我已经安装了它:
"sass-loader": "^12.2.0"
我做错了什么?
你能把 mp4 文件放在 public 文件夹里吗?并且可以通过浏览器使用 url 访问它
localhost:8000/videos/cgi_neutral.mp4
,
然后嵌入到组件中:
<source
size="1080"
src="/videos/cgi_neutral.mp4"
type="video/mp4"
/>
比用 webpack + file-loader 使用 loader 更好
我可以 vue-plyr
像这样处理 YouTube 视频:
<template>
<section id="vision" class="vision">
<vue-plyr>
<div data-plyr-provider="youtube" data-plyr-embed-id="bTqVqk7FSmY"></div>
</vue-plyr>
</section>
</template>
但是当我尝试使用 doc 中描述的本地视频时:
<template>
<section id="vision" class="vision">
<vue-plyr :options="options">
<video
controls
crossorigin
playsinline
>
<source
size="1080"
src="../../videos/cgi_neutral.mp4"
type="video/mp4"
/>
</video>
</vue-plyr>
</section>
</template>
我得到一个错误:
Uncaught Error: Module parse failed: Unexpected character ' ' (1:0)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
(Source code omitted for this binary file)
at Object../resources/videos/cgi_neutral.mp4 (app.js:92053)
at __webpack_require__ (app.js:92132)
at Module../node_modules/babel-loader/lib/index.js??clonedRuleSet-5.use[0]!./node_modules/vue-loader/dist/templateLoader.js??ruleSet[1].rules[2]!./node_modules/vue-loader/dist/index.js??ruleSet[0].use[0]!./resources/vue/sections/vision.vue?vue&type=template&id=0c8fcfd8&scoped=true (app.js:39037)
at __webpack_require__ (app.js:92132)
at Module../resources/vue/sections/vision.vue?vue&type=template&id=0c8fcfd8&scoped=true (app.js:87992)
at __webpack_require__ (app.js:92132)
at Module../resources/vue/sections/vision.vue (app.js:87291)
at __webpack_require__ (app.js:92132)
at Module../node_modules/babel-loader/lib/index.js??clonedRuleSet-5.use[0]!./node_modules/vue-loader/dist/index.js??ruleSet[0].use[0]!./resources/vue/index.vue?vue&type=script&setup=true&lang=js (app.js:36141)
at __webpack_require__ (app.js:92132)
./resources/videos/cgi_neutral.mp4 @ app.js:92053
__webpack_require__ @ app.js:92132
./node_modules/babel-loader/lib/index.js??clonedRuleSet-5.use[0]!./node_modules/vue-loader/dist/templateLoader.js??ruleSet[1].rules[2]!./node_modules/vue-loader/dist/index.js??ruleSet[0].use[0]!./resources/vue/sections/vision.vue?vue&type=template&id=0c8fcfd8&scoped=true @ app.js:39037
__webpack_require__ @ app.js:92132
./resources/vue/sections/vision.vue?vue&type=template&id=0c8fcfd8&scoped=true @ app.js:87992
__webpack_require__ @ app.js:92132
./resources/vue/sections/vision.vue @ app.js:87291
__webpack_require__ @ app.js:92132
./node_modules/babel-loader/lib/index.js??clonedRuleSet-5.use[0]!./node_modules/vue-loader/dist/index.js??ruleSet[0].use[0]!./resources/vue/index.vue?vue&type=script&setup=true&lang=js @ app.js:36141
__webpack_require__ @ app.js:92132
./resources/vue/index.vue?vue&type=script&setup=true&lang=js @ app.js:87384
__webpack_require__ @ app.js:92132
./resources/vue/index.vue @ app.js:86765
__webpack_require__ @ app.js:92132
./resources/js/router.js @ app.js:39210
__webpack_require__ @ app.js:92132
./resources/js/app.js @ app.js:39103
__webpack_require__ @ app.js:92132
(anonymous) @ app.js:92297
__webpack_require__.O @ app.js:92169
(anonymous) @ app.js:92299
(anonymous) @ app.js:92301
This git issue 说要安装 scss-loader
但我已经安装了它:
"sass-loader": "^12.2.0"
我做错了什么?
你能把 mp4 文件放在 public 文件夹里吗?并且可以通过浏览器使用 url 访问它
localhost:8000/videos/cgi_neutral.mp4
,
然后嵌入到组件中:
<source
size="1080"
src="/videos/cgi_neutral.mp4"
type="video/mp4"
/>
比用 webpack + file-loader 使用 loader 更好