2

Anyone know of a way to access an audio file that is protected with Basic auth when using a BackgroundMediaPlayer in WP8.1?

I've tried using the StreamingRandomAccessStream from How to play a video stream that requires authentication? but it doesn't work with BackgroundMediaPlayer. This is because SetStreamSource() needs to be run from the background agent, and I can't use a HttpClient in a Windows Runtime Component.

EDIT (2015-04-13):
I've now tried using a Windows.Web.Http.HttpClient but it never worked properly because of an apparent bug in the HttpClient stack: https://social.msdn.microsoft.com/Forums/windowsapps/en-US/07e551c1-37c0-4bd9-9d98-aa3fc90df974/windows-phone-8-portable-httpclient-causes-outofmemoryexception-downloading-large-file?forum=wpdevelop&prof=required#5eb62907-92cd-4643-8c74-9e6c2a30e464

The SM.Mono.Net repository has a solution, but doesn't work with files over TLS, which unfortunately makes it unusable for me.

Community
  • 1
  • 1
azzlack
  • 1,191
  • 1
  • 9
  • 28
  • 1
    You should be able to use `Windows.Web.Http.HttpClient` from a Windows Runtime Component. – kiewic Feb 13 '15 at 18:27
  • Hmm. Only tried with the `System.Net` client. Will try this again with that one – azzlack Feb 13 '15 at 18:31
  • Well, I've now tried using a `Windows.Web.Http.HttpClient` but it never worked because of a bug in the `HttpClient` stack: https://social.msdn.microsoft.com/Forums/windowsapps/en-US/07e551c1-37c0-4bd9-9d98-aa3fc90df974/windows-phone-8-portable-httpclient-causes-outofmemoryexception-downloading-large-file?forum=wpdevelop&prof=required#5eb62907-92cd-4643-8c74-9e6c2a30e464 – azzlack Apr 13 '15 at 08:50
  • Did you try using `HttpCompletionOption.ResponseHeadersRead`? I do not think the bug you pointed out is in the same HttpClient implementation. – kiewic Apr 13 '15 at 17:26
  • I tried doing that initially yes, to get the total audio file size. Then I used that file size to get the data in batches. Problem was, the player would not play the files, and I got the Overflow exception after some time. – azzlack Apr 14 '15 at 00:30

0 Answers0