Skip to content

Instantly share code, notes, and snippets.

@rdelrosario
Created October 27, 2021 19:12
Show Gist options
  • Save rdelrosario/be985de66f0873cba5284ba5af0ee4ce to your computer and use it in GitHub Desktop.
Save rdelrosario/be985de66f0873cba5284ba5af0ee4ce to your computer and use it in GitHub Desktop.
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage
x:Class="VideoPlayerStateMachine.MainPage"
xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:controls="clr-namespace:VideoPlayerStateMachine.Controls"
xmlns:ios="clr-namespace:Xamarin.Forms.PlatformConfiguration.iOSSpecific;assembly=Xamarin.Forms.Core"
xmlns:local="clr-namespace:VideoPlayerStateMachine"
xmlns:viewModels="clr-namespace:VideoPlayerStateMachine.ViewModels"
BackgroundColor="Black"
ios:Page.UseSafeArea="true">
<ContentPage.BindingContext>
<viewModels:MainViewModel />
</ContentPage.BindingContext>
<Grid ColumnDefinitions="Auto, *"
RowDefinitions="Auto, Auto, Auto, Auto, Auto, Auto">
<Label
FontSize="Title"
HorizontalOptions="Center"
Text="{Binding Status}"
TextColor="White"
VerticalOptions="Start"
Grid.Row="0"
Grid.Column="0"
Grid.ColumnSpan="2"/>
<Label
FontSize="Title"
HorizontalOptions="Center"
Text="{Binding Position, StringFormat='{}{0:hh\\:mm\\:ss}'}"
TextColor="White"
VerticalOptions="Start"
Grid.Row="1"
Grid.Column="0"
Grid.ColumnSpan="2"/>
<controls:VideoPlayer
x:Name="VideoPlayer"
AutoPlay="{Binding CanAutoPlay}"
Command="{Binding VideoActionCommand}"
Position="{Binding Position, Mode=TwoWay}"
VerticalOptions="Start"
HeightRequest="400"
Source="https://sec.ch9.ms/ch9/5d93/a1eab4bf-3288-4faf-81c4-294402a85d93/XamarinShow_mid.mp4"
Grid.Row="2"
Grid.Column="0"
Grid.ColumnSpan="2"/>
<StackLayout
HorizontalOptions="CenterAndExpand"
VerticalOptions="Start"
Orientation="Horizontal"
Grid.Row="3"
Grid.Column="0"
Grid.ColumnSpan="2">
<Button
Command="{Binding TriggerCommand}"
CommandParameter="{x:Static local:VideoTrigger.Play}"
FontSize="Medium"
IsVisible="{Binding CanPlay}"
Text="Play"
TextColor="White" />
<Button
Command="{Binding TriggerCommand}"
CommandParameter="{x:Static local:VideoTrigger.Pause}"
FontSize="Medium"
IsVisible="{Binding CanPause}"
Text="Pause"
TextColor="White" />
<Button
Command="{Binding TriggerCommand}"
CommandParameter="{x:Static local:VideoTrigger.Stop}"
FontSize="Medium"
IsVisible="{Binding CanStop}"
Text="Stop"
TextColor="White" />
<Button
Command="{Binding RewindCommand}"
CommandParameter="{Binding Source={x:Reference RewindStepper}, Path=Value}"
Margin="40,0,0,0"
WidthRequest="30"
HeightRequest="30"
VerticalOptions="Center"
FontSize="Small"
CornerRadius="15"
IsVisible="{Binding CanStop}"
Text="{Binding Source={x:Reference RewindStepper}, Path=Value, StringFormat='-{0}'}"
BackgroundColor="White"
TextColor="Black" />
<Button
Command="{Binding ForwardCommand}"
CommandParameter="{Binding Source={x:Reference ForwardStepper}, Path=Value}"
WidthRequest="30"
HeightRequest="30"
VerticalOptions="Center"
FontSize="Small"
CornerRadius="15"
IsVisible="{Binding CanStop}"
Text="{Binding Source={x:Reference ForwardStepper}, Path=Value, StringFormat='+{0}'}"
BackgroundColor="White"
TextColor="Black" />
</StackLayout>
<Label Text="Rewind Seconds (-5,+5)"
TextColor="White"
IsVisible="{Binding CanStop}"
Grid.Row="4"
Grid.Column="0"/>
<Stepper Maximum="30"
Minimum="5"
Increment="5"
BackgroundColor="White"
IsVisible="{Binding CanStop}"
x:Name="RewindStepper"
Grid.Row="4"
Grid.Column="1"/>
<Label Text="Forward Seconds (-5,+5)"
IsVisible="{Binding CanStop}"
TextColor="White"
Grid.Row="5"
Grid.Column="0"/>
<Stepper Maximum="30"
Minimum="5"
Increment="5"
IsVisible="{Binding CanStop}"
BackgroundColor="White"
x:Name="ForwardStepper"
Grid.Row="5"
Grid.Column="1"/>
</Grid>
</ContentPage>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment