I'm trying to read an audio stream using an HttpClient
because I need to modify HTTP headers. The only "working" way I found is the following :
HttpResponseMessage response = await httpClient.GetAsync("http://...");
Stream stream = await response.Content.ReadAsStreamAsync();
IRandomAccessStream content = stream.AsRandomAccessStream();
musicPlayer.SetSource(content, "audio/mpeg"); //musicPlayer is a MediaElement object
musicPlayer.Play();
The issue is that the MediaElement
really starts to play when the file has been entirely downloaded, so it's quite useless for streaming. I need it to play as soon as the stream is received.