{"id":32483,"date":"2024-11-25T15:00:38","date_gmt":"2024-11-25T07:00:38","guid":{"rendered":"https:\/\/fwq.ai\/blog\/32483\/"},"modified":"2024-11-25T15:00:38","modified_gmt":"2024-11-25T07:00:38","slug":"%e5%b0%8f%e7%a8%8b%e5%ba%8f%e5%a6%82%e4%bd%95%e5%ae%9e%e7%8e%b0%e8%a7%86%e9%a2%91%e6%88%96%e9%9f%b3%e9%a2%91%e8%87%aa%e5%ae%9a%e4%b9%89%e5%8f%af%e6%8b%96%e6%8b%bd%e8%bf%9b%e5%ba%a6%e6%9d%a1","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/32483\/","title":{"rendered":"\u5c0f\u7a0b\u5e8f\u5982\u4f55\u5b9e\u73b0\u89c6\u9891\u6216\u97f3\u9891\u81ea\u5b9a\u4e49\u53ef\u62d6\u62fd\u8fdb\u5ea6\u6761"},"content":{"rendered":"<p>\u672c\u7bc7\u6587\u7ae0\u7ed9\u5927\u5bb6\u5e26\u6765\u7684\u5185\u5bb9\u662f\u5173\u4e8e\u5c0f\u7a0b\u5e8f\u5982\u4f55\u5b9e\u73b0\u89c6\u9891\u6216\u97f3\u9891\u81ea\u5b9a\u4e49\u53ef\u62d6\u62fd\u8fdb\u5ea6\u6761\uff0c\u6709\u4e00\u5b9a\u7684\u53c2\u8003\u4ef7\u503c\uff0c\u6709\u9700\u8981\u7684\u670b\u53cb\u53ef\u4ee5\u53c2\u8003\u4e00\u4e0b\uff0c\u5e0c\u671b\u5bf9\u4f60\u6709\u6240\u5e2e\u52a9\u3002<\/p>\n<p>\u5c0f\u7a0b\u5e8f\u539f\u751f\u7ec4\u4ef6\u7684\u97f3\u9891\u64ad\u653e\u65f6\u5e76\u6ca1\u6709\u8fdb\u5ea6\u6761\u7684\u663e\u793a\uff0c\u800c\u6b64\u6b21\u9879\u76ee\u4e2d\uff0c\u9274\u4e8e\u539f\u751f\u7684\u89c6\u9891\u8fdb\u5ea6\u6761\u6837\u5f0f\u592a\u4e11\uff0c\u4ea7\u54c1\u8981\u6c42\u505a\u4e00\u4e2a\u53ef\u62d6\u62fd\u7684\u8fdb\u5ea6\u6761\u6ee1\u8db3\u9700\u6c42\u3002<br \/>\u89c6\u9891\u548c\u97f3\u9891\u63d0\u4f9b\u7684api\u5927\u81f4\u662f\u76f8\u4f3c\u7684\uff0c\u53ef\u4ee5\u6839\u636e\u4ee5\u4e0b\u4ee3\u7801\u4fee\u6539\u4e3a\u4e0e\u97f3\u9891\u76f8\u5173\u7684\u8fdb\u5ea6\u6761\u3002<\/p>\n<p>wxml\u7684\u7ed3\u6784\u5982\u4e0b:<\/p>\n<pre>&lt;video&gt;&lt;\/video&gt;&lt;view&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&lt;image&gt;&lt;\/image&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;view&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;slider&gt;&lt;\/slider&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&lt;\/view&gt;&nbsp;&nbsp;\n&lt;\/view&gt;<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>data\u4e2d\u521d\u59cb\u5316\u4e86sliderValue, updateState, playStates\u51e0\u4e2a\u53d8\u91cf\u3002<\/p>\n<pre>&nbsp;&nbsp;data:&nbsp;{\n&nbsp;&nbsp;&nbsp;&nbsp;sliderValue:&nbsp;0,&nbsp;\/\/\u63a7\u5236\u8fdb\u5ea6\u6761slider\u7684\u503c\uff0c\n&nbsp;&nbsp;&nbsp;&nbsp;updateState:&nbsp;false,&nbsp;\/\/\u9632\u6b62\u89c6\u9891\u64ad\u653e\u8fc7\u7a0b\u4e2d\u5bfc\u81f4\u7684\u62d6\u62fd\u5931\u6548\n&nbsp;&nbsp;&nbsp;&nbsp;playStates:&nbsp;true&nbsp;\/\/\u63a7\u5236\u64ad\u653e&nbsp;&amp;amp;&nbsp;\u6682\u505c\u6309\u94ae\u7684\u663e\u793a\n&nbsp;&nbsp;},\n&nbsp;&nbsp;onReady:&nbsp;function&nbsp;()&nbsp;{\n&nbsp;&nbsp;&nbsp;&nbsp;this.videoContext&nbsp;=&nbsp;wx.createVideoContext('myVideo');\n&nbsp;&nbsp;&nbsp;&nbsp;this.setData({\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;updateState:&nbsp;true\n&nbsp;&nbsp;&nbsp;&nbsp;})\n&nbsp;&nbsp;},<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>videoUpdate\u5728\u64ad\u653e\u8fdb\u5ea6\u53d8\u5316\u65f6\u89e6\u53d1\uff0c\u89e6\u53d1\u9891\u7387 250ms \u4e00\u6b21\u3002event.detail = {currentTime, duration}\uff0ccurrentTime\u8868\u793a\u5f53\u524d\u65f6\u95f4\uff0cduration\u8868\u793a\u603b\u65f6\u957f\uff0c\u90fd\u4ee5\u79d2\u4e3a\u5355\u4f4d\u3002<\/p>\n<pre>  videoUpdate(e) {\n    if (this.data.updateState) { \/\/\u5224\u65ad\u62d6\u62fd\u5b8c\u6210\u540e\u624d\u89e6\u53d1\u66f4\u65b0\uff0c\u907f\u514d\u62d6\u62fd\u5931\u6548\n      let sliderValue = e.detail.currentTime \/ e.detail.duration * 100;\n      this.setData({\n        sliderValue,\n        duration: e.detail.duration\n      })\n    }\n  },<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u8fdb\u5ea6\u6761\u53ef\u62d6\u62fd\u5e76\u6307\u5b9a\u89c6\u9891\u8df3\u8f6c\u5230\u76f8\u5e94\u7684\u4f4d\u7f6e<\/p>\n<pre>  sliderChanging(e) {\n    this.setData({\n      updateState: false \/\/\u62d6\u62fd\u8fc7\u7a0b\u4e2d\uff0c\u4e0d\u5141\u8bb8\u66f4\u65b0\u8fdb\u5ea6\u6761\n    })\n  },\n  sliderChange(e) {\n    if (this.data.duration) {\n      this.videoContext.seek(e.detail.value \/ 100 * this.data.duration); \/\/\u5b8c\u6210\u62d6\u52a8\u540e\uff0c\u8ba1\u7b97\u5bf9\u5e94\u65f6\u95f4\u5e76\u8df3\u8f6c\u5230\u6307\u5b9a\u4f4d\u7f6e\n      this.setData({\n        sliderValue: e.detail.value,\n        updateState: true \/\/\u5b8c\u6210\u62d6\u52a8\u540e\u5141\u8bb8\u66f4\u65b0\u6eda\u52a8\u6761\n      })\n    }\n  },<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u6682\u505c\/\u64ad\u653e\u89c6\u9891<\/p>\n<pre>  videoOpreation() {\n    this.data.playStates ? this.videoContext.pause() : this.videoContext.play();\n    this.setData({\n      playStates: !this.data.playStates\n    })\n  },<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u603b\u7ed3\uff1aslider\u7684\u6700\u5927\u503c\u4e3a100, step\u7684\u503c\u6700\u5c0f\u4e3a1,\u8fd9\u4f1a\u5bfc\u81f4\u89c6\u9891\u6216\u97f3\u9891\u64ad\u653e\u65f6\u95f4\u8fc7\u957f\u7684\u65f6\u5019,slider\u6ed1\u5757\u79fb\u52a8\u901f\u5ea6\u5f88\u6162,\u62d6\u62fd\u79fb\u52a8\u7684\u65f6\u95f4\u95f4\u9694\u8f83\u5927,\u7528\u6237\u4f53\u9a8c\u5dee\u3002<\/p>\n<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u5c0f\u7a0b\u5e8f\u5982\u4f55\u5b9e\u73b0\u89c6\u9891\u6216\u97f3\u9891\u81ea\u5b9a\u4e49\u53ef\u62d6\u62fd\u8fdb\u5ea6\u6761\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u672c\u7bc7\u6587\u7ae0\u7ed9\u5927\u5bb6\u5e26\u6765\u7684\u5185\u5bb9\u662f\u5173\u4e8e\u5c0f\u7a0b\u5e8f\u5982\u4f55\u5b9e\u73b0\u89c6\u9891\u6216\u97f3\u9891\u81ea\u5b9a\u4e49\u53ef\u62d6\u62fd\u8fdb\u5ea6\u6761\uff0c\u6709\u4e00\u5b9a\u7684\u53c2\u8003\u4ef7\u503c\uff0c\u6709\u9700\u8981\u7684\u670b\u53cb\u53ef\u4ee5\u53c2\u8003\u4e00\u4e0b\uff0c\u5e0c\u671b\u5bf9\u4f60\u6709\u6240\u5e2e\u52a9\u3002 \u5c0f\u7a0b\u5e8f\u539f\u751f\u7ec4\u4ef6\u7684\u97f3\u9891\u64ad\u653e\u65f6\u5e76\u6ca1\u6709\u8fdb\u5ea6\u6761\u7684\u663e\u793a\uff0c\u800c\u6b64\u6b21\u9879\u76ee\u4e2d\uff0c\u9274\u4e8e\u539f\u751f\u7684\u89c6\u9891\u8fdb\u5ea6\u6761\u6837\u5f0f\u592a\u4e11\uff0c\u4ea7\u54c1\u8981\u6c42\u505a\u4e00\u4e2a\u53ef\u62d6\u62fd\u7684\u8fdb\u5ea6\u6761\u6ee1\u8db3\u9700\u6c42\u3002\u89c6\u9891\u548c\u97f3\u9891\u63d0\u4f9b\u7684api\u5927\u81f4\u662f\u76f8\u4f3c\u7684\uff0c\u53ef\u4ee5\u6839\u636e\u4ee5\u4e0b\u4ee3\u7801\u4fee\u6539\u4e3a\u4e0e\u97f3\u9891\u76f8\u5173\u7684\u8fdb\u5ea6\u6761\u3002 wxml\u7684\u7ed3\u6784\u5982\u4e0b: &lt;video&gt;&lt;\/video&gt;&lt;view&gt; &nbsp;&nbsp;&nbsp;&nbsp;&lt;image&gt;&lt;\/image&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;view&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;slider&gt;&lt;\/slider&gt; &nbsp;&nbsp;&nbsp;&nbsp;&lt;\/view&gt;&nbsp;&nbsp; &lt;\/view&gt; \u767b\u5f55\u540e\u590d\u5236 data\u4e2d\u521d\u59cb\u5316\u4e86sliderValue, updateState, playStates\u51e0\u4e2a\u53d8\u91cf\u3002 &nbsp;&nbsp;data:&nbsp;{ &nbsp;&nbsp;&nbsp;&nbsp;sliderValue:&nbsp;0,&nbsp;\/\/\u63a7\u5236\u8fdb\u5ea6\u6761slider\u7684\u503c\uff0c &nbsp;&nbsp;&nbsp;&nbsp;updateState:&nbsp;false,&nbsp;\/\/\u9632\u6b62\u89c6\u9891\u64ad\u653e\u8fc7\u7a0b\u4e2d\u5bfc\u81f4\u7684\u62d6\u62fd\u5931\u6548 &nbsp;&nbsp;&nbsp;&nbsp;playStates:&nbsp;true&nbsp;\/\/\u63a7\u5236\u64ad\u653e&nbsp;&amp;amp;&nbsp;\u6682\u505c\u6309\u94ae\u7684\u663e\u793a &nbsp;&nbsp;}, &nbsp;&nbsp;onReady:&nbsp;function&nbsp;()&nbsp;{ &nbsp;&nbsp;&nbsp;&nbsp;this.videoContext&nbsp;=&nbsp;wx.createVideoContext(&#8216;myVideo&#8217;); &nbsp;&nbsp;&nbsp;&nbsp;this.setData({ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;updateState:&nbsp;true &nbsp;&nbsp;&nbsp;&nbsp;}) &nbsp;&nbsp;}, \u767b\u5f55\u540e\u590d\u5236 videoUpdate\u5728\u64ad\u653e\u8fdb\u5ea6\u53d8\u5316\u65f6\u89e6\u53d1\uff0c\u89e6\u53d1\u9891\u7387 250ms \u4e00\u6b21\u3002event.detail = {currentTime, duration}\uff0ccurrentTime\u8868\u793a\u5f53\u524d\u65f6\u95f4\uff0cduration\u8868\u793a\u603b\u65f6\u957f\uff0c\u90fd\u4ee5\u79d2\u4e3a\u5355\u4f4d\u3002 videoUpdate(e) { if (this.data.updateState) { \/\/\u5224\u65ad\u62d6\u62fd\u5b8c\u6210\u540e\u624d\u89e6\u53d1\u66f4\u65b0\uff0c\u907f\u514d\u62d6\u62fd\u5931\u6548 let sliderValue = e.detail.currentTime \/ e.detail.duration * 100; this.setData({ sliderValue, duration: e.detail.duration }) } }, \u767b\u5f55\u540e\u590d\u5236 \u8fdb\u5ea6\u6761\u53ef\u62d6\u62fd\u5e76\u6307\u5b9a\u89c6\u9891\u8df3\u8f6c\u5230\u76f8\u5e94\u7684\u4f4d\u7f6e sliderChanging(e) [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[19],"tags":[],"class_list":["post-32483","post","type-post","status-publish","format-standard","hentry","category-19"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/32483","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=32483"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/32483\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=32483"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=32483"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=32483"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}