mui
hbuilder连接夜神模拟器
mui相关
# 每个页面必须有
mui.plusReady(function() {
});
- 监听事件
document.getElementById(\'index\').addEventListener(\'tap\',function () {
// 开一个新页面
mui.openWindow({
url: \'index.html\',
id: \'index\',
style: {
top: \'0\',
bottom: \'50px\',
},
extras: {
},
createNew:false,
});
});
// 新页面接收extras参数
mui.plusReady(function() {
var data = plus.webview.currentWebview();
})
- mui.fire(webview, \'event\', {data:data})
document.getElementById(\'send_music\').addEventListener(\'tap\',function () {
var index = plus.webview.getWebviewById("HBuilder");
mui.fire(index,"send_music",{"to_usr":"toy123","music":window.audio_srv + data.src})
})
document.addEventListener("send_music", function(data) {
ws.send(JSON.stringify(data.detail));
})
- mui.back() = function(){};
Storage
相当于web端的cookie
- window.localStorage.setItem("key", data)
- window.localStorage.getItem(\'key\')
- window.localStorage.removeItem(\'key\')
加载子页面
- subpages
播放音频
# 创建player对象
player = plus.audio.createPlayer(window.audio_srv + data.src);
# 重头开始播放
player.play();
# 暂停播放
player.pause()
# 继续播放
player.resume()
# 停止播放
player.stop()