-
Notifications
You must be signed in to change notification settings - Fork 493
Add stream media source #3181
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
Merged
TheCodeTraveler
merged 56 commits into
CommunityToolkit:main
from
matt-goldman:add-stream-media-source
May 11, 2026
Merged
Add stream media source #3181
Changes from 29 commits
Commits
Show all changes
56 commits
Select commit
Hold shift + click to select a range
e443cf4
Added Stream as a media source for all platforms except Tizen
matt-goldman d578bb4
Added media element sample page and fixed small bug on Android
matt-goldman b86fbb7
Code cleanup and fix for Windows
matt-goldman a1f72a4
Resolve content type identification on macios
matt-goldman 500bff8
Add Stream source test and remove temp file
matt-goldman 4eebe6d
Merge branch 'main' into add-stream-media-source
matt-goldman dce4b60
Remove default cancellation token from CreateMediaItemFromStream
matt-goldman ab38062
Update StreamAssetResourceLoader to chunk reads with a max buffer siz…
matt-goldman e978e15
Fix test for MediaSource.FromStream
matt-goldman 94966fe
Remove hard-coded CRLF from sample app csproj file
matt-goldman 72e1b74
Fixed disposal pattern in MediaElementFromStreamPage.xaml.cs, also cl…
matt-goldman c0bcdce
Fix stream position logic in StreamDataSource.android.cs and formatti…
matt-goldman 8cefc98
Remove static keyword from HttpClient declaration in MediaManager.and…
matt-goldman 6846f44
Added a static dictionary to avoid re-instantiation of response heade…
matt-goldman d2ba541
Update samples/CommunityToolkit.Maui.Sample/ViewModels/Views/ViewsGal…
matt-goldman 3ee0570
Update samples/CommunityToolkit.Maui.Sample/MauiProgram.cs
matt-goldman 5b10d29
Fix ILogger type in constructor of MediaElementFromStreamPage.xaml.cs
matt-goldman e64124b
Removed static from artwork metadata method in MediaManager.android.cs
matt-goldman b459302
Update src/CommunityToolkit.Maui.MediaElement/Views/MediaManager.maci…
matt-goldman 9429dbf
Merge branch 'CommunityToolkit:main' into add-stream-media-source
matt-goldman 5d9c2f9
Restore macios StreamAssetResourceLoader.macios.cs to working version
matt-goldman d6b22fe
Merge branch 'main' into add-stream-media-source
matt-goldman a28307e
Added updated permisisons for sample app
matt-goldman a6f715f
Fix race condition in LazyView test
matt-goldman 4dafc54
Remove ConfigureAwait(false) from OnValidationPropertyChanged
matt-goldman 4599b2f
Catch exceptions in OnValidationPropertychanged
matt-goldman d10b027
Merge branch 'main' into add-stream-media-source
matt-goldman 8579f57
Merge branch 'main' into add-stream-media-source
matt-goldman a9c8c92
Merge branch 'main' into add-stream-media-source
ne0rrmatrix dcf4409
Revert unintentional solution and project file changes
matt-goldman dd305df
Move GetMimeType extension to primitives
matt-goldman 2699fc7
Move GetMimeType extension to Extensions folder and namespace
matt-goldman 6c02604
Merge branch 'main' into add-stream-media-source
matt-goldman b0bc6d9
Merge branch 'main' into add-stream-media-source
matt-goldman 64c4bb6
Merge branch 'main' into add-stream-media-source
TheCodeTraveler dc90cb6
Potential fix for pull request finding
TheCodeTraveler 8643cae
Implement CoPilot suggestions
TheCodeTraveler 22a8655
Remove static cached dictionary for empty headers and add property in…
matt-goldman 96c36c3
Add validation for stream length in StreamDataSource to prevent Argum…
matt-goldman 3571483
Change File.Open to File.OpenRead for improved stream handling
matt-goldman 1697efe
Dispose current stream data source factory before initializing a new one
matt-goldman e9e9dcd
Merge branch 'main' into add-stream-media-source
matt-goldman 81c0771
Merge branch 'main' into add-stream-media-source
matt-goldman d75be1d
Update Sample App to play video OnAppearing
TheCodeTraveler f9a6561
Merge branch 'main' into add-stream-media-source
TheCodeTraveler 62533bb
Merge branch 'add-stream-media-source' of https://github.com/matt-gol…
TheCodeTraveler ed443a0
Update `GetMimeType`, Add Unit Tests
TheCodeTraveler 5354e4f
Add `ArgumentNullException.ThrowIfNull`
TheCodeTraveler 64f686c
Nest `StreamDataSource` inside `StreamDataSourceFactory`, Move File L…
TheCodeTraveler fbd7b08
Update formatting
TheCodeTraveler a9cfbcf
Update formatting
TheCodeTraveler 69c97e6
Update formatting
TheCodeTraveler bc3af00
`dotnet format`
TheCodeTraveler 78f261f
Use `StreamAssetResourceLoader.DefaultContentType`
TheCodeTraveler ff5e7ed
Update formatting
TheCodeTraveler 1e8d2e2
Rename `StreamDataSourceFactory`
TheCodeTraveler File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
161 changes: 161 additions & 0 deletions
161
...les/CommunityToolkit.Maui.Sample/Pages/Views/MediaElement/MediaElementFromStreamPage.xaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,161 @@ | ||
| <?xml version="1.0" encoding="utf-8" ?> | ||
| <pages:BasePage xmlns="http://schemas.microsoft.com/dotnet/2021/maui" | ||
| xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | ||
| xmlns:pages="clr-namespace:CommunityToolkit.Maui.Sample.Pages" | ||
| xmlns:toolkit="http://schemas.microsoft.com/dotnet/2022/maui/toolkit" | ||
| xmlns:constants="clr-namespace:CommunityToolkit.Maui.Sample.Constants" | ||
| xmlns:viewModels="clr-namespace:CommunityToolkit.Maui.Sample.ViewModels.Views" | ||
| xmlns:converters="clr-namespace:CommunityToolkit.Maui.Sample.Converters" | ||
| x:TypeArguments="viewModels:MediaElementFromStreamViewModel" | ||
| x:DataType="viewModels:MediaElementFromStreamViewModel" | ||
| x:Class="CommunityToolkit.Maui.Sample.Pages.Views.MediaElementFromStreamPage" | ||
| Title="MediaElement"> | ||
| <pages:BasePage.Resources> | ||
| <converters:SecondsToStringConverter x:Key="SecondsToStringConverter" /> | ||
| </pages:BasePage.Resources> | ||
|
|
||
| <ScrollView> | ||
| <Grid> | ||
| <Grid.RowDefinitions> | ||
| <RowDefinition Height="220" /> | ||
| <RowDefinition Height="50" /> | ||
| <RowDefinition Height="Auto" /> | ||
| <RowDefinition Height="Auto" /> | ||
| <RowDefinition Height="Auto" /> | ||
| <RowDefinition Height="Auto" /> | ||
| <RowDefinition Height="Auto" /> | ||
| <RowDefinition Height="Auto" /> | ||
| <RowDefinition Height="Auto" /> | ||
| </Grid.RowDefinitions> | ||
| <toolkit:MediaElement | ||
| x:Name="MediaElement" | ||
| ShouldAutoPlay="True" | ||
| MediaEnded="OnMediaEnded" | ||
| MediaFailed="OnMediaFailed" | ||
| MediaOpened="OnMediaOpened" | ||
| PositionChanged="OnPositionChanged" | ||
| StateChanged="OnStateChanged" | ||
| SeekCompleted="OnSeekCompleted"/> | ||
| <HorizontalStackLayout Grid.Row="1" Padding="0,0,0,15"> | ||
| <Label HorizontalOptions="Center" x:DataType="toolkit:MediaElement"> | ||
| <Label.Text> | ||
| <MultiBinding StringFormat="{}Current State: {0} - Dimensions: {1}x{2}"> | ||
| <Binding Path="CurrentState" Source="{x:Reference MediaElement}" /> | ||
| <Binding Path="MediaWidth" Source="{x:Reference MediaElement}" /> | ||
| <Binding Path="MediaHeight" Source="{x:Reference MediaElement}" /> | ||
| </MultiBinding> | ||
| </Label.Text> | ||
| </Label> | ||
|
|
||
| </HorizontalStackLayout> | ||
|
|
||
| <Grid Grid.Row="2" Padding="0,10,0,10" ColumnDefinitions="*,*,*,*,*" ColumnSpacing="5"> | ||
| <Button Grid.Column="0" Text="Play" Clicked="OnPlayClicked" /> | ||
| <Button Grid.Column="1" Text="Pause" Clicked="OnPauseClicked" /> | ||
| <Button Grid.Column="2" Text="Stop" Clicked="OnStopClicked" /> | ||
| <Button Grid.Column="3" Text="Mute" Clicked="OnMuteClicked"> | ||
| <Button.Triggers> | ||
| <DataTrigger TargetType="Button" | ||
| x:DataType="toolkit:MediaElement" | ||
| Binding="{Binding ShouldMute, Source={x:Reference MediaElement}}" | ||
| Value="True"> | ||
| <Setter Property="Text" Value="Unmute" /> | ||
| </DataTrigger> | ||
| <DataTrigger TargetType="Button" | ||
| x:DataType="toolkit:MediaElement" | ||
| Binding="{Binding ShouldMute, Source={x:Reference MediaElement}}" | ||
| Value="False"> | ||
| <Setter Property="Text" Value="Mute" /> | ||
| </DataTrigger> | ||
| </Button.Triggers> | ||
| </Button> | ||
| <Button Grid.Column="4" Text="Popup" Clicked="DisplayPopup" /> | ||
| </Grid> | ||
|
|
||
| <Slider | ||
| x:Name="PositionSlider" | ||
| Grid.Row="3" | ||
| MinimumTrackColor="Gray" | ||
| DragStarted="Slider_DragStarted" | ||
| DragCompleted="Slider_DragCompleted"/> | ||
|
|
||
| <Grid Grid.Row="4" HorizontalOptions="Fill"> | ||
| <Label HorizontalOptions="Start" x:DataType="toolkit:MediaElement" Text="{Binding Position, Source={x:Reference MediaElement}, Converter={StaticResource SecondsToStringConverter}}" /> | ||
| <Label HorizontalOptions="End" HorizontalTextAlignment="End" x:DataType="toolkit:MediaElement" Text="{Binding Duration, Source={x:Reference MediaElement}, Converter={StaticResource SecondsToStringConverter}}" /> | ||
| </Grid> | ||
|
|
||
| <VerticalStackLayout Padding="0,20,0,0" Grid.Row="5" Spacing="5"> | ||
| <HorizontalStackLayout Spacing="5" HorizontalOptions="Center"> | ||
| <Button Text="Open Video" Clicked="OnOpenVideoClicked" HorizontalOptions="Fill" /> | ||
|
|
||
| <Button Text="Record Video" Clicked="OnRecordVideoClicked" HorizontalOptions="Fill" /> | ||
| </HorizontalStackLayout> | ||
| <Button Text="Change Aspect" Clicked="ChangeAspectClicked" /> | ||
| </VerticalStackLayout> | ||
|
|
||
| <HorizontalStackLayout Grid.Row="6" Padding="0,10,0,10" Spacing="5"> | ||
| <Label Margin="20,10" x:DataType="toolkit:MediaElement"> | ||
| <Label.FormattedText> | ||
| <FormattedString> | ||
| <Span Text="Speed:" /> | ||
| <Span Text="{Binding Source={x:Reference MediaElement}, Path=Speed}" /> | ||
| </FormattedString> | ||
| </Label.FormattedText> | ||
| </Label> | ||
|
|
||
| <Button Text="-" Clicked="OnSpeedMinusClicked" /> | ||
| <Button Text="+" Clicked="OnSpeedPlusClicked" /> | ||
| </HorizontalStackLayout> | ||
|
|
||
| <HorizontalStackLayout Grid.Row="7" Padding="0,10,0,10" Spacing="5"> | ||
| <Label Margin="20,10" x:DataType="toolkit:MediaElement"> | ||
| <Label.FormattedText> | ||
| <FormattedString> | ||
| <Span Text="Volume:" /> | ||
| <Span Text="{Binding Source={x:Reference MediaElement}, Path=Volume, StringFormat='{}{0:P0}'}" /> | ||
| </FormattedString> | ||
| </Label.FormattedText> | ||
| </Label> | ||
|
|
||
| <Button Text="-" Clicked="OnVolumeMinusClicked" /> | ||
| <Button Text="+" Clicked="OnVolumePlusClicked" /> | ||
| </HorizontalStackLayout> | ||
|
|
||
| <VerticalStackLayout Grid.Row="8"> | ||
| <HorizontalStackLayout Padding="0,0,0,10"> | ||
| <Switch | ||
| Margin="0,0,5,0" | ||
| ThumbColor="White" | ||
| OnColor="LimeGreen" | ||
| x:DataType="toolkit:MediaElement" | ||
| IsToggled="{Binding Source={x:Reference MediaElement}, Path=ShouldShowPlaybackControls}" /> | ||
| <Label | ||
| VerticalOptions="Center" | ||
| Text="Show playback controls" /> | ||
| </HorizontalStackLayout> | ||
| <HorizontalStackLayout Padding="0,0,0,10"> | ||
| <Switch | ||
| Margin="0,0,5,0" | ||
| ThumbColor="White" | ||
| OnColor="LimeGreen" | ||
| x:DataType="toolkit:MediaElement" | ||
| IsToggled="{Binding Source={x:Reference MediaElement}, Path=ShouldLoopPlayback}" /> | ||
| <Label | ||
| VerticalOptions="Center" | ||
| Text="Loop media" /> | ||
| </HorizontalStackLayout> | ||
| <HorizontalStackLayout> | ||
| <Switch | ||
| Margin="0,0,5,0" | ||
| ThumbColor="White" | ||
| OnColor="LimeGreen" | ||
| x:DataType="toolkit:MediaElement" | ||
| IsToggled="{Binding Source={x:Reference MediaElement}, Path=ShouldKeepScreenOn}" /> | ||
| <Label | ||
| VerticalOptions="Center" | ||
| Text="Keep screen on" /> | ||
| </HorizontalStackLayout> | ||
| </VerticalStackLayout> | ||
| </Grid> | ||
| </ScrollView> | ||
| </pages:BasePage> |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.