1+ <?xml version =" 1.0" encoding =" utf-8" ?>
2+ <pages : BasePage xmlns =" http://schemas.microsoft.com/dotnet/2021/maui"
3+ xmlns : x =" http://schemas.microsoft.com/winfx/2009/xaml"
4+ xmlns : pages =" clr-namespace:CommunityToolkit.Maui.Sample.Pages"
5+ xmlns : toolkit =" http://schemas.microsoft.com/dotnet/2022/maui/toolkit"
6+ xmlns : constants =" clr-namespace:CommunityToolkit.Maui.Sample.Constants"
7+ xmlns : viewModels =" clr-namespace:CommunityToolkit.Maui.Sample.ViewModels.Views"
8+ xmlns : converters =" clr-namespace:CommunityToolkit.Maui.Sample.Converters"
9+ x : TypeArguments =" viewModels:MediaElementFromStreamViewModel"
10+ x : DataType =" viewModels:MediaElementFromStreamViewModel"
11+ x : Class =" CommunityToolkit.Maui.Sample.Pages.Views.MediaElementFromStreamPage"
12+ Title =" MediaElement" >
13+ <pages : BasePage .Resources>
14+ <converters : SecondsToStringConverter x : Key =" SecondsToStringConverter" />
15+ </pages : BasePage .Resources>
16+
17+ <ScrollView >
18+ <Grid >
19+ <Grid .RowDefinitions>
20+ <RowDefinition Height =" 220" />
21+ <RowDefinition Height =" 50" />
22+ <RowDefinition Height =" Auto" />
23+ <RowDefinition Height =" Auto" />
24+ <RowDefinition Height =" Auto" />
25+ <RowDefinition Height =" Auto" />
26+ <RowDefinition Height =" Auto" />
27+ <RowDefinition Height =" Auto" />
28+ <RowDefinition Height =" Auto" />
29+ </Grid .RowDefinitions>
30+ <toolkit : MediaElement
31+ x : Name =" MediaElement"
32+ ShouldAutoPlay =" True"
33+ MediaEnded =" OnMediaEnded"
34+ MediaFailed =" OnMediaFailed"
35+ MediaOpened =" OnMediaOpened"
36+ PositionChanged =" OnPositionChanged"
37+ StateChanged =" OnStateChanged"
38+ SeekCompleted =" OnSeekCompleted" />
39+ <HorizontalStackLayout Grid.Row=" 1" Padding =" 0,0,0,15" >
40+ <Label HorizontalOptions =" Center" x : DataType =" toolkit:MediaElement" >
41+ <Label .Text>
42+ <MultiBinding StringFormat =" {}Current State: {0} - Dimensions: {1}x{2}" >
43+ <Binding Path =" CurrentState" Source =" {x:Reference MediaElement}" />
44+ <Binding Path =" MediaWidth" Source =" {x:Reference MediaElement}" />
45+ <Binding Path =" MediaHeight" Source =" {x:Reference MediaElement}" />
46+ </MultiBinding >
47+ </Label .Text>
48+ </Label >
49+
50+ </HorizontalStackLayout >
51+
52+ <Grid Grid.Row=" 2" Padding =" 0,10,0,10" ColumnDefinitions =" *,*,*,*,*" ColumnSpacing =" 5" >
53+ <Button Grid.Column=" 0" Text =" Play" Clicked =" OnPlayClicked" />
54+ <Button Grid.Column=" 1" Text =" Pause" Clicked =" OnPauseClicked" />
55+ <Button Grid.Column=" 2" Text =" Stop" Clicked =" OnStopClicked" />
56+ <Button Grid.Column=" 3" Text =" Mute" Clicked =" OnMuteClicked" >
57+ <Button .Triggers>
58+ <DataTrigger TargetType =" Button"
59+ x : DataType =" toolkit:MediaElement"
60+ Binding =" {Binding ShouldMute, Source={x:Reference MediaElement}}"
61+ Value =" True" >
62+ <Setter Property =" Text" Value =" Unmute" />
63+ </DataTrigger >
64+ <DataTrigger TargetType =" Button"
65+ x : DataType =" toolkit:MediaElement"
66+ Binding =" {Binding ShouldMute, Source={x:Reference MediaElement}}"
67+ Value =" False" >
68+ <Setter Property =" Text" Value =" Mute" />
69+ </DataTrigger >
70+ </Button .Triggers>
71+ </Button >
72+ <Button Grid.Column=" 4" Text =" Popup" Clicked =" DisplayPopup" />
73+ </Grid >
74+
75+ <Slider
76+ x : Name =" PositionSlider"
77+ Grid.Row=" 3"
78+ MinimumTrackColor =" Gray"
79+ DragStarted =" Slider_DragStarted"
80+ DragCompleted =" Slider_DragCompleted" />
81+
82+ <Grid Grid.Row=" 4" HorizontalOptions =" Fill" >
83+ <Label HorizontalOptions =" Start" x : DataType =" toolkit:MediaElement" Text =" {Binding Position, Source={x:Reference MediaElement}, Converter={StaticResource SecondsToStringConverter}}" />
84+ <Label HorizontalOptions =" End" HorizontalTextAlignment =" End" x : DataType =" toolkit:MediaElement" Text =" {Binding Duration, Source={x:Reference MediaElement}, Converter={StaticResource SecondsToStringConverter}}" />
85+ </Grid >
86+
87+ <VerticalStackLayout Padding =" 0,20,0,0" Grid.Row=" 5" Spacing =" 5" >
88+ <HorizontalStackLayout Spacing =" 5" HorizontalOptions =" Center" >
89+ <Button Text =" Open Video" Clicked =" OnOpenVideoClicked" HorizontalOptions =" Fill" />
90+
91+ <Button Text =" Record Video" Clicked =" OnRecordVideoClicked" HorizontalOptions =" Fill" />
92+ </HorizontalStackLayout >
93+ <Button Text =" Change Aspect" Clicked =" ChangeAspectClicked" />
94+ </VerticalStackLayout >
95+
96+ <HorizontalStackLayout Grid.Row=" 6" Padding =" 0,10,0,10" Spacing =" 5" >
97+ <Label Margin =" 20,10" x : DataType =" toolkit:MediaElement" >
98+ <Label .FormattedText>
99+ <FormattedString >
100+ <Span Text =" Speed:" />
101+ <Span Text =" {Binding Source={x:Reference MediaElement}, Path=Speed}" />
102+ </FormattedString >
103+ </Label .FormattedText>
104+ </Label >
105+
106+ <Button Text =" -" Clicked =" OnSpeedMinusClicked" />
107+ <Button Text =" +" Clicked =" OnSpeedPlusClicked" />
108+ </HorizontalStackLayout >
109+
110+ <HorizontalStackLayout Grid.Row=" 7" Padding =" 0,10,0,10" Spacing =" 5" >
111+ <Label Margin =" 20,10" x : DataType =" toolkit:MediaElement" >
112+ <Label .FormattedText>
113+ <FormattedString >
114+ <Span Text =" Volume:" />
115+ <Span Text =" {Binding Source={x:Reference MediaElement}, Path=Volume, StringFormat='{}{0:P0}'}" />
116+ </FormattedString >
117+ </Label .FormattedText>
118+ </Label >
119+
120+ <Button Text =" -" Clicked =" OnVolumeMinusClicked" />
121+ <Button Text =" +" Clicked =" OnVolumePlusClicked" />
122+ </HorizontalStackLayout >
123+
124+ <VerticalStackLayout Grid.Row=" 8" >
125+ <HorizontalStackLayout Padding =" 0,0,0,10" >
126+ <Switch
127+ Margin =" 0,0,5,0"
128+ ThumbColor =" White"
129+ OnColor =" LimeGreen"
130+ x : DataType =" toolkit:MediaElement"
131+ IsToggled =" {Binding Source={x:Reference MediaElement}, Path=ShouldShowPlaybackControls}" />
132+ <Label
133+ VerticalOptions =" Center"
134+ Text =" Show playback controls" />
135+ </HorizontalStackLayout >
136+ <HorizontalStackLayout Padding =" 0,0,0,10" >
137+ <Switch
138+ Margin =" 0,0,5,0"
139+ ThumbColor =" White"
140+ OnColor =" LimeGreen"
141+ x : DataType =" toolkit:MediaElement"
142+ IsToggled =" {Binding Source={x:Reference MediaElement}, Path=ShouldLoopPlayback}" />
143+ <Label
144+ VerticalOptions =" Center"
145+ Text =" Loop media" />
146+ </HorizontalStackLayout >
147+ <HorizontalStackLayout >
148+ <Switch
149+ Margin =" 0,0,5,0"
150+ ThumbColor =" White"
151+ OnColor =" LimeGreen"
152+ x : DataType =" toolkit:MediaElement"
153+ IsToggled =" {Binding Source={x:Reference MediaElement}, Path=ShouldKeepScreenOn}" />
154+ <Label
155+ VerticalOptions =" Center"
156+ Text =" Keep screen on" />
157+ </HorizontalStackLayout >
158+ </VerticalStackLayout >
159+ </Grid >
160+ </ScrollView >
161+ </pages : BasePage >
0 commit comments