Пример #1
0
        static public IAsyncOperation <HttpRandomAccessStream> CreateAsync(HttpClient client, Uri uri)
        {
            HttpRandomAccessStream randomStream = new HttpRandomAccessStream(client, uri);

            return(AsyncInfo.Run <HttpRandomAccessStream>(async(cancellationToken) =>
            {
                await randomStream.SendRequesAsync().ConfigureAwait(false);
                return randomStream;
            }));
        }
Пример #2
0
        private async Task Show_mp3()
        {
            Uri uri = new Uri("https://file-examples.com/wp-content/uploads/2017/11/file_example_MP3_700KB.mp3");


            HttpClient client = new HttpClient();

            client.DefaultRequestHeaders.Add("user", "myName");
            // load HTTP Stream

            HttpRandomAccessStream stream = await HttpRandomAccessStream.CreateAsync(client, uri);

            mediaPlayer.AutoPlay = true;

            mediaPlayer.Source = MediaSource.CreateFromStream(stream, stream.ContentType);
        }