{"id":318,"date":"2021-11-04T16:14:30","date_gmt":"2021-11-04T08:14:30","guid":{"rendered":"http:\/\/gjweb.top\/?p=318"},"modified":"2021-11-04T16:14:31","modified_gmt":"2021-11-04T08:14:31","slug":"h5%e7%ab%afvideo%e6%a0%87%e7%ad%be%e8%bf%9e%e6%8e%a5%e7%9b%b4%e6%92%ad%e6%b5%81%e8%90%a4%e7%9f%b3","status":"publish","type":"post","link":"https:\/\/gjweb.top\/?p=318","title":{"rendered":"H5\u7aefVideo\u6807\u7b7e\u8fde\u63a5\u76f4\u64ad\u6d41(\u8424\u77f3)"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">\u539f\u56e0:<\/h2>\n\n\n\n<p>\u56e0\u4e3auniapp\u5bf9video\u7ec4\u4ef6\u505a\u4e86\u4e8c\u6b21\u5c01\u88c5,\u6587\u6863\u4e2d\u83b7\u53d6\u5143\u7d20ID,\u4f1a\u5b9a\u4f4d\u5230uniapp\u6700\u5916\u5c42\u7684video\u76d2\u5b50.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u89e3\u51b3\u65b9\u6cd5:<\/h2>\n\n\n\n<p>\u624b\u52a8\u521b\u5efavideo\u5143\u7d20\uff0c\u5e76\u7ed9\u5176\u5143\u7d20\u6dfb\u52a0\u81ea\u5b9a\u4e49\u7684\u5c5e\u6027\uff0c<strong>\uff08\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0cuniapp\u4e2d\u662f\u4e0d\u63d0\u5021\u76f4\u63a5\u64cd\u4f5cDOM\uff0c\u6240\u4ee5\u9700\u8981\u9002\u914d\u517c\u5bb9\u8bed\u6cd5\uff09<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\u7528\u539f\u751f\u65b9\u6cd5\u5bf9\u63a5\u76f4\u64ad\u6d41<\/h2>\n\n\n\n<p>\u8fd9\u91cc\u7684\u76f4\u64ad\u6d41\u683c\u5f0f\u4e3am3u8<\/p>\n\n\n\n<p>\u793a\u4f8b<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;template&gt;<br>    &lt;view ref=\"videoContainer\"&gt;&lt;\/view&gt;<br>&lt;\/template&gt;<br>&lt;script&gt;<br> &nbsp; &nbsp;methods:{<br> &nbsp; &nbsp; &nbsp; &nbsp;createVideo(){<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \/\/ ifdef H5<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; let video = document.createElement('video');<br>            video.id=\"video\";<br>            video.controls=true;<br>            video.width=\"300\";<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; var source = document.createElement('source');<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.src = \"\";<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; video.appendChild(source)<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; this.$refs.videoContainer.$el.appendChild(video);<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;\/\/ #endif<br> &nbsp; &nbsp; &nbsp;  }<br> &nbsp;  }<br>&lt;\/script&gt;<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\u5728Uniapp\u4e2d\u5f15\u5165 video.js<\/h2>\n\n\n\n<p>\u5728index.html\u6587\u4ef6\u4e2d\u5f15\u5165<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;link href=\"https:\/\/unpkg.com\/video.js\/dist\/video-js.min.css\" rel=\"stylesheet\"&gt; <br>&lt;script src=\"https:\/\/unpkg.com\/video.js\/dist\/video.min.js\"&gt;&lt;\/script&gt;<br>\/\/ uniapp \u586b\u5751 \u5982\u679c\u9875\u9762\u4e00\u76f4\u51fa\u73b0\"\u53d6\u6d88\"\u5b57\u6837<br>&lt;link rel=\"stylesheet\" href=\"&lt;%= htmlWebpackPlugin.options.baseUrl %&gt;static\/index.css\" \/&gt;<\/code><\/pre>\n\n\n\n<p>\u5728\u4f7f\u7528video.js\u7ec4\u4ef6\u4e2d\u5f15\u5165<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;template&gt;<br>    &lt;view&gt;<br> &nbsp; &nbsp; &nbsp; &nbsp;&lt;view class=\"video-js\" ref=\"videoContainer\"&gt;&lt;\/view&gt;<br> &nbsp; &nbsp;&lt;\/view&gt;<br>&lt;\/template&gt;<br>&lt;script&gt;<br>    export default{<br> &nbsp; &nbsp; &nbsp; &nbsp;data(){<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;return{}<br> &nbsp; &nbsp; &nbsp;  },<br> &nbsp; &nbsp; &nbsp; &nbsp;methods:{<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;createVideo(){<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;var video = document.createElement(\"video\");<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;video.id = \"video\";<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;video.width = \"300\";<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;video.controls = true;<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;var source = document.createElement(\"source\")<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;source.src = \"\u76f4\u64ad\u6d41\u5730\u5740\"\uff1b<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;video.appendChild(source);<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;this.$refs.videoContainer.$el.appendChild(video);<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;video.js(video)<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  }<br> &nbsp; &nbsp; &nbsp;  }<br> &nbsp;  }<br>&lt;\/script&gt;<\/code><\/pre>\n\n\n\n<p><strong>\u5982\u679c\u5728\u5f15\u5165video.js\u6ca1\u6709\u51fa\u73b0\u6837\u5f0f\u95ee\u9898\u7684\u8bdd,\u68c0\u67e5\u7684\u5143\u7d20\u662f\u5426\u7ed1\u5b9a\u4e86class=&#8221;video-js&#8221;<\/strong><\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u539f\u56e0: \u56e0\u4e3auniapp\u5bf9video\u7ec4\u4ef6\u505a\u4e86\u4e8c\u6b21\u5c01\u88c5,\u6587\u6863\u4e2d\u83b7\u53d6\u5143\u7d20ID,\u4f1a\u5b9a\u4f4d\u5230uniapp\u6700\u5916\u5c42\u7684vide [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[33],"tags":[],"class_list":["post-318","post","type-post","status-publish","format-standard","hentry","category-uniapp"],"_links":{"self":[{"href":"https:\/\/gjweb.top\/index.php?rest_route=\/wp\/v2\/posts\/318","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gjweb.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/gjweb.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/gjweb.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/gjweb.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=318"}],"version-history":[{"count":0,"href":"https:\/\/gjweb.top\/index.php?rest_route=\/wp\/v2\/posts\/318\/revisions"}],"wp:attachment":[{"href":"https:\/\/gjweb.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=318"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gjweb.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=318"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gjweb.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=318"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}