-
Notifications
You must be signed in to change notification settings - Fork 133
chore: update MediaElement docs to include custom http headers feature #639
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -153,6 +153,38 @@ By default, the media that is defined by the `Source` property doesn't immediate | |||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| Platform provided media playback controls are enabled by default, and can be disabled by setting the `ShouldShowPlaybackControls` property to `false`. | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| ### Play remote media with custom HTTP headers | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| A `MediaElement` can send custom HTTP headers when loading remote media. This is useful for authenticated streams that require an `Authorization` header or other custom headers. | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| ```csharp | ||||||||||||||||||||||||||||
| MediaElement.Source = new UriMediaSource | ||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||
| Uri = new Uri("https://example.com/stream.m3u8"), | ||||||||||||||||||||||||||||
| HttpHeaders = new Dictionary<string, string> | ||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||
| ["Authorization"] = "Bearer my-token" | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||
|
Comment on lines
+161
to
+168
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks @Kaaybi! To ensure we call (I.e. This means that we can no longer pass in a Long story short, we just need to update the docs here to use the
Suggested change
|
||||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| Or using the `MediaSource.FromUri` overload: | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| ```csharp | ||||||||||||||||||||||||||||
| var headers = new Dictionary<string, string> | ||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||
| ["Authorization"] = "Bearer my-token" | ||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||
| MediaElement.Source = MediaSource.FromUri( | ||||||||||||||||||||||||||||
| new Uri("https://example.com/stream.m3u8"), headers); | ||||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||||
|
Kaaybi marked this conversation as resolved.
Outdated
|
||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| > [!NOTE] | ||||||||||||||||||||||||||||
| > HTTP headers are applied to all HTTP requests made for the media source, including manifest and segment downloads for adaptive streams (HLS/DASH). This feature is supported on Android, iOS, macOS, and Windows. Tizen does not support custom HTTP headers. | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| > [!IMPORTANT] | ||||||||||||||||||||||||||||
| > On iOS and macOS, the `AVURLAssetHTTPHeaderFieldsKey` option requires iOS 16.0+ / macOS 13.0+. | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| ### Use Rich Media Notifications | ||||||||||||||||||||||||||||
| A `MediaElement` can show rich media notifications on Android, iOS, Mac Catalyst, and Windows when media is playing in the background. To enable rich media notifications, the following steps are required: | ||||||||||||||||||||||||||||
| 1. Enable background video playback by setting the `enableForegroundService` parameter to `true` when calling the `UseMauiCommunityToolkitMediaElement` method in *MauiProgram.cs*. Refer to the **Initializing the package** section above for more information. | ||||||||||||||||||||||||||||
|
|
@@ -245,6 +277,7 @@ A `MediaElement` can play media by setting its `Source` property to a remote or | |||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| - `FromFile`, returns a `FileMediaSource` instance from a `string` argument. | ||||||||||||||||||||||||||||
| - `FromUri`, returns a `UriMediaSource` instance from a `Uri` argument. | ||||||||||||||||||||||||||||
| - `FromUri(Uri, IDictionary<string, string>)`, returns a `UriMediaSource` instance from a `Uri` argument with custom HTTP headers applied to all requests. | ||||||||||||||||||||||||||||
|
Kaaybi marked this conversation as resolved.
Outdated
|
||||||||||||||||||||||||||||
| - `FromResource`, returns a `ResourceMediaSource` instance from a `string` argument. | ||||||||||||||||||||||||||||
|
Comment on lines
278
to
281
|
||||||||||||||||||||||||||||
| - `FromFile`, returns a `FileMediaSource` instance from a `string` argument. | |
| - `FromUri`, returns a `UriMediaSource` instance from a `Uri` argument. | |
| - `FromUri(Uri, IDictionary<string, string>)`, returns a `UriMediaSource` instance from a `Uri` argument with custom HTTP headers applied to all requests. | |
| - `FromResource`, returns a `ResourceMediaSource` instance from a `string` argument. | |
| - `FromFile(string)`, returns a `FileMediaSource` instance from a `string` argument. | |
| - `FromUri(Uri)`, returns a `UriMediaSource` instance from a `Uri` argument. | |
| - `FromUri(Uri, IDictionary<string, string>)`, returns a `UriMediaSource` instance from a `Uri` argument with custom HTTP headers applied to all requests. | |
| - `FromResource(string)`, returns a `ResourceMediaSource` instance from a `string` argument. |
Uh oh!
There was an error while loading. Please reload this page.