How to use AdaptiveMediaSource with HttpClient in WinForms App?

asked 2021-11-04T21:02:09.903+00:00
john zyd 406 Reputation points

I found the following article introducing Adaptive streaming:

However, the code in the article is for UWP project, which is not good for my project, I need a WinForms App project for Visual Studio 2019 (Version 16.11.5) on Windows 10 (Version 21H1).
But since the article mentioned AdaptiveMediaSource using HttpClient, but I can use HttpClient inside a WinForms App, so I want to see some code example for using HttpClient in WinForms App.

But there is one more step to go for my project, as I have to login to one web server with my user name and password, then I can get some cookies, I also need to add the cookies to HttpClient, otherwise, I will get HTTP error 403 Forbidden error message.
One of such M3U8 Link is like this:

By the way, if it not possible now, yet I also have Visual Studio 2022 Preview 7.0, and since .NET 6.0 is coming, if I can do this: using adaptive streaming in a WinForms App with .Net 6.0, then it is also good option.
But I need some code sample on how to download one of such M3U8 link into a local hard drive after I login to one web page.

An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
6,911 questions
{count} votes

1 answer

Sort by: Most helpful
  1. answered 2021-11-04T22:08:02.953+00:00
    Castorix31 65,246 Reputation points

    You can use the MediaPlayerElement in Winforms (WindowsXamlHost control for Windows Forms and WPF)

    Test with the code and manifest link from the article :