14

MediaSource.isTypeSupported('audio/ogg; codecs="vorbis"') return false - is it mean that I can not stream ogg as a response from POST?

Matej Kormuth
  • 2,139
  • 3
  • 35
  • 52
Vitaly Zdanevich
  • 13,032
  • 8
  • 47
  • 81

1 Answers1

5

That's exactly what it means. The clients which return false for this condition cannot play this media type (older browsers, unsupported OS or client settings which prevent this).

For streaming OGG file formats you can definitly use Audio.play(); on most modern browsers, but unfortunately the MediaSource element does not support streaming with POST request - you would have to use the classic streaming method, or download the entire source file as a whole and then play it.

Koby Douek
  • 16,156
  • 19
  • 74
  • 103
  • So no way to stream ogg from POST? – Vitaly Zdanevich Jun 11 '17 at 10:55
  • By GET I can `new Audio(src).play()` and listen sound while it not fully downloaded, but if I need to play audio as a response from POST I need to convert this response to blob after that create URL and play - but I will hear the audio only after full file is downloaded: 6mb audio example `fetch('https://ia802607.us.archive.org/31/items/tom_sawyer_librivox/TSawyer_27-28_twain.ogg').then(r => r.blob()).then(b => new Audio(URL.createObjectURL(b)).play())` – Vitaly Zdanevich Jun 11 '17 at 11:09
  • @VitalyZdanevich I've done some more research and updated my answer, it seems that using `fetch` for the OGG blob object via POST is not supported in `MediaSource`. – Koby Douek Jun 21 '17 at 06:43
  • 1
    What do you mean by `classic streaming method`? – Vitaly Zdanevich Jun 21 '17 at 07:50
  • @VitalyZdanevich `Audio(src).play()` – Koby Douek Jun 21 '17 at 07:51
  • But maybe is it possible to use XMLHttpRequest to stream ogg from POST response? – Vitaly Zdanevich Jul 05 '17 at 15:31