2

Is there a way I can play an mp3 file while it is being downloaded?

I'm using requests with stream=True to download to a file, and I can play it that way with the playsound library if its long enough, but it only plays it till however long that file was when it started playing if that makes sense...

any way around this?

  • No, you can't. Can you explain more what you're trying to do? Why does it have to play as it's coming in, as opposed to getting the whole file and then playing it. – mypetlion Nov 09 '18 at 00:12
  • @mypetlion because I'm playing the file real-time, and I don't want the user to have to wait until the entire files is downloaded since the file can be a bit big – Joshua Bultman Nov 09 '18 at 01:33
  • @mypetlion why wouldn't it be possible? This seems like a perfectly reasonable thing. It sounds like playsound just doesn't monitor the file for size changes after opening (which is typically a reasonable assumption). – Peter Gibson Nov 09 '18 at 01:53
  • @PeterGibson So what do you think would be a good way to do this? – Joshua Bultman Nov 09 '18 at 02:19
  • https://stackoverflow.com/questions/20021457/ plenty of other libraries to use, perhaps one of them may fit your need? – Fantix King Nov 09 '18 at 02:27
  • It sounds like live steam, but it seems to need some lib support this. – KC. Nov 09 '18 at 04:52
  • Try searching for Python stream MP3. This answer came up https://stackoverflow.com/questions/38171169/how-to-play-mp3-from-url – Peter Gibson Nov 09 '18 at 06:17
  • I found you are approaching the answer, @PeterGibson. The fact is you are downloading file while you are playing it. instead of `Play An Audio File While It's Being Downloaded` – KC. Nov 09 '18 at 07:28

0 Answers0