V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
qq7588245
V2EX  ›  问与答

微信录音开发,求助

  •  1
     
  •   qq7588245 · 2017-07-05 09:13:00 +08:00 · 2235 次点击
    这是一个创建于 2480 天前的主题,其中的信息可能已经有所发展或是发生改变。

    问题出在安卓手机,使用了微信 jssdk 进行录音,点击按钮开始录音,第一次微信会提示是否允许录音,用户点击了是以后,就直接显示正在上传中,而且一直卡在这里,这个问题怎么解决,请开发过的大神帮帮忙哇!

    第 1 条附言  ·  2017-07-05 10:16:57 +08:00
    function wv_t(t) {
    t.preventDefault();
    if (!localStorage.rainAllowRecord || localStorage.rainAllowRecord !== 'true') {
    wx.startRecord({
    success: function() {
    localStorage.rainAllowRecord = 'true';
    wx.stopRecord();
    },
    cancel: function() {
    alert('用户拒绝授权录音');
    }
    });
    } else {
    wx.startRecord({
    success: function(a) {
    wVoiceinfo.vstart = new Date().getTime();
    }
    });
    $(".Voicepanel p").html("录音中");
    }
    }
    function wv_e(t) {
    if (t) {
    t.preventDefault();
    $(".Voicepanel p").html("按住说话");
    wx.stopRecord({
    success: function(a) {},
    complete: function(a) {
    wVoiceinfo.vend = new Date().getTime();
    console.log(wVoiceinfo);
    if ((wVoiceinfo.vend - wVoiceinfo.vstart) < 300) {
    wVoiceinfo.vend = 0;
    wVoiceinfo.vstart = 0;
    alert("录音小于 300ms,不录音");
    } else {
    wx.uploadVoice({
    localId: a.localId,
    isShowProgressTips: 1,
    success: function(res) {
    var serverId = res.serverId,
    var vd = {
    uname: tomsguser.uname,
    imghead: tomsguser.uimg,
    sceneid: scene.id,
    pageid: pageid,
    media_id: serverId
    };
    console.log("提交保存的数据", vd);
    $.getJSON('/', vd,
    function(data) {
    console.log("提交保存反馈的数据", data);
    //alert(JSON.stringify(data));
    if (data.success) {
    alert("发送成功");
    $(".showwxVoice").click();
    } else {
    alert("发送失败 " + serverId);
    wx.downloadVoice({
    serverId: serverId,
    isShowProgressTips: 1,
    // 默认为 1,显示进度提示
    success: function(res) {
    alert(res.localId);
    var localId = res.localId;
    wx.playVoice({
    localId: localId
    });
    }
    });
    $(".showwxVoice").click();
    }
    });
    }
    });
    }
    }
    });
    }
    }
    5 条回复    2017-07-05 14:16:25 +08:00
    qiayue
        1
    qiayue  
       2017-07-05 09:31:22 +08:00   ❤️ 1
    只有你调用了 wx.uploadVoice 才会上传,所以再看看你的代码逻辑吧
    qq7588245
        2
    qq7588245  
    OP
       2017-07-05 09:36:45 +08:00
    @qiayue 好的 谢谢
    ScotGu
        3
    ScotGu  
       2017-07-05 10:12:22 +08:00
    歪楼求问,看过别人发的一个微信截图。
    在微信会话页面的左侧,有个带头像的标签栏。
    可以在不切换到联系人页面看到哪个群或联系人有新消息,点击后可以直接进入到相关的会话中。
    qq7588245
        4
    qq7588245  
    OP
       2017-07-05 10:19:13 +08:00
    代码贴上了,请帮看看呢
    awanabe
        5
    awanabe  
       2017-07-05 14:16:25 +08:00
    代码要放在 wx.ready 里面
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5236 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 07:28 · PVG 15:28 · LAX 00:28 · JFK 03:28
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.