Uri media source http headers#3169
Conversation
|
@dotnet-policy-service agree |
pictos
left a comment
There was a problem hiding this comment.
Good job, I've a few comments about your work
src/CommunityToolkit.Maui.MediaElement/MediaSource/UriMediaSource.shared.cs
Outdated
Show resolved
Hide resolved
src/CommunityToolkit.Maui.MediaElement/MediaSource/MediaSource.shared.cs
Show resolved
Hide resolved
src/CommunityToolkit.Maui.MediaElement/Views/HttpRandomAccessStream.windows.cs
Show resolved
Hide resolved
src/CommunityToolkit.Maui.MediaElement/Views/HttpRandomAccessStream.windows.cs
Outdated
Show resolved
Hide resolved
src/CommunityToolkit.Maui.MediaElement/Views/HttpRandomAccessStream.windows.cs
Outdated
Show resolved
Hide resolved
| /// An <see cref="IRandomAccessStream"/> implementation backed by HTTP Range requests, | ||
| /// enabling progressive streaming of media content with custom HTTP headers without buffering the entire file in memory. | ||
| /// </summary> | ||
| sealed partial class HttpRandomAccessStream : IRandomAccessStream |
There was a problem hiding this comment.
Not sure if this class should live inside Views
There was a problem hiding this comment.
Not sure either.. Though it's an internal sealed class exclusively used by MediaManager.windows.cs. I can move it elsewhere if needed!
src/CommunityToolkit.Maui.MediaElement/Views/MediaManager.windows.cs
Outdated
Show resolved
Hide resolved
src/CommunityToolkit.Maui.MediaElement/Views/MediaManager.windows.cs
Outdated
Show resolved
Hide resolved
src/CommunityToolkit.Maui.MediaElement/Views/MediaManager.windows.cs
Outdated
Show resolved
Hide resolved
src/CommunityToolkit.Maui.MediaElement/Views/MediaManager.windows.cs
Outdated
Show resolved
Hide resolved
|
Thank you pictos for your detailed review, I will address your points asap! |
There was a problem hiding this comment.
Pull request overview
Adds support for supplying custom HTTP request headers when MediaElement loads media from a UriMediaSource, enabling scenarios like authenticated streaming (Fixes #1889, #3154).
Changes:
- Introduces
UriMediaSource.HttpHeadersand a newMediaSource.FromUri(Uri?, IDictionary<string,string>?)overload. - Implements header propagation on Android (Media3), iOS/macCatalyst (AVUrlAsset options), and Windows (AdaptiveMediaSource + stream fallback).
- Updates the sample page UI to let users define headers, and adds unit tests for the new API surface.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| test-output.txt | Adds captured test runner output (appears to be a local artifact). |
| test-error.txt | Adds captured test crash output (appears to be a local artifact). |
| src/CommunityToolkit.Maui.UnitTests/Views/MediaElement/UriMediaSourceTests.cs | Adds unit tests for HttpHeaders and the new FromUri overload. |
| src/CommunityToolkit.Maui.MediaElement/Views/MediaManager.windows.cs | Applies headers on Windows using AdaptiveMediaSource and a stream fallback. |
| src/CommunityToolkit.Maui.MediaElement/Views/MediaManager.macios.cs | Applies headers for iOS/macCatalyst via AVUrlAsset options. |
| src/CommunityToolkit.Maui.MediaElement/Views/MediaManager.android.cs | Applies headers on Android by configuring a DefaultHttpDataSource.Factory. |
| src/CommunityToolkit.Maui.MediaElement/Views/HttpRandomAccessStream.windows.cs | New Windows stream implementation used for header-enabled URI fallback. |
| src/CommunityToolkit.Maui.MediaElement/MediaSource/UriMediaSource.shared.cs | Adds the HttpHeaders property to UriMediaSource. |
| src/CommunityToolkit.Maui.MediaElement/MediaSource/MediaSource.shared.cs | Adds FromUri(Uri?, IDictionary<string,string>?) overload. |
| samples/CommunityToolkit.Maui.Sample/Pages/Views/MediaElement/MediaElementPage.xaml.cs | Adds logic to capture/apply custom headers in the sample. |
| samples/CommunityToolkit.Maui.Sample/Pages/Views/MediaElement/MediaElementPage.xaml | Adds UI controls for entering custom headers in the sample. |
Description of Change
Add HTTP headers support to MediaElement
Linked Issues
PR Checklist
approved(bug) orChampioned(feature/proposal)mainat time of PRAdditional information
Thank you for reading through!
As documented, Tizen does not support custom HTTP headers.
I tested this on Windows with Mockoon. On HLS for instance, custom headers are propagated to both manifest and segments.
Feel free to test this by using the sample and setting custom headers.