亚洲国产成人久久99精品|四虎久久久久精品无码播放|国产乱偷精品视频a人人澡|欧美日韩精品二区在线|亚洲а∨天堂在线播放2018

網(wǎng)站知識(shí)您當(dāng)前的位置:首頁(yè) > 新聞資訊 > 網(wǎng)站知識(shí) >

關(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行:
  1. <template name="bdParseVideo"
  2.   <!--增加video標(biāo)簽支持,并循環(huán)添加--> 
  3.   <view class="{{item.classStr}} bdParse-{{item.tag}}" style="{{item.styleStr}}"
  4.     <video class="{{item.classStr}} bdParse-{{item.tag}}-video" src="{{item.attr.src}}"></video> 
  5.   </view> 
  6. </template> 
改成:
  1. <template name="bdParseVideo"
  2.   <!--增加video標(biāo)簽支持,并循環(huán)添加--> 
  3.   <view class="{{item.classStr}} bdParse-{{item.tag}}" style="{{item.styleStr}}"
  4.     <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> 
  5.   </view> 
  6. </template> 
(2)針對(duì)dedecms用戶以及其它video的poster屬性不顯示全網(wǎng)址的修復(fù)辦法
在小程序的內(nèi)容之前使用正則替換,補(bǔ)全poster地址:
dede版百度小程序demo修復(fù):show.js的113行加入以下代碼:
  1. content.body = content.body.replace(/poster=\"(.*)\"/gi, 'poster=\"'+ app.globalData.host+'$1\"');  

二、微信小程序wxParse修復(fù)方法
(1)打開(kāi)wxParse/wxParse.wxml找到video標(biāo)簽解析處大致第13行:
  1. <template name="wxParseVideo"
  2.   <!--增加video標(biāo)簽支持,并循環(huán)添加--> 
  3.   <view class="{{item.classStr}} wxParse-{{item.tag}}" style="{{item.styleStr}}"
  4.     <video class="{{item.classStr}} wxParse-{{item.tag}}-video" src="{{item.attr.src}}"></video> 
  5.   </view> 
  6. </template> 
改成:
  1. <template name="wxParseVideo"
  2.   <!--增加video標(biāo)簽支持,并循環(huán)添加--> 
  3.   <view class="{{item.classStr}} wxParse-{{item.tag}}" style="{{item.styleStr}}"
  4.     <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> 
  5.   </view> 
  6. </template> 
(2)同理需要對(duì)文章中的poster不是全網(wǎng)址的視頻封面圖片補(bǔ)全網(wǎng)址
dede版微信小程序demo修復(fù):show.js的105行加入以下代碼:
  1. 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)鍵詞:
相關(guān)文章
  • 添加微信好友

  • 微信小程序太陽(yáng)碼

  • 在線客服
  • 技術(shù)支持
  • 售后服務(wù)
  • 微信號(hào):15137100750