關(guān)于百度小程序微信小程序video標(biāo)簽不支持視頻封面autoplay等問(wèn)題修復(fù)方法
發(fā)布時(shí)間:2019-09-16 18:16:16 作者:admin 點(diǎn)擊:
在現(xiàn)有的百度小程序富文本組件bdParse,以及微信小程序富文本組件wxParse,對(duì)于video的標(biāo)簽解析僅僅只是有個(gè)video而已,其他的屬性幾乎都過(guò)濾掉了,所以就需要我們假設(shè)對(duì)于屬性(由于H5的video屬性和小程序的video屬性要求不一樣,以小程序?yàn)橹鳎?br />
一、百度小程序的bdParse修復(fù)方法
(1)打開(kāi)bdParse/bdParse.swan找到video標(biāo)簽解析處大致第10行:
在小程序的內(nèi)容之前使用正則替換,補(bǔ)全poster地址:
dede版百度小程序demo修復(fù):show.js的113行加入以下代碼:
二、微信小程序wxParse修復(fù)方法
(1)打開(kāi)wxParse/wxParse.wxml找到video標(biāo)簽解析處大致第13行:
dede版微信小程序demo修復(fù):show.js的105行加入以下代碼:
小程序的video和H5的video稍微有點(diǎn)不同
autoplay、controls、loop、muted等屬性需要寫成:autoplay=“{{true}}”,controls=“{{true}}”
這樣就可以實(shí)現(xiàn)了h5的video標(biāo)簽的常用屬性,如圖:
這樣就可以實(shí)現(xiàn)了h5的video標(biāo)簽的常用屬性,如圖:

一、百度小程序的bdParse修復(fù)方法
(1)打開(kāi)bdParse/bdParse.swan找到video標(biāo)簽解析處大致第10行:
改成:
- <template name="bdParseVideo">
- <!--增加video標(biāo)簽支持,并循環(huán)添加-->
- <view class="{{item.classStr}} bdParse-{{item.tag}}" style="{{item.styleStr}}">
- <video class="{{item.classStr}} bdParse-{{item.tag}}-video" src="{{item.attr.src}}"></video>
- </view>
- </template>
(2)針對(duì)dedecms用戶以及其它video的poster屬性不顯示全網(wǎng)址的修復(fù)辦法
- <template name="bdParseVideo">
- <!--增加video標(biāo)簽支持,并循環(huán)添加-->
- <view class="{{item.classStr}} bdParse-{{item.tag}}" style="{{item.styleStr}}">
- <video class="{{item.classStr}} bdParse-{{item.tag}}-video" poster="{{item.attr.poster}}" autoplay="{{item.attr.autoplay}}" controls="{{item.attr.controls}}" loop="{{item.attr.loop}}" muted="{{item.attr.muted}}" src="{{item.attr.src}}"></video>
- </view>
- </template>
在小程序的內(nèi)容之前使用正則替換,補(bǔ)全poster地址:
dede版百度小程序demo修復(fù):show.js的113行加入以下代碼:
- content.body = content.body.replace(/poster=\"(.*)\"/gi, 'poster=\"'+ app.globalData.host+'$1\"');
二、微信小程序wxParse修復(fù)方法
(1)打開(kāi)wxParse/wxParse.wxml找到video標(biāo)簽解析處大致第13行:
改成:
- <template name="wxParseVideo">
- <!--增加video標(biāo)簽支持,并循環(huán)添加-->
- <view class="{{item.classStr}} wxParse-{{item.tag}}" style="{{item.styleStr}}">
- <video class="{{item.classStr}} wxParse-{{item.tag}}-video" src="{{item.attr.src}}"></video>
- </view>
- </template>
(2)同理需要對(duì)文章中的poster不是全網(wǎng)址的視頻封面圖片補(bǔ)全網(wǎng)址
- <template name="wxParseVideo">
- <!--增加video標(biāo)簽支持,并循環(huán)添加-->
- <view class="{{item.classStr}} wxParse-{{item.tag}}" style="{{item.styleStr}}">
- <video class="{{item.classStr}} wxParse-{{item.tag}}-video" poster="{{item.attr.poster}}" autoplay="{{item.attr.autoplay}}" controls="{{item.attr.controls}}" loop="{{item.attr.loop}}" muted="{{item.attr.muted}}" src="{{item.attr.src}}"></video>
- </view>
- </template>
dede版微信小程序demo修復(fù):show.js的105行加入以下代碼:
【注意】
- content.body = content.body.replace(/poster=\"(.*)\"/gi, 'poster=\"' + app.globalData.host + '$1\"');
小程序的video和H5的video稍微有點(diǎn)不同
autoplay、controls、loop、muted等屬性需要寫成:autoplay=“{{true}}”,controls=“{{true}}”
這樣就可以實(shí)現(xiàn)了h5的video標(biāo)簽的常用屬性,如圖:
這樣就可以實(shí)現(xiàn)了h5的video標(biāo)簽的常用屬性,如圖:

網(wǎng)站關(guān)鍵詞:
評(píng)論排行
- ·易優(yōu)cms小程序插件(76)
- ·微信小程序百度小程序記...(10)
- ·關(guān)于百度小程序微信小程...(2)
- ·電子圖書(shū)館網(wǎng)站(1)
- ·dedecms小程序插件最新升級(jí)日志(1)
- ·怎么選擇注冊(cè)有利于SEO優(yōu)...(0)
- ·網(wǎng)站文章內(nèi)容更新有哪些原則(0)
- ·修復(fù)list接口當(dāng)傳參more...(0)
- ·網(wǎng)站被惡意鏡像怎么辦 ...(0)
- ·已經(jīng)上線的小程序如何自...(0)
- ·網(wǎng)站建設(shè)是一門技術(shù)活 ...(0)
- ·企業(yè)網(wǎng)站建設(shè)的具體流程...(0)
- ·建議:請(qǐng)不要在工作中發(fā)...(0)
- ·移動(dòng)端網(wǎng)站建設(shè)將何去何從?(0)
- ·論企業(yè)網(wǎng)站建設(shè)的行業(yè)現(xiàn)狀(0)
- ·phpcms小程序插件api接口...(0)
相關(guān)文章
相關(guān)欄目
閱讀排行
- 1小程序測(cè)試正常真機(jī)不顯示內(nèi)容問(wèn)題處理(request:fail ssl hand shake error)
- 2網(wǎng)站被惡意鏡像怎么辦 一段代碼輕松搞定(全面版)
- 3phpcms開(kāi)發(fā)小程序api插件1.2版本
- 4phpcms v9小程序demo內(nèi)容頁(yè)安卓有時(shí)候不顯示內(nèi)容bug修改
- 5虛擬主機(jī)屏蔽IP地址的方法
- 6阿里云備案詳細(xì)流程
- 7關(guān)于百度小程序微信小程序video標(biāo)簽不支持視頻封面autoplay等問(wèn)題修復(fù)方法
- 8phpcms v9手機(jī)訪問(wèn)電腦站一對(duì)一跳轉(zhuǎn)對(duì)應(yīng)手機(jī)站頁(yè)面插件
- 9FTP使用教程(以FlashFTP為例)
- 10網(wǎng)站安裝教程(phpcms v9程序)
更多+最新案例