收藏
回答

video组件播放m3u8时会自动请求ts和key文件 如何给这两种文件设置请求头?

视频链接:http://xhcl.ebring.com.cn/gateway/filemanage/zimifile/96565cef-6ac4-4459-95dc-16fa365fa76b?type=4

实例代码 :

		<video @error="videoError" v-if="filePath" id="myVideo" :src="filePath"></video>
data() {
			return {
				filePath:"",
			
			}
		},
onLoad(){
const fs = wx.getFileSystemManager();
			//随机定义路径名称
			var times = new Date().getTime();
			// var filePath = wx.env.USER_DATA_PATH + '/' + times + '.png';
			var filePath = wx.env.USER_DATA_PATH + '/videoM3U8.m3u8';
			//将base64图片写入
			var that = this;
			// uni.downloadFile({
			uni.request({
				url:"http://xhcl.ebring.com.cn/gateway/filemanage/zimifile/96565cef-6ac4-4459-95dc-16fa365fa76b?type=4",
				header:{
					'NONCE':'5200062451082838014110',
					'TIMESTAMP':'2023-06-01 16:24:00',
					'SIGNATURE':'RQPBkTUha/wi0yUKYm1nGjpAWxXOXr7coDmP0ZvdqYA4IDDDeG0AWVOwZLsHQ1ui0s7WQKWm3nxNdrWRS6jnrirhO1L91gzszvKd1hSDJxm6dAqKepZizamAvijtNo6pd2KnidebDNzn99K2LB3rXM5SNC+FpaV8LIps3JmcSqE=',
					'Token':'m3u8token999999'
				},
				complete:(e) => {
					var data = e.data
					data = data.replace(/96565cef-6ac4-4459-95dc-16fa365fa76b/ig,'http://xhcl.ebring.com.cn/gateway/filemanage/zimifile/96565cef-6ac4-4459-95dc-16fa365fa76b')
					data = data.replace(".key",'.key?o=5200062451082838014110&t=1672561440000')
					console.log(data)
					fs.writeFile({
						filePath: filePath,
						data: data,
						encoding: 'utf-8',
						complete(res) {
							console.log(res)
						},
						success: () => {
							this.filePath = filePath
							
						}
					})
					console.log(e)
				}
			}),
methods:{
videoError(e){
				console.log(e)
			},
}
}

回答关注问题邀请回答
收藏

1 个回答

  • Programmer.chen
    Programmer.chen
    2023-06-09

    官方再装死,大概率不支持这种模式。

    2023-06-09
    有用
    回复
登录 后发表内容