收藏
回答

wx.chooseMedia选择不符合标准的视频,系统loading不消失,无法正常显示toast?

this.selectComponent('#modal').showModal({

        title: '温馨提示',

        content: '请上传8-45秒的视频~',

        confirmText: '选择视频',

        cancelText: '取消',

        btnStyle: 'plain',

        showCancel: true,

        icon: ``,

        confirm: () => {

          app.globalData.notInit = true

          wx.chooseMedia({

            count: 1,

            mediaType: ['video'],

            sourceType: ['album', 'camera'],

            maxDuration: 45,

            camera: 'back',

            success: (res) => {

              let duration = res.tempFiles[0].duration

              if (duration > 45 || duration < 8{

                wx.showToast({

                  title: '抱歉,请上传8-45s的视频',

                  icon: "none",

                  duration: 3000

                });

                setTimeout(() => {

                  app.globalData.notInit = false

                }, 500);

                return;

              }

              if (res.type !== 'video'{

                wx.showToast({

                  title: '抱歉,请选择要上传的视频',

                  icon: "none",

                });

                setTimeout(() => {

                  app.globalData.notInit = false

                }, 500);

                return;

              }

              app.globalData.notInit = false

            },

            fail: () => {

              wx.showToast({

                title: '已取消',

                icon: "none",

              });

              app.globalData.notInit = false;

            },

            complete: () => {

              app.globalData.notInit = false;

            }

          })

        }

      })


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

2 个回答

  • 社区技术运营专员--阳光
    社区技术运营专员--阳光
    2025-09-03

    不符合标准的视频提供个demo吧


    2025-09-03
    有用
    回复
  • 智能回答 智能回答 本次回答由AI生成
    2025-09-02
    有用
登录 后发表内容