设置 audio.currentTIme;从快递服务器发送的歌曲缓冲区

setting audio.currentTIme; with song buffer sent from express server

我只是为了好玩而尝试制作一个简单的音乐播放器我​​正在从 express 发送图像缓冲区并像这样加载它

song = new Audio('/song/'+ songId);

它加载完美 我可以停止播放并执行所有操作,但我无法设置它 currentTime。我正在阅读另一个 SO 问题,有人说他们的问题是服务器配置不正确。它没有发送 Content-Duration header。所以我试着这样做只是为了测试

  app.get("/song/:songId", function(req, res) {
    var songId = req.param('songId');
    songData.findOne({songId:songId}, function (err, doc) {
      if(err || doc == null){
        res.status(404)        // HTTP status 404: NotFound
          .send('Not found')
      }else{
        var song = new Buffer(doc.base64, 'base64');
        mp3Duration(song, function (err, duration) {
          if (err) return console.log(err.message);
          console.log(duration)
          res.header({
            'Content-Type': 'audio/mp3',
            'Content-Length': song.length,
            'X-Content-Duration': '00:00:03:473'
          });
          res.end(song);
        })
      }
    }); 
  });

它仍然无法正常工作它只是在我尝试设置它时重播音频是我做错了什么吗?

所以我在 this 上找到了一些我需要的信息所以我需要做的就是更改我从这个

发送的 header
'X-Content-Duration': '00:00:03:473'

到这个

'Accept-Ranges': 'bytes', 'Content-Length': song.length

一旦我这样做了,我就能够毫无问题地完美地设置当前时间:)