Skip to content
This repository has been archived by the owner on Nov 6, 2022. It is now read-only.

Commit

Permalink
+ Added new speed button 1.5 to video player page #49
Browse files Browse the repository at this point in the history
  • Loading branch information
trueromanus committed Jul 28, 2020
1 parent ba55876 commit 9169bea
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/Anilibria/Pages/OnlinePlayer/OnlinePlayerView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -1170,6 +1170,16 @@
IsChecked="{Binding ElementName=OnlinePlayerContainer, Path=DataContext.IsNormalSpeed, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}">
Обычная
</ToggleButton>
<ToggleButton
Visibility="{Binding ElementName=OnlinePlayerContainer, Path=DataContext.IsCompactOverlayEnabled, Converter={StaticResource InverseBoolConverter}}"
IsTabStop="False"
Style="{StaticResource QualityToggleButton}"
Foreground="Black"
Height="40"
FontSize="{ThemeResource MTCMediaFontSize}"
IsChecked="{Binding ElementName=OnlinePlayerContainer, Path=DataContext.Is15xSpeed, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}">
x1.5
</ToggleButton>
<ToggleButton
Visibility="{Binding ElementName=OnlinePlayerContainer, Path=DataContext.IsCompactOverlayEnabled, Converter={StaticResource InverseBoolConverter}}"
IsTabStop="False"
Expand Down
33 changes: 33 additions & 0 deletions src/Anilibria/Pages/OnlinePlayer/OnlinePlayerViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,8 @@ public class OnlinePlayerViewModel : ViewModel, INavigation {

private bool m_Is4xSpeed;

private bool m_Is15xSpeed;

/// <summary>
/// Constructor injection.
/// </summary>
Expand Down Expand Up @@ -573,6 +575,7 @@ public void MediaStateChanged ( MediaPlaybackState playbackState ) {
IsMediaOpened = true;

if ( Is2xSpeed ) ChangePlaybackRate ( 2 );
if ( Is15xSpeed ) ChangePlaybackRate ( 1.5 );
if ( Is3xSpeed ) ChangePlaybackRate ( 3 );
if ( Is4xSpeed ) ChangePlaybackRate ( 4 );
}
Expand Down Expand Up @@ -1017,9 +1020,11 @@ public bool IsNormalSpeed
if ( !Set ( ref m_IsNormalSpeed , value ) ) return;

m_Is2xSpeed = !value;
m_Is15xSpeed = !value;
m_Is3xSpeed = !value;
m_Is4xSpeed = !value;

RaisePropertyChanged ( () => Is15xSpeed );
RaisePropertyChanged ( () => Is2xSpeed );
RaisePropertyChanged ( () => Is3xSpeed );
RaisePropertyChanged ( () => Is4xSpeed );
Expand All @@ -1039,17 +1044,41 @@ public bool Is2xSpeed
if ( !Set ( ref m_Is2xSpeed , value ) ) return;

m_IsNormalSpeed = !value;
m_Is15xSpeed = !value;
m_Is3xSpeed = !value;
m_Is4xSpeed = !value;

RaisePropertyChanged ( () => IsNormalSpeed );
RaisePropertyChanged ( () => Is15xSpeed );
RaisePropertyChanged ( () => Is3xSpeed );
RaisePropertyChanged ( () => Is4xSpeed );

ChangePlaybackRate ( 2 );
}
}

/// <summary>
/// Is 2x speed.
/// </summary>
public bool Is15xSpeed {
get => m_Is15xSpeed;
set {
if ( !Set ( ref m_Is15xSpeed , value ) ) return;

m_IsNormalSpeed = !value;
m_Is2xSpeed = !value;
m_Is3xSpeed = !value;
m_Is4xSpeed = !value;

RaisePropertyChanged ( () => IsNormalSpeed );
RaisePropertyChanged ( () => Is2xSpeed );
RaisePropertyChanged ( () => Is3xSpeed );
RaisePropertyChanged ( () => Is4xSpeed );

ChangePlaybackRate ( 1.5 );
}
}

/// <summary>
/// Is 3x speed.
/// </summary>
Expand All @@ -1061,10 +1090,12 @@ public bool Is3xSpeed
if ( !Set ( ref m_Is3xSpeed , value ) ) return;

m_IsNormalSpeed = !value;
m_Is15xSpeed = !value;
m_Is2xSpeed = !value;
m_Is4xSpeed = !value;

RaisePropertyChanged ( () => IsNormalSpeed );
RaisePropertyChanged ( () => Is15xSpeed );
RaisePropertyChanged ( () => Is2xSpeed );
RaisePropertyChanged ( () => Is4xSpeed );

Expand All @@ -1083,10 +1114,12 @@ public bool Is4xSpeed
if ( !Set ( ref m_Is4xSpeed , value ) ) return;

m_IsNormalSpeed = !value;
m_Is15xSpeed = !value;
m_Is3xSpeed = !value;
m_Is2xSpeed = !value;

RaisePropertyChanged ( () => IsNormalSpeed );
RaisePropertyChanged ( () => Is15xSpeed );
RaisePropertyChanged ( () => Is3xSpeed );
RaisePropertyChanged ( () => Is2xSpeed );

Expand Down

0 comments on commit 9169bea

Please sign in to comment.