这研不读也罢 2023-08-09 20:35 采纳率: 88.9%
浏览 9
已结题

parameter.src should be String instead of Undefined;"

微信小程序的网址不能打印出来吗?
上传视频后返回了tempfiles,我想要提取出其中的tempfilepath,但是一直在无法识别,提示我类型错了。
参考代码是https://blog.csdn.net/zhoulib__/article/details/125641526?spm=1001.2014.3001.5506里的,代码问题如下图:

img

img


我的代码如下:

Page({
  // 链接可能会过期换成自己的就行
    data:{
       //"audioUrl": "https://dl.stream.qqmusic.qq.com/C4000026gMkr1L9tKN.m4a?guid=7840612806&vkey=4696DBD6111F38EC3D75D0F4FDF769B3736068A795CF585BA18DF3A4BCD8F83D0662B54D70F64934AF74A34C9A354AFF0AA4660CCE4C66F0&uin=&fromtag=120032",
      videoUrl: "C:/Users/priesty/Desktop/caogao/test.mp4",
      videoInfo: {},
      canvasWidth: 0,
      canvasHeight: 0,
      fps: 0,
      duration: 0,
      imageList: [],
      tempFilePath:"",
    },
    onLoad() {
      console.log("开始"),
      this.videoDecoderStart()
    },
     // async是异步的意思,会返回一个promise对象,而awite会等待这个async的promise完成 并将reslove的结果返回出来
    async videoDecoderStart() {
      // 自己选择视频
      const that = this
/*       var {tempFilePath} = await wx.chooseMedia( */
      //const tempFilePath =  wx.chooseMedia(
        wx.chooseMedia(
        {
          sourceType: ['album'],
          success(res){
            console.log(res);
            //var tempFilePath = res.tempFilePath
            that.setData({        //在data维护一组数据 
              tempFilePath: res.tempFiles.tempFilePath
            })
            console.log(tempFilePath)   //无法识别,为什么?
          }
        }
      )
      console.log("选择")
      console.log(tempFilePath)        //还是无法识别?
      // 网络视频
     // wx.showLoading({
     //   title: '加载中...',
     // })
     // var {
     //   tempFilePath
     // } = await this.getTempPath(this.data.videoUrl)
     // wx.hideLoading()
      var videoInfo = await wx.getVideoInfo({
        src: that.data.tempFilePath          //这里一直报错
      })
      this.setData({
        videoInfo: videoInfo,
        canvasWidth: videoInfo.width,
        canvasHeight: videoInfo.height,
        duration: videoInfo.duration,
        fps: videoInfo.fps
      }, () => {
       // 创建视频解析器
      this.videoDecoder = wx.createVideoDecoder()
        const {
          canvas,
          context
        } = this.initOffscreenCanvas(this.data.canvasWidth, this.data.canvasWidth)
        this.videoDecoder.on("start", () => {
          this.videoDecoder.seek(0)
          this.timer = setInterval(() => {
             this.getFrameData(canvas, context)
          }, 300);
        })
        this.videoDecoder.on("seek", () => {})
        this.videoDecoder.on("stop", () => {})
        this.videoDecoder.start({
          source: tempFilePath
        })
      })
    },

问一下该怎么修改?

  • 写回答

1条回答 默认 最新

  • 崽崽的谷雨 2023-08-10 13:20
    关注

    根据报错 是说 getvedioinfo参数得是个 string .但你现在是undefined .that.data.tempFilePath 你打印一下看看

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论 编辑记录

报告相同问题?

问题事件

  • 系统已结题 8月21日
  • 已采纳回答 8月13日
  • 创建了问题 8月9日

悬赏问题

  • ¥50 这Mac系统提示虚拟内存不足,怎么解决
  • ¥15 Rs232电路无法收发数据,求帮助
  • ¥15 百度cookie扫码登录器
  • ¥15 微机原理汇编语言debug调试实验
  • ¥23 matlab可以把相图转换为庞加莱映射吗
  • ¥15 Arduino电机和openmv连接异常
  • ¥15 Arcgis河网分级报错
  • ¥200 java+appium2.1+idea
  • ¥20 请帮我做一个EXE的去重TXT文本
  • ¥15 工价表引用工艺路线,应如何制作py和xml文件