Ui changes - show ProgramGuide
This commit is contained in:
@@ -26,10 +26,32 @@
|
|||||||
<ColumnDefinition Width="80"/>
|
<ColumnDefinition Width="80"/>
|
||||||
<ColumnDefinition Width="*"/>
|
<ColumnDefinition Width="*"/>
|
||||||
<ColumnDefinition Width="80"/>
|
<ColumnDefinition Width="80"/>
|
||||||
|
<ColumnDefinition Width="80"/>
|
||||||
</Grid.ColumnDefinitions>
|
</Grid.ColumnDefinitions>
|
||||||
<Button Height="50" Width="70" Margin="10,0,0,0" Style="{DynamicResource ButtonBack}" Command="{Binding BackCommand}" />
|
<Button Height="50" Width="70" Margin="10,0,0,0" Style="{DynamicResource ButtonBack}" Command="{Binding BackCommand}" />
|
||||||
<TextBlock Grid.Column="1" FontSize="20" Foreground="White" Text="{Binding TopPanelTitle}" HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
<TextBlock Grid.Column="1" FontSize="20" Foreground="White" Text="{Binding TopPanelTitle}" HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||||
<Button Grid.Column="4" Height="70" Width="50" Margin="10,0,0,0" Style="{DynamicResource ButtonFullScreen}" Command="{Binding FullscreenCommand}" />
|
<Button Grid.Column="2" Height="70" Width="50" Margin="10,0,0,0" Style="{DynamicResource ButtonFullScreen}" Command="{Binding FullscreenCommand}" />
|
||||||
|
<Button Grid.Column="3" Height="70" Width="70" Margin="10,0,0,0" Style="{DynamicResource ButtonClose}" Command="{Binding CloseAppCommand}" />
|
||||||
|
</Grid>
|
||||||
|
<Grid Grid.Row="1" Width="400" HorizontalAlignment="Left" Background="#B0000000"
|
||||||
|
Visibility="{Binding ProgramGuideVisible,Converter={StaticResource BooleanToVisibilityConverterKey}}">
|
||||||
|
<ItemsControl Name="SidebarListView" ItemsSource="{Binding Programs}"
|
||||||
|
Background="Transparent"
|
||||||
|
BorderThickness="0"
|
||||||
|
ScrollViewer.HorizontalScrollBarVisibility="Hidden"
|
||||||
|
ScrollViewer.VerticalScrollBarVisibility="Hidden">
|
||||||
|
<ItemsControl.ItemTemplate>
|
||||||
|
<DataTemplate>
|
||||||
|
<StackPanel Orientation="Vertical">
|
||||||
|
<TextBlock Text="{Binding Title}" HorizontalAlignment="Stretch" TextWrapping="Wrap" FontSize="15" Foreground="White" TextAlignment="Left" Margin="1,0,1,2"/>
|
||||||
|
<StackPanel Orientation="Horizontal">
|
||||||
|
<TextBlock Text="{Binding StartTime ,StringFormat={}{0:HH:mm}}" FontSize="12" TextAlignment="Center" Foreground="White" HorizontalAlignment="Center" TextWrapping="Wrap" Margin="1,0,1,2"/>
|
||||||
|
<TextBlock Text="{Binding EndTime ,StringFormat={}{0:HH:mm}}" FontSize="12" TextAlignment="Center" Foreground="White" HorizontalAlignment="Center" TextWrapping="Wrap" Margin="10,0,1,2"/>
|
||||||
|
</StackPanel>
|
||||||
|
</StackPanel>
|
||||||
|
</DataTemplate>
|
||||||
|
</ItemsControl.ItemTemplate>
|
||||||
|
</ItemsControl>
|
||||||
</Grid>
|
</Grid>
|
||||||
<Grid Grid.Row="2" Background="#B0000000">
|
<Grid Grid.Row="2" Background="#B0000000">
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
@@ -53,6 +75,9 @@
|
|||||||
<ProgressBar Height="10" Foreground="Yellow" Name="progressBar" Value="{Binding DurationValue}" Maximum="100" VerticalAlignment="Center" HorizontalAlignment="Center" Width="400"/>
|
<ProgressBar Height="10" Foreground="Yellow" Name="progressBar" Value="{Binding DurationValue}" Maximum="100" VerticalAlignment="Center" HorizontalAlignment="Center" Width="400"/>
|
||||||
<TextBlock FontSize="15" Foreground="White" Text="{Binding EndProgram}" HorizontalAlignment="Center" />
|
<TextBlock FontSize="15" Foreground="White" Text="{Binding EndProgram}" HorizontalAlignment="Center" />
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
<Grid.InputBindings>
|
||||||
|
<MouseBinding MouseAction="LeftClick" Command="{Binding ShowProgramListCommand}"/>
|
||||||
|
</Grid.InputBindings>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|||||||
@@ -17,16 +17,16 @@ namespace TV_Player
|
|||||||
private LibVLC _libVLC;
|
private LibVLC _libVLC;
|
||||||
private MediaPlayer _mediaPlayer;
|
private MediaPlayer _mediaPlayer;
|
||||||
private PlayerViewModel _viewModel;
|
private PlayerViewModel _viewModel;
|
||||||
private DispatcherTimer _overlayAutoHideTimer;
|
//private DispatcherTimer _overlayAutoHideTimer;
|
||||||
|
|
||||||
public VideoPlayer()
|
public VideoPlayer()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
||||||
_overlayAutoHideTimer = new DispatcherTimer();
|
//_overlayAutoHideTimer = new DispatcherTimer();
|
||||||
_overlayAutoHideTimer.Interval = TimeSpan.FromSeconds(3);
|
//_overlayAutoHideTimer.Interval = TimeSpan.FromSeconds(3);
|
||||||
_overlayAutoHideTimer.Tick += _overlayAutoHideTimer_Tick;
|
//_overlayAutoHideTimer.Tick += _overlayAutoHideTimer_Tick;
|
||||||
_overlayAutoHideTimer.Start();
|
//_overlayAutoHideTimer.Start();
|
||||||
|
|
||||||
_libVLC = new LibVLC(enableDebugLogs: true);
|
_libVLC = new LibVLC(enableDebugLogs: true);
|
||||||
_mediaPlayer = new MediaPlayer(_libVLC);
|
_mediaPlayer = new MediaPlayer(_libVLC);
|
||||||
@@ -58,6 +58,7 @@ namespace TV_Player
|
|||||||
|
|
||||||
private void VideoView_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
|
private void VideoView_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
|
||||||
{
|
{
|
||||||
|
|
||||||
ToggleOverlay();
|
ToggleOverlay();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -88,7 +89,8 @@ namespace TV_Player
|
|||||||
private void ToggleOverlay()
|
private void ToggleOverlay()
|
||||||
{
|
{
|
||||||
if (overlayPanel.Visibility == Visibility.Visible)
|
if (overlayPanel.Visibility == Visibility.Visible)
|
||||||
{
|
{
|
||||||
|
_viewModel.ProgramGuideVisible = false;
|
||||||
HideOverlay();
|
HideOverlay();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -104,12 +106,12 @@ namespace TV_Player
|
|||||||
|
|
||||||
public void ShowOverlay()
|
public void ShowOverlay()
|
||||||
{
|
{
|
||||||
_overlayAutoHideTimer.Start();
|
//_overlayAutoHideTimer.Start();
|
||||||
overlayPanel.Visibility = Visibility.Visible;
|
overlayPanel.Visibility = Visibility.Visible;
|
||||||
}
|
}
|
||||||
public void HideOverlay()
|
public void HideOverlay()
|
||||||
{
|
{
|
||||||
_overlayAutoHideTimer.Stop();
|
// _overlayAutoHideTimer.Stop();
|
||||||
overlayPanel.Visibility = Visibility.Collapsed;
|
overlayPanel.Visibility = Visibility.Collapsed;
|
||||||
}
|
}
|
||||||
private void UserControl_Unloaded(object sender, RoutedEventArgs e)
|
private void UserControl_Unloaded(object sender, RoutedEventArgs e)
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ namespace TV_Player
|
|||||||
public string Title { get => _title; set => SetProperty(ref _title, value); }
|
public string Title { get => _title; set => SetProperty(ref _title, value); }
|
||||||
|
|
||||||
public DateTime StartTime { get; set; }
|
public DateTime StartTime { get; set; }
|
||||||
public DateTime StopTime { get; set; }
|
public DateTime EndTime { get; set; }
|
||||||
public int DurationValue { get => _durationValue; set => SetProperty(ref _durationValue, value); }
|
public int DurationValue { get => _durationValue; set => SetProperty(ref _durationValue, value); }
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -75,7 +75,7 @@ namespace TV_Player
|
|||||||
var id = reader.GetAttribute("channel");
|
var id = reader.GetAttribute("channel");
|
||||||
var channel = epgChannels.FirstOrDefault(x => x.Id == id);
|
var channel = epgChannels.FirstOrDefault(x => x.Id == id);
|
||||||
program.StartTime = DateTime.ParseExact(reader.GetAttribute("start"), "yyyyMMddHHmmss zzz", null);
|
program.StartTime = DateTime.ParseExact(reader.GetAttribute("start"), "yyyyMMddHHmmss zzz", null);
|
||||||
program.StopTime = DateTime.ParseExact(reader.GetAttribute("stop"), "yyyyMMddHHmmss zzz", null);
|
program.EndTime = DateTime.ParseExact(reader.GetAttribute("stop"), "yyyyMMddHHmmss zzz", null);
|
||||||
|
|
||||||
reader.Read();
|
reader.Read();
|
||||||
program.Title = reader.ReadElementContentAsString();
|
program.Title = reader.ReadElementContentAsString();
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ namespace TV_Player
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnCloseAppButtonClick()
|
public void OnCloseAppButtonClick()
|
||||||
{
|
{
|
||||||
Environment.Exit(0);
|
Environment.Exit(0);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using CommunityToolkit.Mvvm.Input;
|
using CommunityToolkit.Mvvm.Input;
|
||||||
|
using System;
|
||||||
using System.Reactive.Linq;
|
using System.Reactive.Linq;
|
||||||
using System.Windows.Input;
|
using System.Windows.Input;
|
||||||
using TV_Player.ViewModels;
|
using TV_Player.ViewModels;
|
||||||
@@ -54,12 +55,28 @@ namespace TV_Player
|
|||||||
get => _endProgram;
|
get => _endProgram;
|
||||||
set => SetProperty(ref _endProgram, value);
|
set => SetProperty(ref _endProgram, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private bool _programGuideVisible;
|
||||||
|
public bool ProgramGuideVisible
|
||||||
|
{
|
||||||
|
get => _programGuideVisible;
|
||||||
|
set => SetProperty(ref _programGuideVisible, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
List<ProgramInfo> _programsOnCurrentChannel;
|
||||||
|
public List<ProgramInfo> Programs
|
||||||
|
{
|
||||||
|
get => _programsOnCurrentChannel;
|
||||||
|
set => SetProperty(ref _programsOnCurrentChannel, value);
|
||||||
|
}
|
||||||
|
|
||||||
private List<M3UInfo> _programs;
|
private List<M3UInfo> _programs;
|
||||||
public ICommand BackCommand { get; }
|
public ICommand BackCommand { get; }
|
||||||
public ICommand FullscreenCommand { get; }
|
public ICommand FullscreenCommand { get; }
|
||||||
public ICommand NextCommand { get; }
|
public ICommand NextCommand { get; }
|
||||||
public ICommand PreviousCommand { get; }
|
public ICommand PreviousCommand { get; }
|
||||||
|
public ICommand ShowProgramListCommand { get; }
|
||||||
|
public ICommand CloseAppCommand { get; }
|
||||||
|
|
||||||
private ProgramGuide _currentGuide;
|
private ProgramGuide _currentGuide;
|
||||||
private ProgramInfo _currentProgramInfo;
|
private ProgramInfo _currentProgramInfo;
|
||||||
@@ -77,6 +94,9 @@ namespace TV_Player
|
|||||||
NextCommand = new RelayCommand(NextProgram);
|
NextCommand = new RelayCommand(NextProgram);
|
||||||
PreviousCommand = new RelayCommand(PreviousProgram);
|
PreviousCommand = new RelayCommand(PreviousProgram);
|
||||||
FullscreenCommand = new RelayCommand(TVPlayerViewModel.Instance.FullScreenToggle);
|
FullscreenCommand = new RelayCommand(TVPlayerViewModel.Instance.FullScreenToggle);
|
||||||
|
CloseAppCommand = new RelayCommand(TVPlayerViewModel.Instance.CloseAppCommand);
|
||||||
|
ShowProgramListCommand = new RelayCommand(ShowProgramList);
|
||||||
|
ProgramGuideVisible = false;
|
||||||
|
|
||||||
_programSubscriber = TVPlayerViewModel.Instance.PlaylistData.AllPrograms.Subscribe(x =>
|
_programSubscriber = TVPlayerViewModel.Instance.PlaylistData.AllPrograms.Subscribe(x =>
|
||||||
{
|
{
|
||||||
@@ -101,6 +121,7 @@ namespace TV_Player
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
_currentGuide = x.FirstOrDefault(p => p.Id == _currentProgram.TvgID);
|
_currentGuide = x.FirstOrDefault(p => p.Id == _currentProgram.TvgID);
|
||||||
|
|
||||||
UpdateScreenInfo();
|
UpdateScreenInfo();
|
||||||
|
|
||||||
_timer = Observable.Interval(TimeSpan.FromMinutes(1)).Subscribe(x =>
|
_timer = Observable.Interval(TimeSpan.FromMinutes(1)).Subscribe(x =>
|
||||||
@@ -121,6 +142,7 @@ namespace TV_Player
|
|||||||
_programGuideDisposable?.Dispose();
|
_programGuideDisposable?.Dispose();
|
||||||
UpdateUI();
|
UpdateUI();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void NextProgram()
|
private void NextProgram()
|
||||||
{
|
{
|
||||||
_currentProgramIndex += 1;
|
_currentProgramIndex += 1;
|
||||||
@@ -130,11 +152,19 @@ namespace TV_Player
|
|||||||
_programGuideDisposable?.Dispose();
|
_programGuideDisposable?.Dispose();
|
||||||
UpdateUI();
|
UpdateUI();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void ShowProgramList()
|
||||||
|
{
|
||||||
|
ProgramGuideVisible = true;
|
||||||
|
}
|
||||||
|
|
||||||
private void UpdateScreenInfo()
|
private void UpdateScreenInfo()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
_currentProgramInfo = _currentGuide.Programs.FirstOrDefault(d => d.StartTime <= DateTime.Now && d.StopTime >= DateTime.Now);
|
_currentProgramInfo = _currentGuide.Programs.FirstOrDefault(d => d.StartTime <= DateTime.Now && d.EndTime >= DateTime.Now);
|
||||||
|
Programs = _currentGuide.Programs.Skip(_currentGuide.Programs.FindIndex(x=>x.Title==_currentProgramInfo.Title)).Take(7).ToList();
|
||||||
|
|
||||||
if (_currentProgramInfo == null)
|
if (_currentProgramInfo == null)
|
||||||
{
|
{
|
||||||
IsProgramInfoVisible = false;
|
IsProgramInfoVisible = false;
|
||||||
@@ -144,9 +174,9 @@ namespace TV_Player
|
|||||||
IsProgramInfoVisible = true;
|
IsProgramInfoVisible = true;
|
||||||
ProgramGuideText = _currentProgramInfo.Title;
|
ProgramGuideText = _currentProgramInfo.Title;
|
||||||
StartProgram = _currentProgramInfo.StartTime.ToShortTimeString();
|
StartProgram = _currentProgramInfo.StartTime.ToShortTimeString();
|
||||||
EndProgram = _currentProgramInfo.StopTime.ToShortTimeString();
|
EndProgram = _currentProgramInfo.EndTime.ToShortTimeString();
|
||||||
|
|
||||||
var programMinutes = (_currentProgramInfo.StopTime - _currentProgramInfo.StartTime).TotalMinutes;
|
var programMinutes = (_currentProgramInfo.EndTime - _currentProgramInfo.StartTime).TotalMinutes;
|
||||||
DurationValue = (int)((DateTime.Now - _currentProgramInfo.StartTime).TotalMinutes / programMinutes * 100);
|
DurationValue = (int)((DateTime.Now - _currentProgramInfo.StartTime).TotalMinutes / programMinutes * 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -117,6 +117,11 @@ namespace TV_Player.ViewModels
|
|||||||
_mainViewModel.OnFullSctreenButtonClick();
|
_mainViewModel.OnFullSctreenButtonClick();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void CloseAppCommand()
|
||||||
|
{
|
||||||
|
_mainViewModel.OnCloseAppButtonClick();
|
||||||
|
}
|
||||||
|
|
||||||
public void SetBackButtonAction(Action action)
|
public void SetBackButtonAction(Action action)
|
||||||
{
|
{
|
||||||
_mainViewModel.ButtonBackAction = action;
|
_mainViewModel.ButtonBackAction = action;
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ namespace TV_Player.MAUI
|
|||||||
public string Title { get => _title; set => SetProperty(ref _title, value); }
|
public string Title { get => _title; set => SetProperty(ref _title, value); }
|
||||||
|
|
||||||
public DateTime StartTime { get; set; }
|
public DateTime StartTime { get; set; }
|
||||||
public DateTime StopTime { get; set; }
|
public DateTime EndTime { get; set; }
|
||||||
public int DurationValue { get => _durationValue; set => SetProperty(ref _durationValue, value); }
|
public int DurationValue { get => _durationValue; set => SetProperty(ref _durationValue, value); }
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -74,7 +74,7 @@ namespace TV_Player.MAUI
|
|||||||
var id = reader.GetAttribute("channel");
|
var id = reader.GetAttribute("channel");
|
||||||
var channel = epgChannels.FirstOrDefault(x => x.Id == id);
|
var channel = epgChannels.FirstOrDefault(x => x.Id == id);
|
||||||
program.StartTime = DateTime.ParseExact(reader.GetAttribute("start"), "yyyyMMddHHmmss zzz", null);
|
program.StartTime = DateTime.ParseExact(reader.GetAttribute("start"), "yyyyMMddHHmmss zzz", null);
|
||||||
program.StopTime = DateTime.ParseExact(reader.GetAttribute("stop"), "yyyyMMddHHmmss zzz", null);
|
program.EndTime = DateTime.ParseExact(reader.GetAttribute("stop"), "yyyyMMddHHmmss zzz", null);
|
||||||
|
|
||||||
reader.Read();
|
reader.Read();
|
||||||
program.Title = reader.ReadElementContentAsString();
|
program.Title = reader.ReadElementContentAsString();
|
||||||
|
|||||||
Reference in New Issue
Block a user