{"id":185313,"date":"2023-09-08T17:16:22","date_gmt":"2023-09-08T09:16:22","guid":{"rendered":"http:\/\/www.idc.net\/help\/185313\/"},"modified":"2023-09-08T17:16:22","modified_gmt":"2023-09-08T09:16:22","slug":"%e5%90%8e%e6%b5%aa%e4%ba%91%e5%b0%8f%e7%a8%8b%e5%ba%8f%e6%95%99%e7%a8%8b%ef%bc%9a%e5%be%ae%e4%bf%a1%e5%b0%8f%e7%a8%8b%e5%ba%8fapi-%e8%a7%86%e9%a2%91%c2%b7videocontext","status":"publish","type":"post","link":"https:\/\/idc.net\/help\/185313\/","title":{"rendered":"\u540e\u6d6a\u4e91\u5c0f\u7a0b\u5e8f\u6559\u7a0b\uff1a\u5fae\u4fe1\u5c0f\u7a0b\u5e8fAPI \u89c6\u9891\u00b7VideoContext"},"content":{"rendered":"<h2><span style=\"font-family: inherit\">VideoContext<\/span><br \/><\/h2>\n<p>VideoContext \u5b9e\u4f8b\uff0c\u53ef\u901a\u8fc7&nbsp;wx.createVideoContext&nbsp;\u83b7\u53d6\u3002<\/p>\n<p>VideoContext&nbsp;\u901a\u8fc7&nbsp;id&nbsp;\u8ddf\u4e00\u4e2a&nbsp;video&nbsp;\u7ec4\u4ef6\u7ed1\u5b9a\uff0c\u64cd\u4f5c\u5bf9\u5e94\u7684&nbsp;video&nbsp;\u7ec4\u4ef6\u3002<\/p>\n<h2>\u65b9\u6cd5\uff1a<\/h2>\n<h2>VideoContext.exitFullScreen()<\/h2>\n<blockquote><p>\n  \u57fa\u7840\u5e93 1.4.0 \u5f00\u59cb\u652f\u6301\uff0c\u4f4e\u7248\u672c\u9700\u505a\u517c\u5bb9\u5904\u7406\u3002\n<\/p><\/blockquote>\n<p>\u9000\u51fa\u5168\u5c4f<\/p>\n<h2>VideoContext.exitPictureInPicture(Object object)<\/h2>\n<p>\u9000\u51fa\u5c0f\u7a97\uff0c\u8be5\u65b9\u6cd5\u53ef\u5728\u4efb\u610f\u9875\u9762\u8c03\u7528<\/p>\n<h2>\u53c2\u6570<\/h2>\n<h3>Object object<\/h3>\n<table>\n<thead>\n<tr>\n<th>\u5c5e\u6027<\/th>\n<th>\u7c7b\u578b<\/th>\n<th>\u9ed8\u8ba4\u503c<\/th>\n<th>\u5fc5\u586b<\/th>\n<th>\u8bf4\u660e<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>success<\/td>\n<td>function<\/td>\n<td><\/td>\n<td>\u5426<\/td>\n<td>\u63a5\u53e3\u8c03\u7528\u6210\u529f\u7684\u56de\u8c03\u51fd\u6570<\/td>\n<\/tr>\n<tr>\n<td>fail<\/td>\n<td>function<\/td>\n<td><\/td>\n<td>\u5426<\/td>\n<td>\u63a5\u53e3\u8c03\u7528\u5931\u8d25\u7684\u56de\u8c03\u51fd\u6570<\/td>\n<\/tr>\n<tr>\n<td>complete<\/td>\n<td>function<\/td>\n<td><\/td>\n<td>\u5426<\/td>\n<td>\u63a5\u53e3\u8c03\u7528\u7ed3\u675f\u7684\u56de\u8c03\u51fd\u6570\uff08\u8c03\u7528\u6210\u529f\u3001\u5931\u8d25\u90fd\u4f1a\u6267\u884c\uff09<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2>VideoContext.hideStatusBar()<\/h2>\n<blockquote><p>\n  \u57fa\u7840\u5e93 2.1.0 \u5f00\u59cb\u652f\u6301\uff0c\u4f4e\u7248\u672c\u9700\u505a\u517c\u5bb9\u5904\u7406\u3002\n<\/p><\/blockquote>\n<p>\u9690\u85cf\u72b6\u6001\u680f\uff0c\u4ec5\u5728iOS\u5168\u5c4f\u4e0b\u6709\u6548<\/p>\n<h2>VideoContext.pause()<\/h2>\n<p>\u6682\u505c\u89c6\u9891<\/p>\n<h2>VideoContext.play()<\/h2>\n<p>\u64ad\u653e\u89c6\u9891<\/p>\n<h2>VideoContext.playbackRate(number rate)<\/h2>\n<blockquote><p>\n  \u57fa\u7840\u5e93 1.4.0 \u5f00\u59cb\u652f\u6301\uff0c\u4f4e\u7248\u672c\u9700\u505a\u517c\u5bb9\u5904\u7406\u3002\n<\/p><\/blockquote>\n<p>\u8bbe\u7f6e\u500d\u901f\u64ad\u653e<\/p>\n<h2>\u53c2\u6570<\/h2>\n<h3>number rate<\/h3>\n<p>\u500d\u7387\uff0c\u652f\u6301 0.5\/0.8\/1.0\/1.25\/1.5\uff0c2.6.3 \u8d77\u652f\u6301 2.0 \u500d\u901f<\/p>\n<h2>VideoContext.requestFullScreen(Object object)<\/h2>\n<blockquote><p>\n  \u57fa\u7840\u5e93 1.4.0 \u5f00\u59cb\u652f\u6301\uff0c\u4f4e\u7248\u672c\u9700\u505a\u517c\u5bb9\u5904\u7406\u3002\n<\/p><\/blockquote>\n<p>\u8fdb\u5165\u5168\u5c4f\u3002\u82e5\u6709\u81ea\u5b9a\u4e49\u5185\u5bb9\u9700\u5728\u5168\u5c4f\u65f6\u5c55\u793a\uff0c\u9700\u5c06\u5185\u5bb9\u8282\u70b9\u653e\u7f6e\u5230 video \u8282\u70b9\u5185\u3002<\/p>\n<h2>\u53c2\u6570<\/h2>\n<h3>Object object<\/h3>\n<table>\n<thead>\n<tr>\n<th>\u5c5e\u6027<\/th>\n<th>\u7c7b\u578b<\/th>\n<th>\u9ed8\u8ba4\u503c<\/th>\n<th>\u5fc5\u586b<\/th>\n<th>\u8bf4\u660e<\/th>\n<th>\u6700\u4f4e\u7248\u672c<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>direction<\/td>\n<td>number<\/td>\n<td><\/td>\n<td>\u5426<\/td>\n<td>\u8bbe\u7f6e\u5168\u5c4f\u65f6\u89c6\u9891\u7684\u65b9\u5411\uff0c\u4e0d\u6307\u5b9a\u5219\u6839\u636e\u5bbd\u9ad8\u6bd4\u81ea\u52a8\u5224\u65ad\u3002<\/td>\n<td>1.7.0 <\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>object.direction \u7684\u5408\u6cd5\u503c<\/p>\n<table>\n<thead>\n<tr>\n<th>\u503c<\/th>\n<th>\u8bf4\u660e<\/th>\n<th>\u6700\u4f4e\u7248\u672c<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>0<\/td>\n<td>\u6b63\u5e38\u7ad6\u5411<\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td>90<\/td>\n<td>\u5c4f\u5e55\u9006\u65f6\u948890\u5ea6<\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td>-90<\/td>\n<td>\u5c4f\u5e55\u987a\u65f6\u948890\u5ea6<\/td>\n<td><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2>VideoContext.seek(number position)<\/h2>\n<p>\u8df3\u8f6c\u5230\u6307\u5b9a\u4f4d\u7f6e<\/p>\n<h2>\u53c2\u6570<\/h2>\n<h3>number position<\/h3>\n<p>\u8df3\u8f6c\u5230\u7684\u4f4d\u7f6e\uff0c\u5355\u4f4d s<\/p>\n<h2>VideoContext.sendDanmu(Object data)<\/h2>\n<p>\u53d1\u9001\u5f39\u5e55<\/p>\n<h2>\u53c2\u6570<\/h2>\n<h3>Object data<\/h3>\n<p>\u5f39\u5e55\u5185\u5bb9<\/p>\n<table>\n<thead>\n<tr>\n<th>\u5c5e\u6027<\/th>\n<th>\u7c7b\u578b<\/th>\n<th>\u9ed8\u8ba4\u503c<\/th>\n<th>\u5fc5\u586b<\/th>\n<th>\u8bf4\u660e<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>text<\/td>\n<td>string<\/td>\n<td><\/td>\n<td>\u662f<\/td>\n<td>\u5f39\u5e55\u6587\u5b57<\/td>\n<\/tr>\n<tr>\n<td>color<\/td>\n<td>string<\/td>\n<td><\/td>\n<td>\u5426<\/td>\n<td>\u5f39\u5e55\u989c\u8272<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2>VideoContext.showStatusBar()<\/h2>\n<blockquote><p>\n  \u57fa\u7840\u5e93 2.1.0 \u5f00\u59cb\u652f\u6301\uff0c\u4f4e\u7248\u672c\u9700\u505a\u517c\u5bb9\u5904\u7406\u3002\n<\/p><\/blockquote>\n<p>\u663e\u793a\u72b6\u6001\u680f\uff0c\u4ec5\u5728iOS\u5168\u5c4f\u4e0b\u6709\u6548<\/p>\n<h2>VideoContext.stop()<\/h2>\n<blockquote><p>\n  \u57fa\u7840\u5e93 1.7.0 \u5f00\u59cb\u652f\u6301\uff0c\u4f4e\u7248\u672c\u9700\u505a\u517c\u5bb9\u5904\u7406\u3002\n<\/p><\/blockquote>\n<p>\u505c\u6b62\u89c6\u9891<\/p>\n<h2>\u793a\u4f8b\u4ee3\u7801<\/h2>\n<p>\u5728\u5f00\u53d1\u8005\u5de5\u5177\u4e2d\u9884\u89c8\u6548\u679c <\/p>\n<pre><code>&lt;view class=\"section tc\"&gt;\n  &lt;video id=\"myVideo\" src=\"http:\/\/wxsnsdy.tc.qq.com\/105\/20210\/snsdyvideodownload?filekey=30280201010421301f0201690402534804102ca905ce620b1241b726bc41dcff44e00204012882540400&amp;bizid=1023&amp;hy=SH&amp;fileparam=302c020101042530230204136ffd93020457e3c4ff02024ef202031e8d7f02030f42400204045a320a0201000400\" rel=\"external nofollow\"  enable-danmu danmu-btn controls&gt;&lt;\/video&gt;\n  &lt;view class=\"btn-area\"&gt;\n    &lt;input bindblur=\"bindInputBlur\"\/&gt;\n    &lt;button bindtap=\"bindSendDanmu\"&gt;\u53d1\u9001\u5f39\u5e55&lt;\/button&gt;\n  &lt;\/view&gt;\n&lt;\/view&gt;\n<\/code><\/pre>\n<\/p>\n<pre><code>function getRandomColor () {\n  let rgb = []\n  for (let i = 0 ; i &lt; 3; ++i) {\n    let color = Math.floor(Math.random() * 256).toString(16)\n    color = color.length == 1 ? '0' + color : color\n    rgb.push(color)\n  }\n  return '#' + rgb.join('')\n}\n\nPage({\n  onReady (res) {\n    this.videoContext = wx.createVideoContext('myVideo')\n  },\n  inputValue: '',\n  bindInputBlur (e) {\n    this.inputValue = e.detail.value\n  },\n  bindSendDanmu () {\n    this.videoContext.sendDanmu({\n      text: this.inputValue,\n      color: getRandomColor()\n    })\n  }\n})<\/code><\/pre>\n<p> <\/p>\n","protected":false},"excerpt":{"rendered":"<p>VideoContext VideoContext \u5b9e\u4f8b\uff0c\u53ef\u901a\u8fc7&nbsp;wx.createVideoCon [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[182398],"tags":[],"class_list":["post-185313","post","type-post","status-publish","format-standard","hentry","category-mini-program"],"_links":{"self":[{"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/posts\/185313","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/comments?post=185313"}],"version-history":[{"count":0,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/posts\/185313\/revisions"}],"wp:attachment":[{"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/media?parent=185313"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/categories?post=185313"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/tags?post=185313"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}