我在尝试,XR-FRAME文档里的让照片动起来的功能:https://developers.weixin.qq.com/miniprogram/dev/framework/xr-frame/#_2DMarker-%E8%A7%86%E9%A2%91%EF%BC%8C%E8%AE%A9%E7%85%A7%E7%89%87%E5%8A%A8%E8%B5%B7%E6%9D%A5
当我把视频换成有声音的资源后,在IOS设备静音模式下不能正常播放声音,已经全局设置了wx.setInnerAudioOption({obeyMuteSwitch:false}),还是不行。
// app.ts
App<IAppOption>({
globalData: {},
onLaunch() {
// 展示本地存储能力
const logs = wx.getStorageSync('logs') || []
logs.unshift(Date.now())
wx.setStorageSync('logs', logs)
wx.setInnerAudioOption({
obeyMuteSwitch:false,
speakerOn:true,
success:function() {
console.log("suuuuuuuuu")
}
})
// 登录
wx.login({
success: res => {
console.log(res.code)
// 发送 res.code 到后台换取 openId, sessionKey, unionId
},
})
},
})
// xr逻辑组件的wxml
<xr-scene ar-system="modes:Marker" bind:ready="handleReady">
<xr-assets bind:loaded="handleAssetsLoaded">
<xr-asset-load
type="video-texture" asset-id="hikari" options="loop:true,abortAudio:false"
src="https://xx/v1.mp4"
/><!-- 这里的视频链接我换成有声音的 -->
<xr-asset-material asset-id="mat" effect="simple" uniforms="u_baseColorMap: video-hikari" />
</xr-assets>
<xr-node wx:if="{{loaded}}">
<xr-ar-tracker
mode="Marker" bind:ar-tracker-switch="handleTrackerSwitch"
src="https://xxx/miu.png"
>
<xr-mesh node-id="mesh-plane" geometry="plane" material="mat" />
</xr-ar-tracker>
</xr-node>
<xr-camera clear-color="0.4 0.8 0.6 1" background="ar" is-ar-camera />
</xr-scene>
// xr逻辑组件的ts
Component({
/**
* 组件的属性列表
*/
properties: {
},
/**
* 组件的初始数据
*/
data: {
avatarTextureId: 'white'
},
/**
* 组件的方法列表
*/
methods: {
handleAssetsProgress: function ({ detail }) {
console.log('assets progress', detail.value);
},
handleAssetsLoaded: function ({ detail }) {
this.setData({ loaded: true });
},
handleTrackerSwitch: function ({detail}) {
const active = detail.value;
const video = this.scene.assets.getAsset('video-texture', 'hikari');
active ? video.play() : video.stop();
},
handleReady: function ({ detail }) {
this.scene = detail.value;
this.scene.assets.loadAsset({
type: 'texture', assetId: 'avatar', src: 'https://xxx/miu.png'
}).then(() => this.setData({ avatarTextureId: 'avatar' }));
}
}
})
